gatsbyjs / gatsby

The best React-based framework with performance, scalability and security built in.
https://www.gatsbyjs.com
MIT License
55.28k stars 10.31k forks source link

GraphQLError: Cannot query field "allWordpressPost" on type "Query #9144

Closed iaindurie closed 4 years ago

iaindurie commented 6 years ago

Description

I have a Wordpress ACF post object which allows me to link to posts from other posts. If I link to the same post more than once (i.e if I link to "Post 1" from "Post 2" as well as "Post 3", using the same acf field), I get the following error when running gatsby:

'GraphQLError: Cannot query field "allWordpressPost" on type "Query". Did you mean "allWordpressTag", "allWordpressWpUsers", "allWordpressWpMedia", "allWordpressWpTypes", or " allWordpressAcfUsers"?

Steps to reproduce

I select a post using ACF post object. Site builds fine. If I then select the same post using the same ACF field on a different page/post, I get the error. If I then remove the post object from other pages and only have it on one page again, site builds fine.

Expected result

I should be able to link to the same post object on multiple pages/posts.

Actual result

success open and validate gatsby-config — 0.012 s
success load plugins — 0.371 s
success onPreInit — 1.752 s
success delete html and css files from previous builds — 0.086 s
success initialize cache — 0.010 s
success copy gatsby files — 0.183 s
success onPreBootstrap — 0.017 s
⠈ source and transform nodes -> wordpress__yoast_v1 fetched : 1
⡀ source and transform nodesPath: /wp-json/yoast/v1/configurator?per_page=100&page=1
The server response was "401 Unauthorized"
Inner exception message: "Sorry, you are not allowed to do that."
⠄ source and transform nodesPath: /wp-json/yoast/v1/reindex_posts?per_page=100&page=1
The server response was "401 Unauthorized"
Inner exception message: "Sorry, you are not allowed to do that."
⠈ source and transform nodesPath: /wp-json/yoast/v1/ryte?per_page=100&page=1
The server response was "401 Unauthorized"
Inner exception message: "Sorry, you are not allowed to do that."
⢀ source and transform nodesPath: /wp-json/yoast/v1/statistics?per_page=100&page=1
The server response was "401 Unauthorized"
Inner exception message: "Sorry, you are not allowed to do that."
⠐ source and transform nodesPath: /wp-json/acf/v3/posts?per_page=100&page=1
The server response was "500 Internal Server Error"
⢀ source and transform nodesPath: /wp-json/acf/v3/pages?per_page=100&page=1
The server response was "500 Internal Server Error"
⠄ source and transform nodes -> wordpress__acf_media fetched : 55
⠂ source and transform nodes -> wordpress__acf_categories fetched : 5
⠈ source and transform nodes -> wordpress__acf_tags fetched : 0
⢀ source and transform nodes -> wordpress__acf_comments fetched : 0
⠂ source and transform nodes -> wordpress__acf_users fetched : 1
⠁ source and transform nodes -> wordpress__wp_api_menus_menus_items fetched : 1
⠠ source and transform nodes -> wordpress__wp_api_menus_menus_items fetched : 1
⠄ source and transform nodes -> wordpress__wp_api_menus_menus_items fetched : 1
 -> wordpress__wp_api_menus_menus fetched : 3
⠈ source and transform nodes -> wordpress__wp_api_menus_menu_locations fetched : 0
⠁ source and transform nodesPath: /wp-json/wp/v2/posts?per_page=100&page=1
The server response was "500 Internal Server Error"
⠁ source and transform nodesPath: /wp-json/wp/v2/pages?per_page=100&page=1
The server response was "500 Internal Server Error"
⠂ source and transform nodes -> wordpress__wp_media fetched : 55
⠠ source and transform nodes -> wordpress__wp_types fetched : 1
⠂ source and transform nodes -> wordpress__wp_statuses fetched : 1
⠠ source and transform nodes -> wordpress__wp_taxonomies fetched : 1
⡀ source and transform nodes -> wordpress__CATEGORY fetched : 7
⠈ source and transform nodes -> wordpress__TAG fetched : 7
⠠ source and transform nodes -> wordpress__wp_users fetched : 1
⠄ source and transform nodesPath: /wp-json/wp/v2/users/me?per_page=100&page=1
The server response was "401 Unauthorized"
Inner exception message: "You are not currently logged in."
⠁ source and transform nodes -> wordpress__wp_comments fetched : 0
⢀ source and transform nodesPath: /wp-json/wp/v2/settings?per_page=100&page=1
The server response was "401 Unauthorized"
Inner exception message: "Sorry, you are not allowed to do that."
⠂ source and transform nodes -> wordpress__acf_options fetched : 1
success source and transform nodes — 186.262 s
success building schema — 0.826 s
⠁ [ { GraphQLError: Cannot query field "allWordpressPost" on type "Query". Did you mean "allWordpressTag", "allWordpressWpUsers", "allWordpressWpMedia", "allWordpressWpTypes", or "allWordpressAcfUsers"?
      at Object.Field (C:\Projects\BI-website\node_modules\graphql\validation\rules\FieldsOnCorrectType.js:65:31)
      at Object.enter (C:\Projects\BI-website\node_modules\graphql\language\visitor.js:324:29)
      at Object.enter (C:\Projects\BI-website\node_modules\graphql\language\visitor.js:366:25)
      at visit (C:\Projects\BI-website\node_modules\graphql\language\visitor.js:254:26)
      at visitUsingRules (C:\Projects\BI-website\node_modules\graphql\validation\validate.js:74:22)
      at validate (C:\Projects\BI-website\node_modules\graphql\validation\validate.js:59:10)
      at graphqlImpl (C:\Projects\BI-website\node_modules\graphql\graphql.js:106:50)
      at C:\Projects\BI-website\node_modules\graphql\graphql.js:66:223
      at Promise._execute (C:\Users\iain.durie\AppData\Roaming\npm\node_modules\gatsby-cli\node_modules\bluebird\js\release\debuggability.js:313:9)
      at Promise._resolveFromExecutor (C:\Users\iain.durie\AppData\Roaming\npm\node_modules\gatsby-cli\node_modules\bluebird\js\release\promise.js:483:18)
      at new Promise (C:\Users\iain.durie\AppData\Roaming\npm\node_modules\gatsby-cli\node_modules\bluebird\js\release\promise.js:79:10)
      at graphql (C:\Projects\BI-website\node_modules\graphql\graphql.js:63:10)
      at graphqlRunner (C:\Projects\BI-website\node_modules\gatsby\dist\bootstrap\index.js:300:14)
      at Promise (C:\Projects\BI-website\gatsby-node.js:43:7)
      at Promise._execute (C:\Projects\BI-website\node_modules\bluebird\js\release\debuggability.js:313:9)
      at Promise._resolveFromExecutor (C:\Projects\BI-website\node_modules\bluebird\js\release\promise.js:483:18)
      at new Promise (C:\Projects\BI-website\node_modules\bluebird\js\release\promise.js:79:10)
      at Object.exports.createPages (C:\Projects\BI-website\gatsby-node.js:36:12)
      at runAPI (C:\Projects\BI-website\node_modules\gatsby\dist\utils\api-runner-node.js:137:37)
      at Promise.mapSeries.plugin (C:\Projects\BI-website\node_modules\gatsby\dist\utils\api-runner-node.js:247:32)
      at tryCatcher (C:\Projects\BI-website\node_modules\bluebird\js\release\util.js:16:23)
      at Object.gotValue (C:\Projects\BI-website\node_modules\bluebird\js\release\reduce.js:155:18)
    message: 'Cannot query field "allWordpressPost" on type "Query". Did you mean "allWordpressTag", "allWordpressWpUsers", "allWordpressWpMedia", "allWordpressWpTypes", or "allWordpressAcfUsers"?',
    locations: [ [Object] ],
    path: undefined } ]
error gatsby-node.js returned an error

  GraphQLError: Cannot query field "allWordpressPost" on type "Query". Did you mean "allWordpressTag", "allWordpressWpUsers", "allWordpressWpMedia", "allWordpressWpTypes", or "  allWordpressAcfUsers"?

  - debuggability.js:313 Promise._execute
    [npm]/[gatsby-cli]/[bluebird]/js/release/debuggability.js:313:9

  - promise.js:483 Promise._resolveFromExecutor
    [npm]/[gatsby-cli]/[bluebird]/js/release/promise.js:483:18

  - promise.js:79 new Promise
    [npm]/[gatsby-cli]/[bluebird]/js/release/promise.js:79:10

  - index.js:300 graphqlRunner
    [BI-website]/[gatsby]/dist/bootstrap/index.js:300:14

  - gatsby-node.js:43 Promise
    C:/Projects/BI-website/gatsby-node.js:43:7

  - debuggability.js:313 Promise._execute
    [BI-website]/[bluebird]/js/release/debuggability.js:313:9

  - promise.js:483 Promise._resolveFromExecutor
    [BI-website]/[bluebird]/js/release/promise.js:483:18

  - promise.js:79 new Promise
    [BI-website]/[bluebird]/js/release/promise.js:79:10

  - gatsby-node.js:36 Object.exports.createPages
    C:/Projects/BI-website/gatsby-node.js:36:12

  - api-runner-node.js:137 runAPI
    [BI-website]/[gatsby]/dist/utils/api-runner-node.js:137:37

  - api-runner-node.js:247 Promise.mapSeries.plugin
    [BI-website]/[gatsby]/dist/utils/api-runner-node.js:247:32

  - util.js:16 tryCatcher
    [BI-website]/[bluebird]/js/release/util.js:16:23

  - reduce.js:155 Object.gotValue
    [BI-website]/[bluebird]/js/release/reduce.js:155:18

error Cannot read property 'allWordpressPost' of undefined

  TypeError: Cannot read property 'allWordpressPost' of undefined

  - gatsby-node.js:71 graphql.then.result
    C:/Projects/BI-website/gatsby-node.js:71:27

  - util.js:16 tryCatcher
    [npm]/[gatsby-cli]/[bluebird]/js/release/util.js:16:23

  - promise.js:512 Promise._settlePromiseFromHandler
    [npm]/[gatsby-cli]/[bluebird]/js/release/promise.js:512:31

  - promise.js:569 Promise._settlePromise
    [npm]/[gatsby-cli]/[bluebird]/js/release/promise.js:569:18

  - promise.js:606 Promise._settlePromiseCtx
    [npm]/[gatsby-cli]/[bluebird]/js/release/promise.js:606:10

  - async.js:142 _drainQueueStep
    [npm]/[gatsby-cli]/[bluebird]/js/release/async.js:142:12

  - async.js:131 _drainQueue
    [npm]/[gatsby-cli]/[bluebird]/js/release/async.js:131:9

  - async.js:147 Async._drainQueues
    [npm]/[gatsby-cli]/[bluebird]/js/release/async.js:147:5

  - async.js:17 Immediate.Async.drainQueues
    [npm]/[gatsby-cli]/[bluebird]/js/release/async.js:17:14

error UNHANDLED REJECTION

  TypeError: Cannot read property 'allWordpressPost' of undefined

  - gatsby-node.js:71 graphql.then.result
    C:/Projects/BI-website/gatsby-node.js:71:27

  - util.js:16 tryCatcher
    [npm]/[gatsby-cli]/[bluebird]/js/release/util.js:16:23

  - promise.js:512 Promise._settlePromiseFromHandler
    [npm]/[gatsby-cli]/[bluebird]/js/release/promise.js:512:31

  - promise.js:569 Promise._settlePromise
    [npm]/[gatsby-cli]/[bluebird]/js/release/promise.js:569:18

  - promise.js:606 Promise._settlePromiseCtx
    [npm]/[gatsby-cli]/[bluebird]/js/release/promise.js:606:10

  - async.js:142 _drainQueueStep
    [npm]/[gatsby-cli]/[bluebird]/js/release/async.js:142:12

  - async.js:131 _drainQueue
    [npm]/[gatsby-cli]/[bluebird]/js/release/async.js:131:9

  - async.js:147 Async._drainQueues
    [npm]/[gatsby-cli]/[bluebird]/js/release/async.js:147:5

  - async.js:17 Immediate.Async.drainQueues
    [npm]/[gatsby-cli]/[bluebird]/js/release/async.js:17:14

Environment

System: OS: Windows 10 CPU: x64 Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz Binaries: Yarn: 1.5.1 - C:\Program Files (x86)\Yarn\bin\yarn.CMD npm: 3.10.10 - C:\Program Files\nodejs\npm.CMD Browsers: Edge: 41.16299.726.0 npmPackages: gatsby: 2.0.14 => 2.0.14 gatsby-image: ^2.0.10 => 2.0.13 gatsby-link: ^2.0.2 => 2.0.4 gatsby-plugin-glamor: ^2.0.5 => 2.0.5 gatsby-plugin-layout: ^1.0.3 => 1.0.3 gatsby-plugin-react-helmet: ^3.0.0 => 3.0.0 gatsby-plugin-robots-txt: ^1.3.0 => 1.3.0 gatsby-plugin-sharp: ^2.0.5 => 2.0.6 gatsby-plugin-typography: ^2.2.0 => 2.2.0 gatsby-source-filesystem: ^2.0.1 => 2.0.3 gatsby-source-wordpress: ^3.0.1 => 3.0.4 gatsby-transformer-sharp: ^2.1.2 => 2.1.3

pieh commented 6 years ago
Path: /wp-json/wp/v2/posts?per_page=100&page=1
The server response was "500 Internal Server Error"

It seems like this is problem in wordpress ACF Rest API plugin and there's nothing that gatsby can do about it.

It just fails to provide response to REST request for posts data. This should be reported in https://github.com/airesvsg/acf-to-rest-api

katrpilar commented 6 years ago

@iaindurie I had this same issue and I this is how I fixed it.

I installed a clean version of Wordpress. Next, I installed the base Advanced Custom Fields Plugin and lastly I installed the ACF Rest API plugin. I had overlooked the part in the setup guide that this Gatsby Wordpress plugin requires both Wordpress plugins to be installed...

I had exact issue you've described and I believe it was because the the base ACF plugin (not the ACF Rest plugin) wasn't properly loading into my Wordpress installation. I discovered that no matter how many times I tried reinstalling the ACF plugin it refused to appear in the Wordpress admin dashboard... Make sure it appears properly for your installation.

Lastly, I had to go into the Wordpress settings (Dashboard > Settings > Permalinks) and change the permalink structure to Post name for the Gatsby Wordpress Plugin to work properly.

The setup guide states the below. However, this didn't work as described and I had to have the permalinks set to Post name. Once I changed this everything worked!

If you see a page on your site, rather than the JSON output, check if your permalink settings are set to “Plain”.

zilahir commented 5 years ago

Hey!

Was this resolved somehow?

I am not using ACF since I can't get the posts from wordpress.com hosted site.

I assume the auth is ok, i am not getting any error on console after gatsby develop.

(If i provide wrong password in gatsby.config.js on purpose, then auth error is present.

I dont'w want to achieve much, just get the posts in graphql, with the following query from the doc:

{
  allWordpressPost {
    edges {
      node {
        id
        slug
        title
        content
        excerpt
        date
        modified
      }
    }
  }
}

but instead of the result i am getting the following `error:

{
  "errors": [
    {
      "message": "Cannot query field \"allWordpressPost\" on type \"Query\". Did you mean \"allWordpressAcfOptions\" or \"allWordpressSiteMetadata\"?",
      "locations": [
        {
          "line": 2,
          "column": 1
        }
      ]
    }
  ]
}

On my wordpress.com site there are 2 posts, each of them has tags and category, but i cant fetch them.

Any idea what goes wrong here? I have checked everything i could find related this issue, but no solution whatsoever.

Thank you!

ghost commented 5 years ago

I have set acf usage to false as well but I am getting this error

Path: /wp-json/wp/v2/themes?per_page=100&page=1
The server response was "400 Bad Request"
Inner exception message: "Missing parameter(s): status"
brodneil commented 5 years ago

Is this resolved? My end, I am still getting the errors: "Cannot query field"

Is there another way to migrate from wordpress to gatsby without trying to do them manually?

gatsbot[bot] commented 5 years ago

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’s 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!

Thanks for being a part of the Gatsby community! 💪💜

kharrop commented 5 years ago

I'm also getting this issue. Using wp.com and no luck.

gatsbot[bot] commented 5 years ago

Hey again!

It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it.

Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY. Please feel free to reopen this issue or create a new one if you need anything else.

Thanks again for being part of the Gatsby community!

akshitkrnagpal commented 4 years ago

Getting same error.

akshitkrnagpal commented 4 years ago

In our case, problem was due to a optional field in ACF. We just changed it to required and it started working.

Hope this helps someone.

github-actions[bot] commented 4 years ago

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’s 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! 💪💜

github-actions[bot] commented 4 years ago

Hey again!

It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it. Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY. Please feel free to reopen this issue or create a new one if you need anything else. 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 again for being part of the Gatsby community! 💪💜