[BUG] Middleware not called while using nestjs-session with @nestjs/graphql
See original GitHub issueWhat is the current behavior?
I don’t succeed to make this package work with @nestjs/graphql
.
When I call a REST route, it’s working well, and the session(req, res, next)
middleware (from express-session
) is well called.
But when I call the GraphQL entrypoint, the middleware is not called at all.
I’ve digged deep in nestjs source-code, but I don’t know really where to look.
Even with a forRoutes: [{ path: '/*', method: RequestMethod.ALL }],
this change nothing.
What is the expected behavior?
In practice, the consequences are that no cookie is defined in the GraphQL response, and so, the sessions don’t work.
Please mention other relevant information such as Node.js version and Operating System.
Issue Analytics
- State:
- Created 3 years ago
- Comments:17 (5 by maintainers)
Top Results From Across the Web
Nestjs - how to get session in middleware - Stack Overflow
i tried to add a middleware to the app module, with forRoutes call. but the middleware isn't called with the graphql route /graphql...
Read more >Setting Up Sessions with NestJS, Passport, and Redis
controller an exception is thrown because passport is not initialized but if I use the LoggedInGuard in my auth.controller it's working. The one ......
Read more >Field middleware | NestJS - A progressive Node.js framework
Field Middleware lets you run arbitrary code before or after a field is resolved. A field middleware can be used to convert the...
Read more >Nestjs set cookie - salonelibrousato.it
Judging by parameters, Nest doesn't provide us with an ability to set a cookie in resolvers. Configuring Cookie Authentication Service.
Read more >Nestjs Log Response Data Object - ADocLib
For example: import moesif from 'moesif-nodejs'; 2. Node. js loggers and start using two of the most popular logging packages for Node, I...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m using redis to manage the session. It’s really odd because the session in my controllers works great. However, with graphql, every request creates a brand new empty session.
Session in Controllers
Session in Graphql
Notice that only the first session is used in the controller, but all the rest of the sessions are created new with every graphql request.
So, I’ve built a simple module to do the init and session, and it works well. So I think the problem is not from your side, but from @nestjs/passport side who should integrate a way to register these middlewares.