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

[0.11.x] Error: Schema must be an instance of GraphQLSchema. Also ensure that there are not multiple versions of GraphQL installed in your node_modules directory. #1016

Closed
joncursi opened this issue Aug 29, 2017 · 10 comments

Comments

@joncursi
Copy link

I get this error when querying my GraphQL server after upgrading from 0.10.5 to 0.11.1:

Error: Schema must be an instance of GraphQLSchema. Also ensure that there are not multiple versions of GraphQL installed in your node_modules directory.
W20170828-20:16:35.253(-4)? (STDERR)     at invariant (/Users/joncursi/Sites/joncursi/redbird-web/node_modules/apollo-server-core/node_modules/graphql/jsutils/invariant.js:19:11)
W20170828-20:16:35.254(-4)? (STDERR)     at Object.validate (/Users/joncursi/Sites/joncursi/redbird-web/node_modules/apollo-server-core/node_modules/graphql/validation/validate.js:60:72)
W20170828-20:16:35.254(-4)? (STDERR)     at doRunQuery (/Users/joncursi/Sites/joncursi/redbird-web/node_modules/apollo-server-core/dist/runQuery.js:80:38)
W20170828-20:16:35.255(-4)? (STDERR)     at /Users/joncursi/Sites/joncursi/redbird-web/node_modules/apollo-server-core/dist/runQuery.js:20:54
W20170828-20:16:35.255(-4)? (STDERR)     at /Users/joncursi/.meteor/packages/promise/.0.10.0-beta.10.hrsya6.14jf9++os+web.browser+web.cordova/npm/node_modules/meteor-promise/fiber_pool.js:43:39

My setup works great on 0.10.5, and I don't see any related breaking changes in the 0.11.x release notes. Any ideas on where to start troubleshooting this?

@wincent
Copy link
Contributor

wincent commented Aug 29, 2017

Any ideas on where to start troubleshooting this?

The problem almost certainly lies in the place pointed at by the error message:

Also ensure that there are not multiple versions of GraphQL installed in your node_modules directory.

Try doing a find node_modules -name graphql and seeing if you have more than one copy in there.

@jonirrings
Copy link

jonirrings commented Aug 29, 2017

pls refer #956

it seems you got a dependency who had installed a graphql dependency under its own node_modules directory

@joncursi
Copy link
Author

Hi @wincent, when I run the command you suggested, I do see multiple instances of graphql in my node_modules:

$ find node_modules -name graphql
node_modules/@types/graphql
node_modules/apollo-client/node_modules/@types/graphql
node_modules/graphql

Do you have any suggestions on how to resolve this? I.e., should I open up a separate issue on apollo-client, or is there a way I can tell yarn to only package one instance? cc @stubailo

@jonirrings
Copy link

jonirrings commented Aug 29, 2017

@joncursi

yarn remove apollo-client graphql
yarn add graphql
yarn add apollo-client

the correct add sequence makes the work
but seems the problem is not about graphql itself, it is about the typescript @types file?

so in fact,you may need

yarn remove apollo-client @types/graphql
yarn add @types/graphql
yarn add apollo-client

have a try

@joncursi
Copy link
Author

I've tried to remove @types/graphql but I get this error:

$ yarn remove @types/graphql
yarn remove v0.27.5
[1/2] Removing module @types/graphql...
error This module isn't specified in a manifest.
info Visit https://yarnpkg.com/en/docs/cli/remove for documentation about this command.

I guess this is because I don't have @types/graphql directly in my package.json. I presume it is included in my node_modules via some other dependency. My relevant package.json is:

    "apollo-client": "^1.9.1",
    "apollo-upload-server": "^2.0.3",
    "body-parser": "^1.17.2",
    "express": "^4.15.4",
    "graphql": "0.10.5",
    "graphql-date": "^1.0.3",
    "graphql-loader": "^1.2.1",
    "graphql-log": "^0.1.3",
    "graphql-redis-subscriptions": "^1.2.0",
    "graphql-server-express": "1.1.2",
    "graphql-subscriptions": "^0.4.4",
    "graphql-tools": "^1.2.1",
    "graphql-type-json": "^0.1.4",
    "meteor-apollo-accounts": "^2.0.3",

@oliviertassinari
Copy link

oliviertassinari commented Aug 29, 2017

Here is the observed behavior by just upgrading this dependency:

with 0.10.5

07:04:25 (fixes-v3) ~/x/app$ find node_modules -name graphql
node_modules/@types/graphql
node_modules/graphql

with 0.11.0

07:04:55 (fixes-v3) ~/x/app$ find node_modules -name graphql
node_modules/@types/graphql
node_modules/apollo-client/node_modules/graphql
node_modules/apollo-link-core/node_modules/graphql
node_modules/express-graphql/node_modules/graphql
node_modules/graphql
node_modules/graphql-resolve-batch/node_modules/graphql
node_modules/graphql-tag/node_modules/graphql

@oliviertassinari
Copy link

Sounds like we end up in a situation close to was we had at the beginning of the React boom. I guess we should encourage the community to move graphql to a peer dependency.

@wincent
Copy link
Contributor

wincent commented Aug 29, 2017

One thing to note: we will be cutting a release today, and then updating the express-graphql package to depend on that.

@wincent
Copy link
Contributor

wincent commented Aug 29, 2017

Latest versions are now graphql v0.11.2 and express-graphql v0.6.11.

@akhilaudable
Copy link

akhilaudable commented Dec 9, 2017

Hi, I have the same error in graphiql

 "message": "Schema must be an instance of GraphQLSchema. Also ensure that there are not multiple versions of GraphQL installed in your node_modules directory."

I tried find node_modules -name graphql. But I have only one version of graphql.

schema.js

import {
GraphQLObjectType,
GraphQLSchema,
 GraphQLInt
} from 'graphql';
let count = 0;
let schema = new GraphQLSchema({
  query: new GraphQLObjectType({
    name: 'RootQueryType',
    fields: {
      count: {
        type: GraphQLInt,
        resolve: function() {
          return count;
        }
      }
    }
  })
});
export default schema;

package.json

"dependencies": {
    "babel-core": "^6.26.0",
    "babel-loader": "^7.1.2",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-react": "^6.24.1",
    "babel-preset-stage-1": "^6.24.1",
    "express": "^4.16.2",
    "express-graphql": "^0.6.11",
    "graphql": "^0.11.7",
    "mysql": "^2.15.0",
    "react": "^16.2.0",
    "react-dom": "^16.2.0",
    "react-relay": "^1.4.1",
    "require-clean": "^0.1.3",
    "webpack": "^3.8.1",
    "webpack-dev-server": "^2.9.5"
  }

server.js

import express from 'express';
import graphQLHTTP from 'express-graphql';
var Schema = require('./data/schema');
const GRAPHQL_PORT = 8080;
let graphQLServer;
 
 const graphQLApp = express();
  graphQLApp.use('/', graphQLHTTP({
    graphiql: true,
    pretty: true,
    schema: Schema,
  }));
  graphQLServer = graphQLApp.listen(GRAPHQL_PORT, () => {
    console.log(
      GraphQL server is now running.
 );
  });

Any idea what is wrong in it?

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

No branches or pull requests

5 participants