Skip to content

Instantly share code, notes, and snippets.

@marcelovue
marcelovue / README.md
Last active April 18, 2019 18:00
That's how I did PUBLIC and PRIVATE resolvers in my express apollo server, wondering if its the best way of doing it

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