https://supertokens.com/ logo
#general
Title
# general
a

aditya._.tomar

04/23/2022, 8:40 PM
hi guys, can anyone tell me how to use super token with apollo-server?
r

rp

04/24/2022, 5:15 AM
hey @aditya._.tomar
You can checkout the graphql section in the docs.
a

aditya._.tomar

04/24/2022, 8:35 AM
yes i've gone throught it.. but it's not much helping me..
r

rp

04/24/2022, 8:36 AM
so if you have specific questions, it would be easier to help out.
a

aditya._.tomar

04/24/2022, 8:36 AM
this is the code i've written in backend.
r

rp

04/24/2022, 8:38 AM
alright.
that seems about right. Where are your resolvers?
and what happens when you make a request to the graphql endpoint?
a

aditya._.tomar

04/24/2022, 8:45 AM
first thing is should i've to use both apollo-server-express and express-graphql?
r

rp

04/24/2022, 8:46 AM
probably not. Im not a graphql expert. But both those libs seem to be doing similar tasks.
a

aditya._.tomar

04/24/2022, 8:48 AM
one solution i think of is that.. i should create one express microservice for authentication with supertoken separete.. and other microservice with apollo.. but the problem will occur that how'll i implement the session middleware in apollo then.
r

rp

04/24/2022, 8:50 AM
yea.. you don't need to have separate services. You can use them together as well. As explained in the docs
a

aditya._.tomar

04/24/2022, 8:51 AM
if you have any working code. can you please share. just for reference. coz I'm really confused.
my supertoken endpoints are not working.
r

rp

04/24/2022, 8:54 AM
so the code you have written on the backend seem to be mostly correct. The only step you missed out on is to add the supertokens errorHandler after the graphql API endpoint. About the errors you are seeing, it seems that the node server is not running / or is not reachable when you are querying it from the frontend.
We don't yet have a graphql example app, but we have a normal express example app: https://github.com/supertokens/supertokens-auth-react/tree/master/examples/with-emailpassword
a

aditya._.tomar

04/24/2022, 9:08 AM
ok i'll try again.. will let you know shortly and if it works i'll share my code as a graphql example.. 😁 thanks for your time.
r

rp

04/24/2022, 9:08 AM
Thank you