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

fix(fastify): return reply object from async handlers #6798

Merged
merged 2 commits into from Aug 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions CHANGELOG.md
Expand Up @@ -10,9 +10,10 @@ The version headers in this history reflect the versions of Apollo Server itself

## vNEXT

## 3.7.0 (RESTDataSource only)
## v3.10.2

- [apollo-datasource-rest] Add option `memoizeGetRequests` to disable GET cache [PR #6650](https://github.com/apollographql/apollo-server/pull/6650) and [PR #6834](https://github.com/apollographql/apollo-server/pull/6834)
- `apollo-server-fastify`: Use `return reply.send` in handlers to match the pattern encouraged by Fastify 4 (although [`apollo-server-fastify@3` only works with Fastify 3](https://github.com/apollographql/apollo-server/issues/6576#issuecomment-1159249244)). [PR #6798](https://github.com/apollographql/apollo-server/pull/6798)
- `apollo-datasource-rest@3.7.0`: Add option `memoizeGetRequests` to disable GET cache [PR #6650](https://github.com/apollographql/apollo-server/pull/6650) and [PR #6834](https://github.com/apollographql/apollo-server/pull/6834)

## v3.10.1

Expand Down
14 changes: 8 additions & 6 deletions packages/apollo-server-fastify/src/ApolloServer.ts
Expand Up @@ -56,12 +56,12 @@ export class ApolloServer<
if (onHealthCheck) {
try {
await onHealthCheck(request);
reply.send('{"status":"pass"}');
return reply.send('{"status":"pass"}');
} catch (e) {
reply.status(503).send('{"status":"fail"}');
return reply.status(503).send('{"status":"fail"}');
}
} else {
reply.send('{"status":"pass"}');
return reply.send('{"status":"pass"}');
}
});
}
Expand Down Expand Up @@ -94,9 +94,11 @@ export class ApolloServer<

if (prefersHtml) {
reply.type('text/html');
reply.send(landingPage.html);
return reply.send(landingPage.html);
}
}

return undefined;
}
: undefined;

Expand Down Expand Up @@ -129,7 +131,7 @@ export class ApolloServer<
}
reply.status(responseInit.status || 200);
reply.serializer((payload: string) => payload);
reply.send(graphqlResponse);
return reply.send(graphqlResponse);
} catch (error) {
if (!isHttpQueryError(error)) {
throw error;
Expand All @@ -143,7 +145,7 @@ export class ApolloServer<

reply.code(error.statusCode);
reply.serializer((payload: string) => payload);
reply.send(error.message);
return reply.send(error.message);
}
},
});
Expand Down