Gatsby GraphQL Error: Cannot query field “dogs” on type “Query”

Gatsby GraphQL Error: Cannot query field “dogs” on type “Query”


0

I created a custom post type in WordPress and would like to build pages for it. When I try out the queries in the IDE they pull the custom post data ok. When I add it to the code, however, it throws the error Cannot query field "dogs" on type "Query" when I build the site.

Why does it work in the GraphiQL IDE but not in production?

The following query works in the IDE:

query GetDogs {
  dogs {
    nodes {
      content
      title
    }
  }
}

When I include it in the query to build post/pages, it fails. There is content for this post type. Restarting the server does not help. I have tried customPosts(filter: { customPostTypes: ["dog"] }) to no avail.

    query Query {
      allWpPage {
        edges {
          node {
            content
            excerpt
            date
            id
            parentDatabaseId
            isFrontPage
            isHome
            pageTemplate
            link
            slug
            status
            title
            uri
            nodeType
          }
        }
      }
      allWpPost(sort: { fields: date, order: DESC }) {
        edges {
          node {
            author {
              node {
                databaseId
              }
            }
            categories {
              nodes {
                name
                slug
                uri
              }
            }
            id
            nodeType
            date
            excerpt
            content
            slug
            title
            uri
            status
          }
        }
      }
      dogs{
        edges {
          node {
            author {
              node {
                databaseId
              }
            }
            id
            date
            excerpt
            content
            slug
            title
            uri
            status
          }
        }
      }
    }


Load 7 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *