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

apollo-engine-reporting: don't fail if errors have non-array 'path' #3112

Merged
merged 2 commits into from
Jul 31, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The version headers in this history reflect the versions of Apollo Server itself

> The changes noted within this `vNEXT` section have not been released yet. New PRs and commits which introduce changes should include an entry in this `vNEXT` section as part of their development. When a release is being prepared, a new header will be (manually) created below and the the appropriate changes within that release will be moved into the new section.

- `apollo-engine-reporting`: Fix reporting errors which have non-array `path` fields (eg, non-GraphQLError errors). [PR #3112](https://github.com/apollographql/apollo-server/pull/3112)
- `apollo-engine-reporting`: Add missing `apollo-server-caching` dependency. [PR #3054](https://github.com/apollographql/apollo-server/pull/3054)
- `apollo-server-hapi`: Revert switch from `accept` and `boom` which took place in v2.8.0. [PR #3089](https://github.com/apollographql/apollo-server/pull/3089)
- `@apollo/gateway`: Change the `setInterval` timer, which is used to continuously check for updates to a federated graph from the Apollo Graph Manager, to be an `unref`'d timer. Without this change, the server wouldn't terminate properly once polling had started since the event-loop would continue to have unprocessed events on it. [PR #3105](https://github.com/apollographql/apollo-server/pull/3105)
Expand Down
4 changes: 3 additions & 1 deletion packages/apollo-engine-reporting/src/treeBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ export class EngineReportingTreeBuilder {

// By default, put errors on the root node.
let node = this.rootNode;
if (path) {
// If a non-GraphQLError Error sneaks in here somehow with a non-array
// path, don't crash.
if (path && Array.isArray(path)) {
const specificNode = this.nodes.get(path.join('.'));
if (specificNode) {
node = specificNode;
Expand Down
5 changes: 5 additions & 0 deletions packages/apollo-gateway/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,11 @@ export class ApolloGateway implements GraphQLService {
});
}

// XXX Nothing guarantees that the only errors thrown or returned in
// result.errors are GraphQLErrors, even though other code (eg
// apollo-engine-reporting) assumes that. In fact, errors talking to backends
// are unlikely to show up as GraphQLErrors. Do we need to use
// formatApolloErrors or something?
public executor = async <TContext>(
requestContext: WithRequired<
GraphQLRequestContext<TContext>,
Expand Down
3 changes: 3 additions & 0 deletions packages/apollo-server-core/src/requestPipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,9 @@ export async function processGraphQLRequest<TContext>(

try {
if (config.executor) {
// XXX Nothing guarantees that the only errors thrown or returned
// in result.errors are GraphQLErrors, even though other code
// (eg apollo-engine-reporting) assumes that.
return await config.executor(requestContext);
} else {
return await graphql.execute(executionArgs);
Expand Down