Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation: Azure Functions Deployment #5675

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions packages/apollo-server-azure-functions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,26 @@ The options correspond to the [express cors configuration](https://github.com/ex
* `credentials`: boolean
* `maxAge`: number

### Request Body / Token
By default Azure Functions will pass the request object as req. Pass this into the context of the ApolloServer constructor to access request contents. For example for passing an auth token to a backend.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

req is just the name you're choosing for an argument here, FWIW.


```js
const server = new ApolloServer(
{ typeDefs,
resolvers,
context: (req) => {
const authHeader = req.context.bindings.req.headers.authorization || '';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that actually the best way to get a header? I see at https://www.apollographql.com/docs/apollo-server/api/apollo-server/#middleware-specific-context-fields that we pass context and also request. Wouldn't req.request.headers be simpler?

if (authHeader === '') throw new AuthenticationError('please send Bearer token with request');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weird spacing in the error message

return {
token: authHeader,
}
},
```

### Optional, helpful packages
* azure-function-log-intercept - console.* messages appear in teh functions log.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how helpful this is without an example of how to use it. Also typo "teh" vs "the".



## Principles

GraphQL Server is built with the following principles in mind:
Expand Down