Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
exports.onCreateNode = async ({
node,
actions: { createNode },
createNodeId,
getCache,
}) => {
if (node.remoteTypeName === 'Asset' && node.mimeType.includes('image/')) {
const fileNode = await createRemoteFileNode({
url: node.url,
parentNodeId: node.id,
createNode,
createNodeId,
getCache,
})
if (fileNode) node.remoteFile = fileNode.id
}
}
exports.createSchemaCustomization = ({ actions }) => {
actions.createTypes(`
type GraphCMS_Asset {
remoteFile: File @link
}
`)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment