-
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
[1.0] Questions about the Node API and ___NODE in particular #1220
Comments
This is a really helpful list of questions :-) Lemme turn answers to this into a new docs page on advanced data modeling or whatever. |
@KyleAMathews Did anything substantial change in this API recently? With the current HEAD my plugin stopped working. It was fine about a week ago. I'll investigate further, but maybe you know something obvious from the top of your head. With stopped working I mean the markdown field is left as the original string and is not transformed to remark / markdown node anymore. The original node seems to be untouched. |
There's also #1299 |
I think it fails before MarkdownRemark. In my plugin code above the Gatsby now tells me that Do you see anything funny or outdated about the code above maybe? |
Ah I see where things go wrong. At the top of my plugin I have
But the json files picked up by the filesystem source plugin are not set as I think it makes sense to have the filesystem source plugin set media types always. What do you think? |
The filesystem source plugin does (should?) always set a media/type. A lot of other plugins don't now though. |
Ah yes sorry it is the |
I have my site content pulled in via JSON files. Some of those JSON fields contain Markdown. The following snippet creates a MarkdownField node when it finds a JSON object with a field that matches the given name. Because this MarkdownField gets the markdown mediaType, the remark plugin picks it up to generate a childMarkdownRemark on that node with the rendered HTML.
It works but I'm not 100% sure this is the right approach. I took bits from looking at other plugins but I think the documentation is currently lacking some info so I'm left with some questions.
node[
${field}___NODE] = fieldNodeId
seems to replace the field of an existing node with a reference to another node. I'm not sure ifdelete node[field]
after that is required. Not all plugins seem to do this consistently. Is___NODE
something specific to Gatsby or is it internal to Relay or GraphQL?node.children = node.children.concat([fieldNodeId])
is required, whennode[
${field}___NODE] = fieldNodeId
is already linking a field to the node in question.createParentChildLink({ parent: node, child: fieldNode })
instead if a JSON node only ever contained one markdown field, but since there can be multiple I think this___NODE
api is the way to go, right, or could I also use the new plugin fields API for this?The text was updated successfully, but these errors were encountered: