server icon indicating copy to clipboard operation
server copied to clipboard

Support Authentication

Open wzalazar opened this issue 5 years ago • 4 comments

https://www.apollographql.com/docs/apollo-server/features/authentication

wzalazar avatar Apr 15 '19 15:04 wzalazar

@wzalazar in this feature will contain the context implementation also correct?

rodrigooler avatar Jul 03 '19 13:07 rodrigooler

@rodrigooler yes, I think is just add the context option. If you want you can contribute to this feature...

The best way to start with that is to create a functional test, for example:

https://github.com/graphitejs/server/blob/master/test/functional/mutation.js

where Graphite could receive the context option

const context = ({ req }) => {
   // get the user token from the headers
   const token = req.headers.authorization || '';
  
   // try to retrieve a user with the token
   const user = getUser(token);
  
   // add the user to the context
   return { user };
 }

const graphite = await Graphite({ models: [Developer], context })

btw, you can run the functional test with this command

npm run test:functional

wzalazar avatar Jul 03 '19 14:07 wzalazar

if you start with this issue and you have doubts or problems, ping me!

wzalazar avatar Jul 03 '19 18:07 wzalazar

@wzalazar this problem seems very simple. I am just trying to reconcile with my coding schedule and I will do the PR with the implementation and also discuss some possible points of improvement in the code.

rodrigooler avatar Jul 04 '19 18:07 rodrigooler