How can I save cookies in the response object of a NestJS GraphQL application? Here is the relevant code snippet:
app.module.ts:
GraphQLModule.forRoot<ApolloDriverConfig>({
autoSchemaFile: true,
driver: ApolloDriver,
cors: {
origin: process.env.ADDRESS,
credentials: true,
},
context: ({ req, res }) => ({ req, res }),
}),
resolver:
@Mutation(() => token)
async login(
@Args("input") input: LoginI,
@Context() context: GraphQLExecutionContext
) {
const result = await this.authnService.login(input);
context.res.cookie("authorization", "Bearer " + result.userToken);
return result;
}
However, it seems like it's not working as expected.
console.log(context.res.cookies)
Returns undefined. Additionally, I do not see any cookies in the browser devtools for my client.