Skip to content

Instantly share code, notes, and snippets.

@vladar
Last active Jul 10, 2020
Embed
What would you like to do?
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