Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple "graphql" instances with npm link #3713

Closed
egor-shell opened this issue Aug 22, 2022 · 2 comments
Closed

Multiple "graphql" instances with npm link #3713

egor-shell opened this issue Aug 22, 2022 · 2 comments

Comments

@egor-shell
Copy link

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.
@JoviDeCroock
Copy link
Member

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
Copy link
Member

Closing due to inactivity - do note my prior response that this is a common issue and either can be solved through using an alias or explicitly marking graphql as external in your library. Similar issues are present in i.e. React

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants