Skip to content

Cannot query field "allWordpressPost" on type "Query". #39368

@SRD75

Description

@SRD75

Preliminary Checks

Description

New Gatsby/WordPress project.

src/pages/index.js:

import { graphql } from "gatsby"
import Layout from "../components/layout"
import SEO from "../components/seo"

export default ({ data }) => {
  return (
    <Layout>
      <SEO title="home" />
      <h4>Posts</h4>
      {data?.allWordpressPost.edges.map(({ node }) => (
        <div>
          <p>{node.title}</p>
          <div dangerouslySetInnerHTML={{ __html: node.excerpt }} />
        </div>
      ))}
    </Layout>
  )
}
export const pageQuery = graphql`
  query {
    allWordpressPost(sort: { fields: [date] }) {
      edges {
        node {
          title
          excerpt
        }
      }
    }
  }

After running gatsby develop, I receive an error:

Unhandled GraphQL Error
One unhandled GraphQL error found in your files. See the list below to fix it:
Cannot query field "allWordpressPost" on type "Query".


`/**
 * Configure your Gatsby site with this file.
 *
 * See: https://www.gatsbyjs.com/docs/reference/config-files/gatsby-config/
 */

/**
 * @type {import('gatsby').GatsbyConfig}
 */
module.exports = {
  siteMetadata: {
    title: `Gatsby Default Starter`,
    description: `Kick off your next, great Gatsby project with this default starter. This barebones starter ships with the main Gatsby configuration files you might need.`,
    author: `@gatsbyjs`,
    siteUrl: `https://gatsbystarterdefaultsource.gatsbyjs.io/`,
  },
  plugins: [
    {
      resolve: `gatsby-source-wordpress`,
      options: {
        url:
          process.env.WPGRAPHQL_URL ||
          `http://gutenberg-gatsby.local/graphql`,
          schema: {
            //Prefixes all WP Types with "Wp" so "Post and allPost" become "WpPost and allWpPost".
            typePrefix: `Wp`,
          },
          develop: {
            //caches media files outside of Gatsby's default cache an thus allows them to persist through a cache reset.
            hardCacheMediaFiles: true,
          },
          type: {
            Post: {
              limit:
                process.env.NODE_ENV === `development`
                  ? // Lets just pull 50 posts in development to make it easy on ourselves (aka. faster).
                    50
                  : // and we don't actually need more than 5000 in production for this particular site
                    5000,
            },
        },
      }
    }
  ]
}```

Help appreciated.

### Reproduction Link

https://github.com/SRD75/gatsby-wordpress2

### Steps to Reproduce

1.`npm develop`


### Expected Result

The `http://localhost:8000/` should display posts.

### Actual Result

I receive:

`Unhandled GraphQL Error
Close
One unhandled GraphQL error found in your files. See the list below to fix it:


Cannot query field "allWordpressPost" on type "Query".
ERROR #85923
Open in Editor
/Users/stevendoig/Documents/Projects/gatsby-wordpress/src/pages/index.js:22:5
There was an error in your GraphQL query:

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

If you don't expect "allWordpressPost" to exist on the type "Query" it is most likely a typo. However, if you expect "allWordpressPost" to exist there are a couple of solutions to common problems:

- If you added a new data source and/or changed something inside gatsby-node/gatsby-config, please try a restart of your development server.
- You want to optionally use your field "allWordpressPost" and right now it is not used anywhere.

It is recommended to explicitly type your GraphQL schema if you want to use optional fields.
See our docs page for more info on this error: https://gatsby.dev/creating-type-definitions`

### Environment

```shell
System:
    OS: macOS 26.0.1
    CPU: (10) arm64 Apple M4
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.9.0 - /opt/homebrew/bin/node
    npm: 11.6.0 - /opt/homebrew/bin/npm
  Browsers:
    Chrome: 141.0.7390.55
    Safari: 26.0.1
  npmPackages:
    gatsby: ^5.14.6 => 5.15.0 
    gatsby-plugin-image: ^3.14.0 => 3.15.0 
    gatsby-plugin-manifest: ^5.14.0 => 5.15.0 
    gatsby-plugin-sharp: ^5.14.0 => 5.15.0 
    gatsby-source-filesystem: ^5.14.0 => 5.15.0 
    gatsby-source-wordpress: ^7.16.0 => 7.16.0 
    gatsby-transformer-sharp: ^5.14.0 => 5.15.0 
  npmGlobalPackages:
    gatsby-core-utils: 4.15.0

Config Flags

/**

/**

  • @type {import('gatsby').GatsbyConfig}
    */
    module.exports = {
    siteMetadata: {
    title: Gatsby Default Starter,
    description: Kick off your next, great Gatsby project with this default starter. This barebones starter ships with the main Gatsby configuration files you might need.,
    author: @gatsbyjs,
    siteUrl: https://gatsbystarterdefaultsource.gatsbyjs.io/,
    },
    plugins: [
    {
    resolve: gatsby-source-wordpress,
    options: {
    url:
    process.env.WPGRAPHQL_URL ||
    http://gutenberg-gatsby.local/graphql,
    schema: {
    //Prefixes all WP Types with "Wp" so "Post and allPost" become "WpPost and allWpPost".
    typePrefix: Wp,
    },
    develop: {
    //caches media files outside of Gatsby's default cache an thus allows them to persist through a cache reset.
    hardCacheMediaFiles: true,
    },
    type: {
    Post: {
    limit:
    process.env.NODE_ENV === development
    ? // Lets just pull 50 posts in development to make it easy on ourselves (aka. faster).
    50
    : // and we don't actually need more than 5000 in production for this particular site
    5000,
    },
    },
    }
    }
    ]
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: triage neededIssue or pull request that need to be triaged and assigned to a reviewertype: bugAn issue or pull request relating to a bug in Gatsby

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions