Schema must be an instance of GraphQLSchema
See original GitHub issueHello, I get this error when hitting /graphql with browser:
{
"errors": [
{
"message": "Schema must be an instance of GraphQLSchema. Also ensure that there are not multiple versions of GraphQL installed in your node_modules directory."
}
]
}
any suggestion? My schema is an instance of GraphQLSchema…and graphql appears only once in package.json
thanks
Issue Analytics
- State:
- Created 8 years ago
- Comments:29 (7 by maintainers)
Top Results From Across the Web
Schema must be an instance of GraphQLSchema. Ensure that ...
js. fields is a function property. This works. let schema = new GraphQLSchema({ query: new GraphQLObjectType({ name: 'RootQueryType', ...
Read more >GraphQL schema basics - Apollo GraphQL Docs
Your GraphQL server uses a schema to describe the shape of your available data. This schema defines a hierarchy of types with fields...
Read more >Building your first GraphQL Server | by christoffer noring
To create a schema you need to create an instance of the type GraphQLSchema . There are different ways of creating this instance...
Read more >Constructing Types - GraphQL
When you are using the GraphQLSchema constructor to create a schema, instead of defining Query and Mutation types solely using schema language, you...
Read more >Frequently Asked Questions - TypeGraphQL
and must perform side effects e.g. a database call - use a resolver class method ... In this case, what should be returned...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@LoicMahieu: Unless you’re running a modified version of graphql-js, this shouldn’t be a problem if you
npm dedupe
. The limitation has to do with flow type checking.Just want to mention that when importing a schema from another package, and using
yarn link
in development, I run into the same problems that @LoicMahieu describes withlerna
.Edit: I found a solution, which I wanted to share in case anyone else runs into this issue: do more linking so that each of your packages is linked to the same copy of graphql. (This also works for other dependencies that are sensitive to multiple copies, such as react.)
In this scenario,
schema-package
exports a graphql schema, andserver-package
imports that schema, perhaps to serve it over HTTP:$ yarn global add graphql
$ cd ~/.config/yarn/global/node_modules/graphql && yarn link
$ cd path/to/schema-package && yarn link graphql && yarn link
$ cd path/to/server-package && yarn link graphql && yarn link schema-package
After these steps,
server-package
is linked to your development copy ofschema-package
, and both are linked to the same copy ofgraphql
. This should causeinstanceof
checks in graphql code to work properly.@leebyron You said that the error has to do with flow type-checking; but I think that is not correct. The error comes from three runtime checks that look like this:
Some options for avoiding errors like this when usinglerna
,yarn link
, ornpm link
could be to change the check from aninstanceof
check to a check for expected properties, or to disable invariant checks if an environment variable or configuration option is set.