alex-ald / postgraphile-nest

GraphQL (PostGraphile) module for Nest framework (node.js)
Other
59 stars 11 forks source link

NestJS's global interceptors, guards don't execute #36

Open kuldeep-extentia opened 2 years ago

kuldeep-extentia commented 2 years ago

Hi, So if i configure postgraphile using the official doc like:

**> `For Nest, this might look something like:

import { Controller, Get, Post, Req, Next, Res } from '@nestjs/common'; import { Request, Response } from 'express'; import { PostGraphileResponseNode } from 'postgraphile'; import { middleware } from './postgraphile.middleware';

@Controller('/') export class PostGraphileController { @Get(middleware.graphiqlRoute) graphiql (@Req() request: Request, @Res() response: Response, @Next() next) { middleware.graphiqlRouteHandler(new PostGraphileResponseNode(request, response, next)); }

@Post(middleware.graphqlRoute) graphql (@Req() request: Request, @Res() response: Response, @Next() next) { middleware.graphqlRouteHandler(new PostGraphileResponseNode(request, response, next)); } }`**

All my nestjs global interceptors and guards work.

But when i configure postgraphile using your module's forRoot method, none of my global interceptors/guards get executed. I'm able to execute middlewares configured for /graphql but not interceptors/guards.

Any hint would be helpful. Thank you.

kuldeep-extentia commented 2 years ago

I realized postgraphile instance is being used as a middleware directly using app.use(postgraphile) and thus interceptors/guards will not run. Any chance of exposing the postgraphile instance instead of mounting as a middleware?