When I run react-apollo with a mockNetworkInterface (last versions of react-apollo and apollo-test-utils, an error is constantly poping :
GraphQL error: Schema must be an instance of GraphQLSchema.
Also ensure that there are not multiple versions of GraphQL installed
in your node_modules directory.
@Ayc0 Are you using graphql-server-express? If yes then you need to upgrade it to 0.8.0. I don't think it is coming directly from react-apollo.
P.S -> Assuming you are running latest version of graphql
I am not connected to a server: I mock the data as the tuto says.
But I'm sure that It comes either from react-apollo or from apollo-test-utils: when I git clone, it works but with old packages and when I upgrade every packages, it crashes on both of them (this error with react-apollo)
Can you post a reproduction with some code? We can't tell where that is coming without being able to see what you are doing.
@Ayc0 what's the output of npm list | grep graphql?
https://github.com/Ayc0/apollo
In the folder client, there is a version of the code which is working with old packages.
In the folder client2, there is exactly the same code but with the newest packages.
Last updates of apollo fix my problem
Thanks apollo team <3
install the same version of graphql as the one in react-apollo devDependencies list, for example, for react-apollo 1.4.15, just yarn add [email protected].
this is just a version compatibility error between react-apollo ang graphql.
@stubailo Here's a reproduction: https://github.com/fxlemire/graphql-react-tutorial/tree/part-1 (notice the branch part-1)
It's basically the entire part 1 of this tutorial
I've also tried with graphql@^0.10.5, to no avail.
Any help on how to fix this would be much appreciated!
EDIT: Now working thanks to @linhdsv yarn add [email protected] ๐
This tutorial doesn't work anymore but it helps me understand how Apollo sets up a Higher Order Component.
I tried yarn add [email protected] and restarted the app, everything worked well to me.
Thanks @linhdsv ! Indeed the ^ in yarn add graphql@^0.10.5 was the culprit.
Thanks @linhdsv . Try npm list | grep graphql to see all versions of graphql on your location. See https://github.com/apollographql/apollo-test-utils/issues/35
$ npm list | grep graphql
[email protected] /Users/xxx/workspace/GitHub/graphql-tutorial/client
โ โโโ [email protected]
โ โโโ [email protected]
โ โโโฌ [email protected]
โ โโโ @types/[email protected]
โโโฌ [email protected]
โโโฌ [email protected]
โ โ โโโ @types/[email protected]
โ โ โ โโโ [email protected]
โ โ โโโ [email protected]
โ โ โโโ [email protected]
There are two version of graphql: 0.11.7 & 0.10.5.
So I try to update my npm by sudo npm install -g npm. ( My previous npm version is 3.x)
And reinstall graphql by npm install [email protected].
It works for me.
For those arriving after the battle, I solved things by adding this into my packages.json:
"resolutions": {
"graphql": "^0.11.0"
},
This will instruct Yarn not to nest graphqland keep only one version (like the flat mode).
I have tried all above but still encountering below error
Error: Schema must be an instance of GraphQLSchema. Also ensure that there are not multiple versions of GraphQL installed in your node_modules directory.
at t.default (/Project/react-coolcat/dist/bundle.server.js:1:13926)
at Object.t.validate (/Project/react-coolcat/dist/bundle.server.js:1:270198)
at /Project/react-coolcat/dist/bundle.server.js:1:268684
at /Project/react-coolcat/dist/bundle.server.js:1:269337
at process._tickCallback (internal/process/next_tick.js:109:7)
I checked graphql packages
```
npm list | grep graphql
โ โโโ [email protected]
โ โ โโโฌ [email protected]
โ โโโ [email protected]
โ โโโฌ [email protected]
โ โโโ @types/[email protected]
โโโฌ [email protected]
โโโ [email protected]
โโโฌ [email protected]
npm ERR! peer dep missing: apollo-client@^1.0.0, required by [email protected]
Packages installed
"dependencies": {
"apollo-cache-inmemory": "^1.1.2",
"apollo-client": "^2.1.0",
"apollo-link-error": "^1.0.2",
"apollo-link-http": "^1.3.0",
"apollo-server-express": "^1.2.0",
"apollo-test-utils": "^0.3.2",
"babel-polyfill": "^6.26.0",
"babel-runtime": "^6.26.0",
"body-parser": "^1.18.2",
"express": "^4.16.2",
"graphql": "^0.11.7",
"graphql-tag": "^2.5.0",
"graphql-tools": "^2.11.0",
"react": "^16.1.1",
"react-dom": "^16.1.1",
...
},
```
@pricetula You have two versions of GraphQL include 0.10.5 & 0.11.7. You should npm install [email protected] --save to solve this issue.
Hi @zhoukekestar thanks i got it resolved nothing to do with multiple graphql copies. I also did install [email protected] but kept on getting Error: Schema must be an instance of GraphQLSchema. Also ensure that there are not multiple versions of GraphQL installed in your node_modules directory. error.
Turns out I was using typeDefs incorrectly without making it executable using makeExecutableSchema({ typeDefs }) on graphqlExpress()
Can also happen trying to import a makeExecutableSchema(...) exported in a different package.
Most helpful comment
@stubailo Here's a reproduction: https://github.com/fxlemire/graphql-react-tutorial/tree/part-1 (notice the branch
part-1)It's basically the entire part 1 of this tutorial
I've also tried with graphql@^0.10.5, to no avail.
Any help on how to fix this would be much appreciated!
EDIT: Now working thanks to @linhdsv
yarn add [email protected]๐