apollographql / react-apollo

:recycle: React integration for Apollo Client
https://www.apollographql.com/docs/react/
MIT License
6.85k stars 786 forks source link

[GraphQL error]: Message: Cannot query field "xxx" on type "Query"., Location: [object Object], Path: undefined #3947

Open jack0wsky opened 4 years ago

jack0wsky commented 4 years ago

Intended outcome: Get all data from GraphCMS

Actual outcome: I'm building app in Gatsby with Apollo. GraphQL throws error which I specified in title. In localhost:8000/__graphql this "xxx" query is visible and working but in useQuery and Query from Apollo, data displays as undefined

import ApolloClient from "apollo-boost"
//import fetch from "isomorphic-fetch"

export const client = new ApolloClient({
  uri: "graphcms-api",
})

Here is my config

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`,
  },
  plugins: [
    `gatsby-plugin-react-helmet`,
    "gatsby-theme-apollo",
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name: `images`,
        path: `${__dirname}/src/images`,
      },
    },
    `gatsby-transformer-sharp`,
    `gatsby-plugin-sharp`,
    {
      resolve: `gatsby-plugin-manifest`,
      options: {
        name: `gatsby-starter-default`,
        short_name: `starter`,
        start_url: `/`,
        background_color: `#663399`,
        theme_color: `#663399`,
        display: `minimal-ui`,
        icon: `src/images/gatsby-icon.png`, // This path is relative to the root of the site.
      },
    },
    {
      resolve: `gatsby-plugin-styled-components`,
      options: {
        // Add any options here
      },
    },
    {
      resolve: "gatsby-source-graphql",
      options: {
        // Arbitrary name for the remote schema Query type
        typeName: "VENDOR",
        // Field under which the remote schema will be accessible. You'll use this in your Gatsby query
        fieldName: "vendor",
        // Url to query from
        url:
          "https://api-eu-central-1.graphcms.com/v2/ck9bubr8609f101yy3yt05dsw/master",
      },
    },
  ],
}

How to reproduce the issue:

Version

jack0wsky commented 4 years ago

System: OS: macOS 10.15.4 Binaries: Node: 12.14.0 - /usr/local/bin/node Yarn: 1.22.4 - /usr/local/bin/yarn npm: 6.14.4 - /usr/local/bin/npm Browsers: Chrome: 81.0.4044.122 Firefox: 75.0 Safari: 13.1 npmPackages: @apollo/client: ^3.0.0-beta.44 => 3.0.0-beta.44 @apollo/react-hooks: ^3.1.5 => 3.1.5 apollo-boost: ^0.4.7 => 0.4.7 gatsby-theme-apollo: ^3.0.2 => 3.0.2 react-apollo: ^3.1.5 => 3.1.5