Created
July 8, 2020 16:30
-
-
Save vladar/ffcab42fcfa11e2f0fb2125259b1a103 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.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