diff --git a/docs/source/security/authentication.md b/docs/source/security/authentication.md index 82fc4575577..674381c5334 100644 --- a/docs/source/security/authentication.md +++ b/docs/source/security/authentication.md @@ -23,12 +23,20 @@ const server = new ApolloServer({ typeDefs, resolvers, context: ({ req }) => { - // get the user token from the headers + // Note! This example uses the `req` object to access headers, + // but the arguments received by `context` vary by integration. + // This means they will vary for Express, Koa, Lambda, etc.! + // + // To find out the correct arguments for a specific integration, + // see the `context` option in the API reference for `apollo-server`: + // https://www.apollographql.com/docs/apollo-server/api/apollo-server/ + + // 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 }; },