Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

GraphQL error: Schema must be an instance of GraphQLSchema #742

Closed
Ayc0 opened this issue Jun 1, 2017 · 18 comments
Closed

GraphQL error: Schema must be an instance of GraphQLSchema #742

Ayc0 opened this issue Jun 1, 2017 · 18 comments

Comments

@Ayc0
Copy link

Ayc0 commented Jun 1, 2017

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.
@mairh
Copy link

mairh commented Jun 1, 2017

@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

@Ayc0
Copy link
Author

Ayc0 commented Jun 1, 2017

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)

@stubailo
Copy link
Contributor

stubailo commented Jun 1, 2017

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.

@helfer
Copy link
Contributor

helfer commented Jun 2, 2017

@Ayc0 what's the output of npm list | grep graphql?

@Ayc0
Copy link
Author

Ayc0 commented Jun 2, 2017

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.

@Ayc0
Copy link
Author

Ayc0 commented Jun 7, 2017

Last updates of apollo fix my problem
Thanks apollo team <3

@Ayc0 Ayc0 closed this as completed Jun 7, 2017
@erlangxk
Copy link

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 graphql@0.10.5.

@therealedsheenan
Copy link

this is just a version compatibility error between react-apollo ang graphql.

@fxlemire
Copy link

fxlemire commented Sep 8, 2017

@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 graphql@0.10.5 👍

@siltwood
Copy link

This tutorial doesn't work anymore but it helps me understand how Apollo sets up a Higher Order Component.

@linhdsv
Copy link

linhdsv commented Sep 19, 2017

I tried yarn add graphql@0.10.5 and restarted the app, everything worked well to me.

@fxlemire
Copy link

fxlemire commented Sep 19, 2017

Thanks @linhdsv ! Indeed the ^ in yarn add graphql@^0.10.5 was the culprit.

@zhoukekestar
Copy link

zhoukekestar commented Oct 21, 2017

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
client@0.1.0 /Users/xxx/workspace/GitHub/graphql-tutorial/client
│ ├── graphql@0.10.5
│ ├── graphql-tag@2.5.0
│ └─┬ graphql-tools@1.2.3
│   └── @types/graphql@0.9.4
├─┬ graphql@0.11.7
├─┬ graphql-tools@2.5.1
│ │ ├── @types/graphql@0.10.2
│ │ │ ├── graphql@0.10.5
│ │ ├── graphql@0.10.5
│ │ ├── graphql-anywhere@3.1.0

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 graphql@0.10.5.

It works for me.

@maximeg
Copy link

maximeg commented Nov 12, 2017

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).

@pricetula
Copy link

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     
│ └── graphql-anywhere@4.0.2
│ │ └─┬ graphql-extensions@0.0.5
│ ├── graphql@0.10.5
│ └─┬ graphql-tools@1.2.3
│   └── @types/graphql@0.9.4
├─┬ graphql@0.11.7
├── graphql-tag@2.5.0
├─┬ graphql-tools@2.11.0
npm ERR! peer dep missing: apollo-client@^1.0.0, required by apollo-test-utils@0.3.2

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",
    ...
  },

@zhoukekestar
Copy link

@pricetula You have two versions of GraphQL include 0.10.5 & 0.11.7. You should npm install graphql@0.10.5 --save to solve this issue.

@pricetula
Copy link

pricetula commented Dec 5, 2017

Hi @zhoukekestar thanks i got it resolved nothing to do with multiple graphql copies. I also did install graphql@0.10.5 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()

@jiku
Copy link

jiku commented Feb 6, 2019

Can also happen trying to import a makeExecutableSchema(...) exported in a different package.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests