Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

376
Vistas
Gatsby and WPGraphQL - Build Error "Cannot query field "pages" on type "Query""

I'm completely new to WPGraphQL and I'm having some bother with building a Gatsby site from my new Wordpress endpoint. When I execute the following query to my endpoint in Postman, I get the page data back successfully:

 query MyQuery {
     pages {
        edges {
            node {
                id
                slug
                status
            }
        }
     }
  }

However when I attempt to build the Gatsby site, I get the following:

ERROR #85923 GRAPHQL

There was an error in your GraphQL query:

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

The relevant code in gatsby-node.js is:

const _ = require('lodash')
const path = require('path')
const { createFilePath } = require('gatsby-source-filesystem')
const { paginate } = require('gatsby-awesome-pagination')

const getOnlyPublished = edges =>
  _.filter(edges, ({ node }) => node.status === 'publish')

exports.createPages = ({ actions, graphql }) => {
  const { createPage } = actions

  return graphql(`
    {
      pages {
        edges {
          node {
            id
            slug
            status
          }
        }
      }
    }
  `)
    .then(result => {
      if (result.errors) {
        result.errors.forEach(e => console.error(e.toString()))
        return Promise.reject(result.errors)
      }

Gatsby config:

module.exports = {
  siteMetadata: {
    siteUrl: "https://www.yourdomain.tld",
    title: "graphql-test",
  },
  plugins: [
    {
      resolve: "gatsby-source-wordpress",
      options: {
        url: "https://*********/graphql",
      },
    },
    "gatsby-plugin-sass",
    "gatsby-plugin-react-helmet",
    "gatsby-plugin-sitemap",
  ],
};

This is a brand new test Gatsby site created with gatsby new, all plugins are the latest version.

Any help with this greatly appreciated!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

It turns out that Gatsby uses a slightly different format for its graphql queries. What I should have had in gatsby-node.js was this:

  return graphql(`
    {
      allWpPage {
          nodes {
            id
            slug
            status
        }
      }
    }
  `)
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda