Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query.node defined in resolvers, but not in schema #25405

Closed
GreenOn opened this issue Jun 30, 2020 · 4 comments
Closed

Query.node defined in resolvers, but not in schema #25405

GreenOn opened this issue Jun 30, 2020 · 4 comments
Assignees
Labels
topic: GraphQL Related to Gatsby's GraphQL layer type: bug An issue or pull request relating to a bug in Gatsby

Comments

@GreenOn
Copy link

GreenOn commented Jun 30, 2020

Description

We are trying to make use of an existing Apollo Graphql Server for a new Gatsby site. I am not sure why but we are getting this error on gatsby develop.

Error: Query.node defined in resolvers, but not in schema.

Our Apollo server has been working with no issues and the above error we are getting from Gatsby doesn't seem to be legitimate.

Our schema does have the node definition as shown below:

interface Node {
  id: ID!
}
type Query{
  .....
  ...
  node(id: ID!): Node
}

I enabled the playground for the graphql server also if you need any additional info.

Steps to reproduce

Here is a simple repo you can use to reproduce the problem: https://github.com/GreenOn/gatsby-apollo-dynos.

I followed the example posted here and updated the config file with our graphql server name: https://github.com/jlengstorf/gatsby-with-apollo

Expected result

The expected result is to run the project successfully getting all the queries working at the build time.

Actual result

On executing gatsby develop, it fails immediately after loading gatsby-config.js.

Environment

System:
OS: Windows 10 10.0.18362
CPU: (4) x64 Intel(R) Core(TM) i7-6500U CPU @ 2.50GHz
Binaries:
Node: 12.16.1 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.4 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.14.0 - C:\Program Files\nodejs\npm.CMD
Languages:
Python: 2.7.16 - /c/Users/pramo/.windows-build-tools/python27/python
Browsers:
Edge: 44.18362.449.0
npmPackages:
gatsby: ^2.0.19 => 2.23.11
gatsby-source-graphql: ^2.0.6 => 2.5.7
npmGlobalPackages:
gatsby-cli: 2.12.50

@GreenOn GreenOn added the type: bug An issue or pull request relating to a bug in Gatsby label Jun 30, 2020
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jun 30, 2020
@pvdz pvdz added topic: GraphQL Related to Gatsby's GraphQL layer and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Jun 30, 2020
@vladar vladar self-assigned this Jun 30, 2020
@vladar
Copy link
Contributor

vladar commented Jun 30, 2020

Quick googling shows that it is probably an apollo-server issue (at least there is a couple of similar reports in their repo):

apollographql/apollo-server#2656
apollographql/apollo-server#1534

Have you checked those?

@GreenOn
Copy link
Author

GreenOn commented Jun 30, 2020

Yes, but why only Gatsby graphql plugin complains about this? Our graphql server has been working fine for some time. If we have to make changes to get this running, we can, but I find it odd that only Gatsby has issues with this?

@vladar
Copy link
Contributor

vladar commented Jun 30, 2020

You are right, it happens when we try to transform the schema using graphql-tools. Somewhere in this call:

const schema = transformSchema(
{
schema: introspectionSchema,
link,
},

It throws even without custom Gatsby transforms. So probably a bug somewhere in graphql-tools.

One interesting thing though is that you have this Node interface in your schema but there is no single type implementing this interface. My best bet is that it confuses graphql-tools somehow.

Do you even use Query.node? Looks like it can't return anything, can it?

@GreenOn
Copy link
Author

GreenOn commented Jun 30, 2020

I actually had to convert the interface to type to get this working. Actually, this whole schema was auto-generated by Prisma (v1).
It has a whole bunch of things like interface, input, DateTime etc. I tried to upgrade graphql-tools to the latest v6, but it is throwing more errors now on the schema generated by Prisma. So for now, I took this route and got this working. Yes, there are so many moving parts here and everything needs to be in sync to get it working.

@GreenOn GreenOn closed this as completed Jun 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: GraphQL Related to Gatsby's GraphQL layer type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

No branches or pull requests

3 participants