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
Error: @nestjs/mercurius tried to access graphql and mercurius and lodash, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
#2129
Closed
2 of 4 tasks
ceefour opened this issue
Apr 9, 2022
· 2 comments
ceefour
changed the title
Error: @nestjs/mercurius tried to access graphql, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
Error: @nestjs/mercurius tried to access graphql and mercurius, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
Apr 9, 2022
ceefour
changed the title
Error: @nestjs/mercurius tried to access graphql and mercurius, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
Error: @nestjs/mercurius tried to access graphql and mercurius and lodash, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
Apr 9, 2022
Would you like to create a PR adding graphql as a peer dependency? Note: this might be problematic as mercurius incorrectly marks graphql as a dependency (while it should be a peer dependency instead) mercurius-js/mercurius#711
This issue also occurs when Express and Apollo are installed using yarn 'PnP'. In this case, graphql and apollo-server-core can't be resolved.
I temporarily solved this by adding a few lines of code to the .yarnrc.yml and add apollo-server-core as a dependency in my nestjs project.
Is there an existing issue for this?
Current behavior
@nestjs/mercurius uses graphql without listing it in its dependencies. It works in certain hoisting layouts because it hijacks it from other package
This creates issues when using the package with Yarn's PnP resolution, and I assume also breaks the pnpm package manager.
See:
Minimum reproduction code
Steps to reproduce
With an empty app as in https://docs.nestjs.com/graphql/quick-start#mercurius-integration
Then edit
.yarnrc.yml
and setnode-linker
topnp
yarn start:dev
will no longer start.This is very similar to #1162
Expected behavior
All imported packages should be listed in package.json. (maybe as peer dependencies?) Specifically:
graphql
mercurius
lodash
Package version
10.0.8
Graphql version
graphql
: 16.3.0apollo-server-express
: not usedapollo-server-fastify
: not used@nestjs/platform-fastify
: 8.4.4@nestjs/mercurius
: 10.0.8NestJS version
8.4.4
Node.js version
16.14.2
In which operating systems have you tested?
Other
No response
The text was updated successfully, but these errors were encountered: