I'm trying to get this package working with graphiql, but with a simple example I get this error:
{"type":"error","id":"1","payload":{"message":"Cannot use GraphQLSchema \"[object Object]\" from another module or realm.\n\nEnsure that there is only one instance of \"graphql\" in the node_modules\ndirectory. If different versions of \"graphql\" are the dependencies of other\nrelied on modules, use \"resolutions\" to ensure only one version is installed.\n\nhttps://yarnpkg.com/en/docs/selective-version-resolutions\n\nDuplicate \"graphql\" modules cannot be used at the same time since different\nversions may have different capabilities and behavior. The data from one\nversion used in the function from another could produce confusing and\nspurious results."}}
Packages used:
"dependencies": {
"apollo-server-express": "^1.3.6",
"body-parser": "^1.18.2",
"cors": "^2.8.4",
"dotenv": "^5.0.1",
"express": "^4.16.3",
"graphql": "^0.13.2",
"graphql-tools": "^3.0.0",
"graphql-type-json": "^0.2.1",
"mongodb": "^3.0.7",
"mongoose": "^5.0.16",
"promise-retry": "^1.1.1",
"web3": "^1.0.0-beta.34"
},
I've tried this to no avail either:
https://github.com/graphcool/graphql-yoga/issues/162#issuecomment-367368045
What is the output of running npm ls | grep graphql in your project?
โก npm ls | grep graphql
โ โ โ โโโ [email protected] deduped
โ โ โ โโโ [email protected] deduped
โ โ โโโฌ [email protected]
โโโฌ [email protected]
โโโฌ [email protected] invalid
โโโ [email protected]
npm ERR! extraneous: node-pre-gyp /....../node_modules/node-pre-gyp
npm ERR! error in /....../node_modules/node-pre-gyp: ENOENT: no such file or directory, open '/....../node_modules/node-pre-gyp/package.json'
npm ERR! invalid: [email protected] /....../node_modules/graphql-tools
npm ERR! extraneous: [email protected] /....../node_modules/apollo-link
npm ERR! extraneous: [email protected] /....../node_modules/apollo-utilities
npm ERR! extraneous: [email protected] /....../node_modules/deprecated-decorator
I would resolve the npm ERR! to see if that fixes the issue. Might need to remove your existing node_modules and reinstall.
Thanks. That node-gyp stuff has been mad annoying recently.
i have the same error and "npm ls | grep graphql" did not show any errors. How do i resolve the issue?
"
$ npm ls | grep graphql
+-- [email protected]
+-- [email protected]
"
THE ERROR
{
"errors": [
{
"message": "Cannot use GraphQLSchema \"[object GraphQLSchema]\" from another module or realm.\n\nEnsure that there is only one instance of \"graphql\" in the node_modules\ndirectory. If different versions of \"graphql\" are the dependencies of other\nrelied on modules, use \"resolutions\" to ensure only one version is installed.\n\nhttps://yarnpkg.com/en/docs/selective-version-resolutions\n\nDuplicate \"graphql\" modules cannot be used at the same time since different\nversions may have different capabilities and behavior. The data from one\nversion used in the function from another could produce confusing and\nspurious results."
}
]
}
I have an error :- "message": "Cannot use GraphQLSchema \"[object GraphQLSchema]\" from another module or realm.\n\nEnsure that there is only one instance of \"graphql\" in the node_modules\ndirectory. If different versions of \"graphql\" are the dependencies of other\nrelied on modules, use \"resolutions\" to ensure only one version is installed.\n\nhttps://yarnpkg.com/en/docs/selective-version-resolutions\n\nDuplicate \"graphql\" modules cannot be used at the same time since different\nversions may have different capabilities and behavior. The data from one\nversion used in the function from another could produce confusing and\nspurious results."
can u please let me know what the actual error is
In my case, realized I was using graphql v15.x.x in my application package.json while graphql-yoga was using graphql v14.x.x. Deleted the v15.x.x and replaced it with v14.x.x works. That created a single graphql v14.x.x to be used.
Hope this helps.
Most helpful comment
i have the same error and "npm ls | grep graphql" did not show any errors. How do i resolve the issue?
"
THE ERROR