enisdenjo / graphql-yoga-nestjs

Nest GraphQL GraphQL Yoga driver
https://the-guild.dev/graphql/yoga-server/docs/integrations/integration-with-nestjs
25 stars 11 forks source link

GraphQL initialization fails #52

Closed MitkoTschimev closed 1 year ago

MitkoTschimev commented 1 year ago

Hi,

thanks for doing the work and integrating yoga into NestJS. I tried it out with the newest version of nestjs and yoga but unfortunately it fails already at bootstrap.

codesandbox link: https://codesandbox.io/s/nestjs-yoga-graphql-auth-e68htx

sandbox@sse-sandbox-e68htx:/sandbox$ npm start

> nestjs-yoga-graphql-auth@1.0.0 start /sandbox
> nest start

[Nest] 1673  - 01/11/2023, 6:04:08 AM     LOG [NestFactory] Starting Nest application...
[Nest] 1673  - 01/11/2023, 6:04:08 AM     LOG [InstanceLoader] AppModule dependencies initialized +24ms
[Nest] 1673  - 01/11/2023, 6:04:08 AM     LOG [InstanceLoader] GraphQLModule dependencies initialized +0ms
[Nest] 1673  - 01/11/2023, 6:04:08 AM   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:
- If GraphQLFactory is a provider, is it part of the current GraphQLModule?
- If GraphQLFactory is exported from a separate @Module, is that module imported withinGraphQLModule?
  @Module({
    imports: [ /* the Module containing GraphQLFactory */ ]
  })

Error: Nest can't resolve dependencies of the YogaDriver. Please make sure that the "graphQlFactory" property is available in the current context.

Is there something wrong with what I do? Also I really would like to know how dependency injection with the envelop plugins are working? My idea was to use an async initialization of the graphql module to inject the required services but therefore I have first to figure out how to start a simple server :D

I read also this issue so I thought it should work know

synerp commented 1 year ago

I have the same error.

enisdenjo commented 1 year ago

@MitkoTschimev @synerp seems like this is caused with the latest version of @nestjs/graphql@v10.1.7, downgrading to v10.1.6 fixes the issue.

Still pinpointing the exact root cause, will push a fix soon. Thanks for reporting!

enisdenjo commented 1 year ago

Quick heads up, this has been fixed with #54. Please update to at least @graphql-yoga/nestjs@v0.3.0.