-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
|
||
```js | ||
const server = new ApolloServer( | ||
{ typeDefs, | ||
resolvers, | ||
context: (req) => { | ||
const authHeader = req.context.bindings.req.headers.authorization || ''; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
if (authHeader === '') throw new AuthenticationError('please send Bearer token with request'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: | ||
|
There was a problem hiding this comment.
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.