But, by declaring it as a dependency, and furthermore pinning it to a specific version, you enforce users to use the same version. This makes it impossible to upgrade @nestjs/graphql freely. When using monorepo setups, the users have to uninstall @nestjs/core from their projects and depend on @graphql-yoga/nestjs to provide it. Here is the error happening when there are multiple @nestjs/graphql packages:
[Nest] 82791 - 12/07/2022, 10:34:33 PM ERROR [ExceptionHandler] Nest can't resolve dependencies of the YogaDriver. Please make sure that the "httpAdapterHost" property is available in the current context.
Potential solutions:
- Is GraphQLModule a valid NestJS module?
- If HttpAdapterHost is a provider, is it part of the current GraphQLModule?
- If HttpAdapterHost is exported from a separate @Module, is that module imported within GraphQLModule?
@Module({
imports: [ /* the Module containing HttpAdapterHost */ ]
})
In a Yarn Workspaces setup, if I patch yarn.lock to remove @nestjs/graphql from @graphql-yoga/nestjs, it works fine, but the types rightfully fail. If I remove @nestjs/graphql from my dependencies, it works fine. I tried upgrading the code-first example project and it works fine. If I do yarn add @nestjs/graphql@10.1.6, it still works because the example project is not a monorepo. If I do yarn add @nestjs/graphql, which resolves to 10.1.7, it stops working and throws this error:
[Nest] 89366 - 12/07/2022, 10:50:02 PM ERROR [ExceptionHandler] Nest can't resolve dependencies of the YogaDriver. Please make sure that the "graphQlFactory" property is available in the current context.
Potential solutions:
- Is GraphQLModule a valid NestJS module?
- If GraphQLFactory is a provider, is it part of the current GraphQLModule?
- If GraphQLFactory is exported from a separate @Module, is that module imported within GraphQLModule?
@Module({
imports: [ /* the Module containing GraphQLFactory */ ]
})
which is basically the same as the first error I sent, just for a different "provider".
Fixes #48, but the problem is more than that.
This package pins
@nestjs/graphql
to a specific version, as adependency
: https://github.com/charlypoly/graphql-yoga-nestjs/blob/7182757556c60321ca39f4ffffaa813c27697141/package.json#L67This guide instructs installing
@nestjs/graphql
: https://the-guild.dev/graphql/yoga-server/docs/integrations/integration-with-nestjs#installationBut, by declaring it as a
dependency
, and furthermore pinning it to a specific version, you enforce users to use the same version. This makes it impossible to upgrade@nestjs/graphql
freely. When using monorepo setups, the users have to uninstall@nestjs/core
from their projects and depend on@graphql-yoga/nestjs
to provide it. Here is the error happening when there are multiple@nestjs/graphql
packages:In a Yarn Workspaces setup, if I patch
yarn.lock
to remove@nestjs/graphql
from@graphql-yoga/nestjs
, it works fine, but the types rightfully fail. If I remove@nestjs/graphql
from mydependencies
, it works fine. I tried upgrading thecode-first
example project and it works fine. If I doyarn add @nestjs/graphql@10.1.6
, it still works because the example project is not a monorepo. If I doyarn add @nestjs/graphql
, which resolves to10.1.7
, it stops working and throws this error:which is basically the same as the first error I sent, just for a different "provider".
It should be specified in
peerDependencies
instead, just like how NestJS does in Apollo and Mercurius drivers: https://github.com/nestjs/graphql/blob/5997d561f9abc17bfc444a10b71edbbc72ef817c/packages/apollo/package.json#L52 https://github.com/nestjs/graphql/blob/5997d561f9abc17bfc444a10b71edbbc72ef817c/packages/mercurius/package.json#L39I upgraded the code-first example to NestJS v9. To reproduce the problem I've mentioned, just do the following: