Reputation: 459
How can I access pass @Res()
into my graphql resolvers?
this doesn't work:
@Mutation(() => String)
login(@Args('loginInput') loginInput: LoginInput, @Res() res: Response) {
return this.authService.login(loginInput, res);
}
Upvotes: 5
Views: 3378
Reputation: 70061
@Res()
is for HTTP Requests. To access to res
object you'd need to first make sure it is added to the context
for graphql by using context: ({ req, res }) => ({ req, res })
in the GraphqlModule
's options, and then you can use @Context() ctx
to get the context and ctx.res
to get the response object
Upvotes: 12