dotansimha / graphql-yoga

🧘 Rewrite of a fully-featured GraphQL Server with focus on easy setup, performance & great developer experience. The core of Yoga implements WHATWG Fetch API and can run/deploy on any JS environment.
https://the-guild.dev/graphql/yoga-server
MIT License
8.2k stars 568 forks source link

Plugins not working in nestjs #3383

Open SOG-web opened 1 month ago

SOG-web commented 1 month ago

Describe the bug

 GraphQLModule.forRoot<YogaDriverConfig>({
      driver: YogaDriver,
      autoSchemaFile: join(process.cwd(), 'src/schema.gql'),
      sortSchema: true,
      logging: 'debug',
      landingPage: false,
      // graphiql: false,
      healthCheckEndpoint: '/live',
      context: ({ req, res }) => ({ req, res }),
      plugins: [
        useSofa({
          basePath: '/rest',
          swaggerUI: {
            endpoint: '/swagger',
            spec: {
              info: {
                title: 'My API',
                version: '1.0.0',
                description: 'This is a sample API',
              },
            },
          },
        }),
        useReadinessCheck({
          endpoint: '/ready', // default
          check: async () => {
            try {
              // await checkDbAvailable();
              // if true, respond with 200 OK
              return true;
            } catch (err) {
              // log the error on the server for debugging purposes
              console.error(err);
              // if false, respond with 503 Service Unavailable and no bdy
              return false;
            }
          },
        }),
        useExecutionCancellation(),
        useCSRFPrevention({
          requestHeaders: ['x-graphql-yoga-csrf'], // default
        }),
        useResponseCache({
          // global cache
          session: () => null,
          cache,
        }),
        useAPQ(),
      ],
    }),

/live not working /swagger not working /rest not working /ready not working

Your Example Website or App

https://github.com/SOG-web/yoga-nestjs

Steps to Reproduce the Bug or Issue

just set up a simple code first gql nestjs server

Expected behavior

those endpoint should be working

Screenshots or Videos

No response

Platform

Additional context

No response

greenGizmo commented 1 month ago

Same problem here. Trying to use customEnvelop plugins and the useJWT plugin which work perfectly fine in Mesh but not in NestJS.