"one instance of graphql" error when using esm package.
See original GitHub issueWhen using esm package (https://github.com/standard-things/esm) even most simple package.json configurations (only dependancies are esm and graphql-yoga) results in the Error: Cannot use GraphQLSchema "[object Object]" from another module or realm. error when using imports.
node -r esm testWithImport.js will fail while node testWithRequire.js and node -r esm testWithRequire.js will work.
Issue Analytics
- State:
- Created 5 years ago
- Comments:16 (5 by maintainers)
Top Results From Across the Web
How to fix the annoying "Ensure there is only one instance of ...
Error: Cannot use GraphQLSchema "[object Object]" from another module or realm. Ensure that there is only one instance of "graphql" in the node_modules ......
Read more >GraphQL error handling to the max with Typescript, codegen ...
In REST, one can send a response with a appropriate status code to inform the caller about the kind of exception encountered, e.g.:...
Read more >graphql-upload - npm
Middleware and an Upload scalar to add support for GraphQL multipart requests (file uploads via queries and mutations) to various Node.js ...
Read more >Migrating to Apollo Client 3.0 - Apollo GraphQL Docs
The @apollo/client package includes both React hooks and GraphQL request handling, ... If you are updating an existing application to use Apollo Client...
Read more >gqlr - NPM Package Overview - Socket - Socket.dev
Actually Isomorphic (works with Node / browsers). Ships a real ESM module, instead of the fake one TS generates. Why? graphql-request was causing...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

This happens if you were to add a new npm script called
and a test file
serverWithImport.mjs:too.
The issue is that
graphql-yogais CJS (and loads the CJS entry ofgraphql) but you’re loading the ESM version ofgraphql.Because
graphglis running two entry points they create 2 separate instances (a limitation of their current dual approach). The way around it is forgraphqlto instantiate their instances in CJS and export them for the ESM entry to consume.My solution was to replace
with
I was using flags
--experimental-modules --es-module-specifier-resolution=nodeto omit extensions.