https://supertokens.com/ logo
v

Version467

03/26/2022, 5:10 PM
Has anyone successfully setup supertokens with nestjs + graphql? I've had no trouble setting it up for nestjs without graphql, but I'm not able to adapt the supertokens graphql guide to work with the nestjs grapqhl module.
r

rp

03/26/2022, 5:11 PM
Are you facing any errors specifically? We have had people implement this combination before
v

Version467

03/26/2022, 5:14 PM
The verifySession method in my guard errors out because the request object is undefined.
r

rp

03/26/2022, 5:15 PM
Hmmm. Are you applying the guard to the graphql endpoint?
v

Version467

03/26/2022, 5:19 PM
Yes. I'm applying the auth middleware to every route, so the graphql endpoint should be included. I probably have to differentiate between http and graphql requests in the guard, because the application context is different. But I'm really not sure.
r

rp

03/26/2022, 5:21 PM
I see. We will have to look into it a bit. If you open an issue about it on our GitHub, then we can make a demo app for this
v

Version467

03/26/2022, 5:22 PM
I'll try a couple more things, but if I can't get it to run by the end of the day I'll open an issue. Thanks 👍
r

rp

03/26/2022, 5:22 PM
Sounds good!
If you do get it to work, feel free to contribute the example to open source 🙂
v

Version467

03/26/2022, 5:43 PM
Got it to work. Accessing the request object is different for the graphql executioncontext. Checking the context type before calling verifySession fixes the issue. I can probably build an example for this. If I do, where can I put it?
r

rp

03/26/2022, 5:45 PM
You can create a PR for the demo in here: https://github.com/supertokens/supertokens-node/tree/master/examples A folder name like
nestjs-graphql
would work well
v

Version467

03/26/2022, 5:54 PM
Alright, sounds good.
4 Views