Last active
July 10, 2020 07:27
-
-
Save vladar/d7659285b7292cde011687939e158d6a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.sourceNodes = async (gatsbyAPI, pluginOptions) => { | |
const config = await createSourcingConfig(gatsbyApi) | |
const { webhookBody } = gatsbyAPI | |
if (webhookBody && Object.keys(webhookBody).length) { | |
const { isDelete, typeName, id } = webhookBody | |
const nodeEvent = isDelete | |
? { | |
eventName: "DELETE", | |
remoteTypeName: typeName, | |
remoteId: { __typename: typeName, id }, | |
} | |
: { | |
eventName: "UPDATE", | |
remoteTypeName: typeName, | |
remoteId: { __typename: typeName, id }, | |
} | |
await sourceNodeChanges(config, { nodeEvents: [nodeEvent] }) | |
} else { | |
// Normal full sourcing | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment