server
server copied to clipboard
Support Authentication
https://www.apollographql.com/docs/apollo-server/features/authentication
@wzalazar in this feature will contain the context implementation also correct?
@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
if you start with this issue and you have doubts or problems, ping me!
@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.