Gatsby: [v2] gatsby-node: Cannot read property "edges" of null

Created on 18 Jun 2018  路  8Comments  路  Source: gatsbyjs/gatsby

Description

I tried to upgrade my portfolio to v2. Since I already upgraded multiple sites I know what I had to do and in the past I never had a problem with gatsby-node.js.

The creating of the pages worked without problems in v1, the projects query also works in GraphiQL but now I'm getting the error:

TypeError: Cannot read property 'edges' of null
gatsby-node.js:107 graphql.then.result
E:/Lennart/Documents/GitHub/portfolio/gatsby-node.js:107:50

Steps to reproduce

https://github.com/LeKoArts/portfolio/blob/feature/gatsby-v2/gatsby-node.js#L73-L107

When running gatsby develop the above mentioned error occurs.

Expected result

result.data.projects.edges should contain an array

It worked exactly like that in v1!

Actual result

result.data.projects.edges is null

help wanted bug

Most helpful comment

All 8 comments

Hey @LeKoArts, I'm seeing the same thing when I run your project locally. It's strange - onCreateNode doesn't seem to get the projekte nodes either. It'd be great to figure out the source of this error if you're able to do a bit more investigation?

@m-allanson

It's strange - onCreateNode doesn't seem to get the projekte nodes either.

When you insert console.log(`Filenode: ${fileNode.sourceInstanceName}`); under line 13 you actually get Filenode: blog and Filenode: projekte.

createPages seems to be the issue in my opinion. As said if you run the query in GraphiQL, everything works. And for the v2 update I didn't change anything else. So I'm pretty clueless what to investigate as I don't see what to look for on my end as my code hasn't changed.

I did try a bunch of things without any luck:
1) Remove the posts query
2) Remove the alias on projects
3) Choose another alias
4) Do it like gatsby. That did help the error in the console, but when localhost got served the pages weren't created.
5) Remove parts of the query like cover

@m-allanson @pieh Did you try it?

Because on my end it still isn't working.

I did try it with your feature/gatsby-v2 branch locally and it did fix this problem for me. It wasn't published yet - did you try applying changes manually or just updated packages?

---edit
here's screenshot of bootstrap completing (and console log with results of query):
lekoarts-fs-issue

@LeKoArts [email protected] is published now.

Ah, looking at the beta.2 release (here on GitHub - the PR was merged there?) I was assuming the fix is live. Will pull the new version later (I only updated packages)

@pieh Working now! 馃憤
Thank you very much!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ferMartz picture ferMartz  路  3Comments

brandonmp picture brandonmp  路  3Comments

jimfilippou picture jimfilippou  路  3Comments

theduke picture theduke  路  3Comments

signalwerk picture signalwerk  路  3Comments