apollo-server
apollo-server copied to clipboard
Improved Azure Function middleware handling
Added a simple inner return statement to the return statement of createHandler within the apollo-server-azure-functions package.
The reason for this is improved middleware handling for Azure Functions. Now it will be possible to modify Azure Function context before letting it be handled by ApolloServer:
const httpTrigger: AzureFunction = async function (context: Context, req: HttpRequest): Promise<void> {
const server = new ApolloServer({ typeDefs, resolvers });
await server.createHandler()(context, req);
};
exports.graphqlHandler = httpTrigger;
Before, server.createHandler()(context, req) wouldn't return anything, making the Azure Function return a 204 since it didn't know how long to wait for the function to return anything. I needed the return for making middleware like https://www.npmjs.com/package/graphql-upload#function-processrequest possible in an Azure Function.
@marcveens: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/
Deploy Preview for apollo-server-docs canceled.
Built without sensitive environment variables
| Name | Link |
|---|---|
| Latest commit | 55cd9f0926053c11ab5e882b0d5aceced266803a |
| Latest deploy log | https://app.netlify.com/sites/apollo-server-docs/deploys/6284b9c77b6ae8000a0c96de |
This pull request is automatically built and testable in CodeSandbox.
To see build info of the built libraries, click here or the icon next to each commit SHA.
Latest deployment of this branch, based on commit 55cd9f0926053c11ab5e882b0d5aceced266803a:
| Sandbox | Source |
|---|---|
| Apollo Server Typescript | Configuration |
| Apollo Server | Configuration |
That does seem useful. How confident are you that this will be fully backwards-compatible?
Your sample code doesn't look great: it starts a new ApolloServer from scratch on every request. I realize this is serverless but don't serverless infrastructures typically use a container multiple times in a row? It's better to use a single ApolloServer object so it doesn't have to fetch its schema from Uplink and do other startup tasks on every request.
Also one weird request — sometimes our CI does not run on contributor pull requests. I am told by CircleCI support that this is because you have logged in to CircleCI and "followed" your fork there. Is that true? Are you able to go to https://app.circleci.com/pipelines/github/marcveens/apollo-server and "unfollow" that forked project?
We no longer directly maintain an Azure Functions integration. Instead, AS4 has a well-defined API for building integrations. If you're interested in helping to maintain a package for building Azure Functions with AS, we're discussing it over at https://github.com/apollographql/apollo-server/issues/6032