8000 Graphql Support for LoggingInterceptor · Issue #489 · algoan/nestjs-components · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Graphql Support for LoggingInterceptor #489
Open
@agmoss

Description

@agmoss

Currently, the LoggingInterceptor does not work with graphql. Internal calls to intercept, logNext, and logError use the base ExecutionContext from nest without first evaluating the current application context.

Accessors for the in-flight request object are different depending on the application context. For rest they look like:

const req: Request = context.switchToHttp().getRequest<Request>();
const res: Response = context.switchToHttp().getResponse<Response>();
const { method, url } = req;

as you have in logNext

In graphql it looks like

const method = context.getArgs()[2].req.method;
const url = context.getArgs()[2].req.url;

(at least this is the cleanest way I have been able to access these)

As such, the use of rest style of access yields the following logs when in the graphql context:

[LoggingInterceptor - undefined - undefined - undefined] Outgoing response - undefined - undefined - undefined 

Anyway, if you want to support gql with this interceptor I would be open to making a pr! Or perhaps I could add a new one that is specific for graphql.

This is a great assembly of nest utils!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0