graphql-js icon indicating copy to clipboard operation
graphql-js copied to clipboard

Multiple "graphql" instances with npm link

Open egor-shell opened this issue 3 years ago • 1 comments

When I connect my other module to the main application using npm link, an error appears: "Cannot use GraphQLObjectType "Query" from another module or realm."

  • Graphql versions are the same in both modules.
  • There are no other graphics folders in the node_modules folder
  • All versions of graphql in npm ls are identical. What could be the problem?
  • GraphQL added to peerDependencies in the plug-in
  • The options with the removal of package-lock, resolution and npm dedupe did not work. And the problem only occurs with npm link.

egor-shell avatar Aug 22 '22 17:08 egor-shell

This is expected yes, you can use an alias to always resolve to the local node_modules or ensure that you use a link (unlike npm) which won't allow usage of node_modules of the symlinked package.

The issue here is that you symlink to a second folder which has its own version of GraphQL while if you build and publish that library/... you will mark graphql as external and add it to peerDependencies hence this won't happen.

JoviDeCroock avatar May 04 '24 14:05 JoviDeCroock