Upgrading gatsby-source-contentful from 2.1.88 to 2.2.5 resulted in build errors, as we're unable to use gatsby's getNode function with a valid node id string. Using the graphql search I can find the node.
Of note: it's a parent node to the current node we're inspecting
I should be able to fetch a node by getNode on gatsby-source-contentful 2.2.5
getNode returns null
System:
OS: macOS 10.15.2
CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 10.13.0 - ~/.nvm/versions/node/v10.13.0/bin/node
Yarn: 1.19.2 - /usr/local/bin/yarn
npm: 6.4.1 - ~/.nvm/versions/node/v10.13.0/bin/npm
Languages:
Python: 3.7.6 - /usr/local/opt/python/libexec/bin/python
Browsers:
Chrome: 80.0.3987.163
Safari: 13.0.4
npmPackages:
gatsby: ^2.20.12 => 2.20.12
gatsby-image: ^2.0.13 => 2.0.33
gatsby-plugin-canonical-urls: ^2.1.5 => 2.1.5
gatsby-plugin-catch-links: ^2.1.5 => 2.1.17
gatsby-plugin-favicon: ^3.1.6 => 3.1.6
gatsby-plugin-google-gtag: ^1.0.17 => 1.0.17
gatsby-plugin-hotjar: ^1.0.1 => 1.0.1
gatsby-plugin-netlify-cache: ^1.0.0 => 1.0.0
gatsby-plugin-polyfill-io: ^1.1.0 => 1.1.0
gatsby-plugin-react-helmet: ^3.0.12 => 3.0.12
gatsby-plugin-robots-txt: ^1.3.0 => 1.3.0
gatsby-plugin-sass: ^2.0.1 => 2.0.7
gatsby-plugin-sharp: ^2.4.5 => 2.4.5
gatsby-plugin-sitemap: ^2.0.5 => 2.0.5
gatsby-plugin-typescript: ^2.0.15 => 2.0.15
gatsby-plugin-webpack-bundle-analyzer: ^1.0.5 => 1.0.5
gatsby-source-contentful: ^2.2.5 => 2.2.5
gatsby-source-filesystem: ^2.0.2 => 2.0.5
gatsby-source-stripe: ^3.0.4 => 3.0.4
gatsby-transformer-sharp: ^2.3.14 => 2.3.14
npmGlobalPackages:
gatsby-cli: 2.11.5
I've also updated node to 12.16.1 -- and still fails
Hey @glenna, thanks for filling this bug.
That's a big leap in versions, I'll see if I can find the culprit and create an update. When does this happen? Initially or when you get a contentful update?
Is it possible to give me some steps to reproduce? (I have access to gatsby cloud 馃槃 )
Thanks for taking a look! Let me know if you need more information!
So, internally, we have a gatsby plugin that adds some fields to our content/node (this case in particular is generating the path for the page and adding it as a field on the content/node).
We have a content model that has another content model as a child. When we are doing our transformations on the child node, we get the reference to the parent node like so
const parentNode = rest.getNode(
node['name of content type of parent node___NODE'][0]
)
It's important to note that node['name of content type of parent node___NODE'][0] does return a node ID, and in graphiql, we're able to find a node with that ID when querying in allContentfulNameOfContentTypeOfParentNode and filtering for IDs matching the one returned above.
If it helps, you can look at our branch builds on gatsby builds: upgrade/gatsby-source-contentful
Same here, though I am querying the other way around, from parent to child.
2.2.x did not work, getNode returns undefined for me. I downgrade to 2.1.100 which works perfectly fine.
Potentially related: Contentful nodes aren't showing up when calling the onCreateNode in gatsby-node.js. As with the other issues, this isn't a problem in 2.1.100. Puzzle!
Any updates on this?
Hiya!
This issue has gone quiet. Spooky quiet. 馃懟
We get a lot of issues, so we currently close issues after 30 days of inactivity. It鈥檚 been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!
Thanks for being a part of the Gatsby community! 馃挭馃挏
Not stable. I believe it is in the backlog to work on.
Hiya!
This issue has gone quiet. Spooky quiet. 馃懟
We get a lot of issues, so we currently close issues after 30 days of inactivity. It鈥檚 been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!
Thanks for being a part of the Gatsby community! 馃挭馃挏
Not stale.
Hiya!
This issue has gone quiet. Spooky quiet. 馃懟
We get a lot of issues, so we currently close issues after 30 days of inactivity. It鈥檚 been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!
Thanks for being a part of the Gatsby community! 馃挭馃挏
Not stale. Still waiting to be fixed.
Hiya!
This issue has gone quiet. Spooky quiet. 馃懟
We get a lot of issues, so we currently close issues after 30 days of inactivity. It鈥檚 been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!
Thanks for being a part of the Gatsby community! 馃挭馃挏
More waiting..
Curious, any progress of this case?
I'm facing the same in [email protected]
if (node.internal.type === "ContentfulPost") {
if (node.categories___NODE && node.categories___NODE.length)
console.log(getNode(node.categories___NODE[0]))
}
returns null or undefined but works other way:
if (node.internal.type === "ContentfulCategory") {
if (node.post___NODE && node.post___NODE.length)
console.log(getNode(node.post___NODE[0]))
}
I'm new to Gatsby, so I thought I didn't understand the concept thus spent the last 2 days in Gatsby docs and QA sites but I think it should work when it is not.
I can confirm that [email protected] has solved my problem but it's not the latest version of course.
@xmflsct
Hey there, we changed a lot related to the ids of nodes. Could you check with latest v4 of the plugin if your issue still exists?
Thanks :)
@axe312ger Thanks for the update! I have been using 2.3.51 for a while now without problem. :)
Seems to be fixed in the latest versions. If you still run into this issue, and use v4 of the gatsby-source-contentful plugin, feel free to comment here.