staticfuse / create-gatsby-theme-publisher

Use this to create a new Gatsby site with the Publisher theme.
22 stars 6 forks source link

Error #11321 Plugin Cannot read property 'nodes' of null #7

Open davidshq opened 4 years ago

davidshq commented 4 years ago

Using a git clone from today (4/8/20), running yarn, and then gatsby develop results in the following error:

NOTE: This only occurs with one of the sites I've tried using this theme for, the other one works fine, no errors...unsure what is causing an issue in this one site.

ERROR #11321 PLUGIN

"@staticfuse/gatsby-theme-publisher" threw an error while running the createPages lifecycle:

Cannot read property 'nodes' of null

TypeError: Cannot read property 'nodes' of null

  • createPages.js:96 [create-gatsby-theme-publisher]/[@staticfuse]/gatsby-theme-publisher/create/createPages.js:96:13

  • runMicrotasks

  • task_queues.js:97 processTicksAndRejections internal/process/task_queues.js:97:5

  • createPages.js:89 async fetchPages [create-gatsby-theme-publisher]/[@staticfuse]/gatsby-theme-publisher/create/createPages.js:89:5

  • createPages.js:157 async module.exports [create-gatsby-theme-publisher]/[@staticfuse]/gatsby-theme-publisher/create/createPages.js:157:19

  • gatsby-node.js:23 async Object.exports.createPages [create-gatsby-theme-publisher]/[@staticfuse]/gatsby-theme-publisher/gatsby-node.js:23:3

Failed createPages

This was preceded by "USER TOTAL: 5" and followed by "success createPagesStatefully - 0.077s"

I think this caused the static pages that are dynamically created for this site and not sourced from WP to fail (as they return 404's).

justinwhall commented 4 years ago

Hey @davidshq -

success createPagesStatefully - 0.077s suggests that no pages were created.

createPages.js:96
[create-gatsby-theme-publisher]/[@staticfuse]/gatsby-theme-publisher/create/createPages.js:96:13

And this confirms that no pages were created from WordPress anyway. There are no nodes here. A number of things could be going on here but...

1) Is the WPGraphql plugin installed, activated and working? 2) Do you have any pages? 3) Do you have a URL I can take a look at?

davidshq commented 4 years ago

Hi Justin,

The WPGraphQL plugin is installed, activated, and working.

There are a number of pages.

URL is dev.liquidchurch.com

davidshq commented 4 years ago

(Ignore this for a minute, I just realized I put into the config file https but haven't setup a cert on this site yet, retrying with updated config files)

I setup a fresh install of WP at gatsby.liquidchurch.com to see if the issue was something with my WP install (at dev.liquidchurch.com, which is a copy of a production site).

I added and enabled the WPGraphQL and WPGraphiQL plugins. I disabled all other plugins.

I then followed these steps on my local machine:

  1. git clone https://github.com/staticfuse/create-gatsby-theme-publisher lqdgatsby
  2. cd lqdgatsby
  3. yarn
  4. Edit gatsby-config.js
    • siteURL: https://gatsby.liquidchurch.com
    • wordPressUrl: https://gatsby.liquidchurch.com/graphql
    • menuName: Main Menu
  5. gatsby develop

But I'm still getting errors...Here is the output from running gatsby develop. Figured this would be easier to troubleshoot than what I originally posted...

success open and validate gatsby-configs - 0.028s success load plugins - 0.748s success onPreInit - 0.003s success initialize cache - 0.008s success copy gatsby files - 0.058s success onPreBootstrap - 0.012s

ERROR #11321 PLUGIN

"gatsby-source-graphql" threw an error while running the sourceNodes lifecycle:

Unexpected token < in JSON at position 0

ServerParseError: Unexpected token < in JSON at position 0

  • JSON.parse

  • index.js:35 [lqdgatsby]/[apollo-link-http-common]/lib/index.js:35:25

  • task_queues.js:97 processTicksAndRejections internal/process/task_queues.js:97:5

warn The gatsby-source-graphql plugin has generated no Gatsby nodes. Do you need it? success source and transform nodes - 0.470s warn createResolvers passed resolvers for type WPGraphQL_MediaItem that doesn't exist in the schema. Use success building schema - 0.362s

ERROR #85901 GRAPHQL

There was an error in your GraphQL query:

Cannot query field "wpgraphql" on type "Query".

File: node_modules\@staticfuse\gatsby-theme-publisher\gatsby-node.js:19:9

ERROR #85901 GRAPHQL

There was an error in your GraphQL query:

Unknown type "WPGraphQL_Post".

File: node_modules\@staticfuse\gatsby-theme-publisher\gatsby-node.js:19:9

ERROR #85901 GRAPHQL

There was an error in your GraphQL query:

Unknown type "WPGraphQL_Post".

File: node_modules\@staticfuse\gatsby-theme-publisher\gatsby-node.js:19:9

ERROR #11321 PLUGIN

"@staticfuse/gatsby-theme-publisher" threw an error while running the createPages lifecycle:

Cannot read property 'wpgraphql' of undefined

TypeError: Cannot read property 'wpgraphql' of undefined

  • createPosts.js:135 [lqdgatsby]/[@staticfuse]/gatsby-theme-publisher/create/createPosts.js:135:9

  • createPosts.js:198 async module.exports [lqdgatsby]/[@staticfuse]/gatsby-theme-publisher/create/createPosts.js:198:3

  • gatsby-node.js:19 async Object.exports.createPages [lqdgatsby]/[@staticfuse]/gatsby-theme-publisher/gatsby-node.js:19:3

failed createPages - 0.195s success createPagesStatefully - 0.068s success onPreExtractQueries - 0.005s success update schema - 0.034s

ERROR #85901 GRAPHQL

There was an error in your GraphQL query:

Unknown type "WPGraphQL_MenuItem".

File: node_modules\@staticfuse\gatsby-theme-publisher\src\components\Menu.js:15:26

failed extract queries from components - 0.512s success write out requires - 0.070s success write out redirect data - 0.008s success onPostBootstrap - 0.006s ⠀ info bootstrap finished - 6.641 s ⠀ success run queries - 0.033s - 3/3 91.26/s warn Browserslist: caniuse-lite is outdated. Please run next command yarn upgrade ⠀ You can now view create-gatsby-theme-publisher in the browser. ⠀ http://localhost:8000/ ⠀ View GraphiQL, an in-browser IDE, to explore your site's data and schema ⠀ http://localhost:8000/___graphql ⠀ Note that the development build is not optimized. To create a production build, use gatsby build ⠀ success Building development bundle - 4.233s

davidshq commented 4 years ago

So for the new, fresh install (gatsby.liquidchurch.com) it was a config mistake on my end. Namely, I had configured the config with https but the site is currently only http.

I'm not sure what the original install's problem was (dev.liquidchurch.com) as that does use https and have a valid cert.