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

Fully replace 'ApolloError' with 'GraphQLError' #6355

Merged
Merged
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
34 changes: 34 additions & 0 deletions packages/server/src/__tests__/integration/apolloServerTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1774,6 +1774,40 @@ export function defineIntegrationTestSuiteApolloServerTests(
expect(result.errors[0].extensions.exception).toBeDefined();
expect(result.errors[0].extensions.exception.stacktrace).toBeDefined();
});

it('shows error extensions in extensions (only!)', async () => {
const uri = await createServerAndGetUrl({
typeDefs: gql`
type Query {
fieldWhichWillError: String
}
`,
resolvers: {
Query: {
fieldWhichWillError: () => {
throw new AuthenticationError('Some message', {
extensions: { ext1: 'myExt' },
});
},
},
},
stopOnTerminationSignals: false,
nodeEnv: 'development',
});

const apolloFetch = createApolloFetch({ uri });

const result = await apolloFetch({ query: `{fieldWhichWillError}` });
expect(result.data).toEqual({ fieldWhichWillError: null });

expect(result.errors).toBeDefined();
expect(result.errors.length).toEqual(1);
expect(result.errors[0].message).toEqual('Some message');
expect(result.errors[0].extensions.code).toEqual('UNAUTHENTICATED');
expect(result.errors[0].extensions.ext1).toEqual('myExt');
expect(result.errors[0].extensions.exception).toBeDefined();
expect(result.errors[0].extensions.exception.ext1).toBeUndefined();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we also check result.errors[0].extensions.exception.extensions is undefined? basically we want to make sure it isn't there twice. (Or we could just do an inline snapshot on result tbh)

});
});

describe('Persisted Queries', () => {
Expand Down