You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ curl -s -X POST -H "Content-type: application/json" http://localhost:4000/graphql --data '{ "query": "{ hello }" }'|jq
{
"errors": [
{
"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."
}
]
}
Creating a wrapper to require buildSchema instead:
req.js
module.exports=require('graphql').buildSchema;
And changing the initial example:
//import { buildSchema } from 'graphql';importbuildSchemafrom'./req';
Arguably this is a problem with express-graphql; it could be resolved by their build including a .mjs file that imports GraphQL to match like-for-like module conventions, instead of just a .js file that requires it regardless of context. However, I think GraphQL is wrong to complain about the mixed arrangement, and in any case the error message is a red herring.
The text was updated successfully, but these errors were encountered:
The following does not work, though it seems to me it should (node@9.8.0):
Creating a wrapper to
require
buildSchema instead:req.js
And changing the initial example:
works as expected:
Arguably this is a problem with
express-graphql
; it could be resolved by their build including a.mjs
file thatimport
s GraphQL to match like-for-like module conventions, instead of just a.js
file thatrequires
it regardless of context. However, I think GraphQL is wrong to complain about the mixed arrangement, and in any case the error message is a red herring.The text was updated successfully, but these errors were encountered: