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
When I start the server with node --experimental-modules ./index.mjs everything goes smoothly, but as soon as I open http://localhost:4567/graphiql or send query directly to http://localhost:4567/graphql, this error apperas:
Error: Cannot use GraphQLSchema "[object Object]" from another module or realm.
Ensure that there is only one instance of "graphql" in the node_modules
directory. If different versions of "graphql" are the dependencies of other
relied on modules, use "resolutions" to ensure only one version is installed.
https://yarnpkg.com/en/docs/selective-version-resolutions
Duplicate "graphql" modules cannot be used at the same time since different
versions may have different capabilities and behavior. The data from one
version used in the function from another could produce confusing and
spurious results.
at instanceOf (/Users/kalle/Desktop/test/node_modules/graphql/jsutils/instanceOf.js:15:13)
at isSchema (/Users/kalle/Desktop/test/node_modules/graphql/type/schema.js:52:35)
at validateSchema (/Users/kalle/Desktop/test/node_modules/graphql/type/validate.js:55:25)
at assertValidSchema (/Users/kalle/Desktop/test/node_modules/graphql/type/validate.js:80:16)
at Object.validate (/Users/kalle/Desktop/test/node_modules/graphql/validation/validate.js:58:35)
at doRunQuery (/Users/kalle/Desktop/test/node_modules/apollo-server-core/dist/runQuery.js:110:38)
at /Users/kalle/Desktop/test/node_modules/apollo-server-core/dist/runQuery.js:21:56
at process._tickCallback (internal/process/next_tick.js:178:7)
I have read issues such as this, but they don't seem to match my case.
Everything works fine with CommonJS modules using require, but I'm not satisfied with that.
The text was updated successfully, but these errors were encountered:
This is because apollo-server is published only as CJS/.js without ESM/.mjs. What happens, is that graphql is imported using ESM in your code, but it is imported in apollo-server code using CJS. The objects are in different .js/.mjs modules and graphql refuses to cooperate via that assertion, thinking you are loading two different GraphQL packages.
The appropriate solution is for Apollo to publish native-ESM capable packages. Until then, you can create a graphql.js file in your project, containing:
I've found an issue while running a query in a simple koa server using es modules with Node v10.0.0. My
index.mjs
server file is the following:When I start the server with
node --experimental-modules ./index.mjs
everything goes smoothly, but as soon as I openhttp://localhost:4567/graphiql
or send query directly tohttp://localhost:4567/graphql
, this error apperas:I have read issues such as this, but they don't seem to match my case.
Everything works fine with CommonJS modules using
require
, but I'm not satisfied with that.The text was updated successfully, but these errors were encountered: