-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to manually set graphql type / link to existing nodes #1583
Comments
Yes, you can can use createNodeField with the not-yet-documented Something like. createNodeField({
node,
name: `nodeLink___NODE`,
value: `ID_OF_ANOTHER_NODE`
}) The auto-linking to file nodes is a special case that relies on relative links between file nodes. When you create links like above, you need to use the actual ID of the node you're trying to link to. |
i keep having this error message
it comes from
|
I have the same problem as @peonmodel. Trying to create a node field on a SitePage node with createNodeField({
node,
name: 'source___NODE',
value: jsFrontmatterNode.id
}); but I'm getting
what's wrong? |
My code is something like this: exports.onCreateNode = ({ node, getNode, boundActionCreators }) => {
const { createNodeField } = boundActionCreators;
if (node.internal.type === 'SitePage') {
const jsFrontmatterNode = getNode(`${node.component} absPath of file >>> JSFrontmatter`);
if (jsFrontmatterNode) {
createNodeField({
node,
name: 'source___NODE',
value: jsFrontmatterNode.id
});
}
}
}; |
i see that infer-graphql-type.js will automatically inferObjectStructureFromNodes to create links between nodes
such that an .md file with frontmatter (image: '11.jpg') will return from graphql as frontmatter.image = { id:
${dir}/11.jpg
}is it possible to manually create the links on onCreateNode or something similar?
The text was updated successfully, but these errors were encountered: