I wanted to create a graphql apollo server without using a separate route like:
app.post('/login', () => {//do stuff})
app.post('/signup', () => {//do stuff})
So I decided to create an middleware to all my graphql resolvers, but I'm wondering if does exist a best way of doing it.
Of course I could verify the user by putting a verify function inside the context, but I don't want to make it, I think putting a new String
in an array is more convenient
I'm using passport
for the authentication and setting a custom property req.authenticated
to know if the users is authenticated or not