Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed Nov 2, 2021
1 parent 4b6d332 commit 24cfc64
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ The version headers in this history reflect the versions of Apollo Server itself
-聽`apollo-server-core`: Fix build error when building with `@rollup/plugin-commonjs`. [PR #5797](https://github.com/apollographql/apollo-server/pull/5797)
- `apollo-server-plugin-response-cache`: Add missing dependency on `apollo-server-types` (broken since v3.0.0). [Issue #5804](https://github.com/apollographql/apollo-server/issues/5804) [PR #5816](https://github.com/apollographql/apollo-server/pull/5816)
- `apollo-server-core`: The default landing page plugins now take `document`, `variables`, and `headers` arguments which fill in default values if you click through to Explorer. [PR #5711](https://github.com/apollographql/apollo-server/pull/5711)
- Apollo Server can now be installed with `graphql@16` without causing peer dependency errors or warnings. [PR #5857](https://github.com/apollographql/apollo-server/pull/5857)

## v3.4.0

Expand Down
14 changes: 14 additions & 0 deletions packages/apollo-server-errors/src/__tests__/ApolloError.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@ describe('ApolloError', () => {
}),
).toThrow(/Pass extensions directly/);
});

it('provides toJSON method', () => {
const error = new ApolloError('My original message', 'A_CODE', {
arbitrary: 'user_data',
});

expect(error.toJSON()).toEqual({
message: 'My original message',
extensions: {
code: 'A_CODE',
arbitrary: 'user_data',
},
});
});
});

describe('ForbiddenError', () => {
Expand Down
4 changes: 3 additions & 1 deletion packages/apollo-server-errors/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ declare module 'graphql' {
}
}

// Note: We'd like to switch to `extends GraphQLError` and look forward to doing so
// as soon as we drop support for `graphql` bellow `v15.7.0`.
export class ApolloError extends Error implements GraphQLError {
public extensions: Record<string, any>;
override readonly name!: string;
Expand Down Expand Up @@ -165,7 +167,7 @@ export function fromGraphQLError(error: GraphQLError, options?: ErrorOptions) {
// copy enumerable keys
Object.entries(error).forEach(([key, value]) => {
if (key === 'extensions') {
return; // extensions are handeled bellow
return; // extensions are handled bellow
}
copy[key] = value;
});
Expand Down

0 comments on commit 24cfc64

Please sign in to comment.