Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

377
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda