zgordon / tabor-gatsby-theme

A port of the Tabor WordPress Theme over to Gatsby
77 stars 23 forks source link

Compiling Error when fetching Menus #12

Closed derweili closed 5 years ago

derweili commented 5 years ago

I installed my own WordPress, the WPGraphQL Plugin and added the WP URL to gatsby-config.js

When running yarn workspace site develop I get some errors and the compiling fails.

error GraphQL Error Expected type WPGraphQL_MenuLocationEnum, found PRIMARY.

  file: /Users/werbeagenten/Code/tabor-gatsby-theme/packages/gatsby-theme-tabor/src/components/Menu.js

   3 |     id
   4 |     label
   5 |     url
   6 |     connectedObject {
   7 |       __typename
   8 |     }
   9 |   }
  10 |
  11 |   query GET_MENU_ITEMS {
  12 |     wpgraphql {
> 13 |       menuItems(where: { location: PRIMARY }) {
     |                                    ^
  14 |         nodes {
  15 |           ...MenuFields
  16 |           childItems {
  17 |             nodes {
  18 |               ...MenuFields
  19 |             }
  20 |           }
  21 |         }
  22 |       }
  23 |     }
(node:10161) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
(node:10161) DeprecationWarning: Resolver#doResolve: The type arguments (string) is now a hook argument (Hook). Pass a reference to the hook instead.
 ERROR  Failed to compile with 1 errors                                                                                          09:21:02

 error  in ../packages/gatsby-theme-tabor/src/components/Menu.js

Module Error (from ../node_modules/eslint-loader/index.js):

/Users/werbeagenten/Code/tabor-gatsby-theme/packages/gatsby-theme-tabor/src/components/Menu.js
  19:36  error  Expected type WPGraphQL_MenuLocationEnum, found PRIMARY  graphql/template-strings

✖ 1 problem (1 error, 0 warnings)

 @ ../packages/gatsby-theme-tabor/src/components/Header.js 11:0-26 56:29-33
 @ ../packages/gatsby-theme-tabor/src/components/Layout.js
 @ ../packages/gatsby-theme-tabor/src/templates/posts/archive.js
 @ ./.cache/sync-requires.js
 @ ./.cache/app.js
 @ multi event-source-polyfill ../node_modules/webpack-hot-middleware/client.js?path=/__webpack_hmr&reload=true&overlay=false ./.cache/app

✖ 「wdm」:
ERROR in ../packages/gatsby-theme-tabor/src/components/Menu.js
Module Error (from ../node_modules/eslint-loader/index.js):

/Users/werbeagenten/Code/tabor-gatsby-theme/packages/gatsby-theme-tabor/src/components/Menu.js
  19:36  error  Expected type WPGraphQL_MenuLocationEnum, found PRIMARY  graphql/template-strings

✖ 1 problem (1 error, 0 warnings)

 @ ../packages/gatsby-theme-tabor/src/components/Header.js 11:0-26 56:29-33
 @ ../packages/gatsby-theme-tabor/src/components/Layout.js
 @ ../packages/gatsby-theme-tabor/src/templates/posts/archive.js
 @ ./.cache/sync-requires.js
 @ ./.cache/app.js
 @ multi event-source-polyfill ../node_modules/webpack-hot-middleware/client.js?path=/__webpack_hmr&reload=true&overlay=false ./.cache/app
ℹ 「wdm」: Failed to compile.

Before switching from the wordPressUrl in gatsby-config.js to my own it worked well. Do I need any special configuration in WordPress?

I'm running WordPress 5.2 with WPGraphQL 0.3.01. I also tried the latest WPGraphQL Pre-release 0.3.3 from github.

shanebp commented 5 years ago

The solution is here: https://github.com/zgordon/tabor-gatsby-theme/issues/10

Try changing PRIMARY to MENU_1