graphiql: Schema must be an instance of GraphQLSchema
Hello, 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
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 29 (7 by maintainers)
Commits related to this issue
- Use babel-plugin-react-relay but override the graphql dependency to workaround bug graphql/graphiql/issues/58 — committed to sedubois/belong by sedubois 8 years ago
- Use babel-plugin-react-relay but override the graphql dependency to workaround bug graphql/graphiql/issues/58 — committed to sedubois/belong by sedubois 8 years ago
- Use babel-plugin-react-relay but override the graphql dependency to workaround bug graphql/graphiql/issues/58 — committed to sedubois/belong by sedubois 8 years ago
- Fix duplicate `graphql` package bug by checking for local installation See https://github.com/graphql/graphiql/issues/58 for more info — committed to mfix22/gest by mfix22 7 years ago
- Merge pull request #58 from graphql/greenkeeper/babel-plugin-transform-class-properties-6.19.0 Update babel-plugin-transform-class-properties to the latest version 🚀 — committed to acao/graphiql by wincent 8 years ago
- Merge pull request #58 from wincent/glh/fix-lint-2 Fix a lint — committed to acao/graphiql by wincent 7 years ago
- feat(CodeLens): and configuration fixes (#58) * bump: version for 0.0.10 * feat: codelens without query * feat: inline playground and codelens * feat: codelens, extract graphql response from... — committed to graphql/graphiql by deleted user 6 years ago
@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 linkin 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-packageexports a graphql schema, andserver-packageimports 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-packageAfter these steps,
server-packageis linked to your development copy ofschema-package, and both are linked to the same copy ofgraphql. This should causeinstanceofchecks 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 linkcould be to change the check from aninstanceofcheck to a check for expected properties, or to disable invariant checks if an environment variable or configuration option is set.In my case, the issue was not having twice
graphqlbut twice@types/graphql. Downgrading myapollo-clientversion from^1.9.1to1.9.0solved it :I found that by inspecting
yarn.lockfile, and identifying which dependency was requiring a different version of@types/graphql.In case this helps anyone else, I’ve came across this when mixing ES6 and CommonJS modules. Choosing one or the other sorted it.
I think this is the solution (if you’re using webpack):
http://stackoverflow.com/questions/31169760/how-to-avoid-react-loading-twice-with-webpack-when-developing
Find the culprit: Seems like the documentation isn’t fully updated yet to reflect the recent changes in
v0.2. The solution is to follow the upgrade guide which contains more information then the server setup doc.Ok, it’s related to babel 6 (babel-core). If I use babel@5.8.34 then no problem. Maybe there is a babel 6 preset that could work, I just tried with
presets: ['es2015', 'stage-1', 'react']and withpresets: ['es2015'], both without success (https://github.com/graphql/graphql-js/issues/228)In case it helps anyone else, I got this error when
graphqlwas installed as adevDependencyinstead of a normaldependencywith the rest of my graphql-related packages.