Skip to content

Commit 5f1c58d

Browse files
fix(apollo): include original error (response) to avoid more breaking changes
1 parent 992af74 commit 5f1c58d

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

packages/apollo/lib/drivers/apollo-base.driver.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,9 @@ export abstract class ApolloBaseDriver<
241241
},
242242
});
243243
}
244-
244+
if (exceptionRef?.response) {
245+
error.extensions['originalError'] = exceptionRef.response;
246+
}
245247
(error as any).locations = formattedError.locations;
246248
return error;
247249
};

packages/apollo/tests/e2e/guards-filters.spec.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,13 @@ describe('GraphQL - Guards', () => {
2929
message: 'Unauthorized error',
3030
locations: [{ line: 2, column: 3 }],
3131
path: ['recipe'],
32-
extensions: { code: 'UNAUTHENTICATED' },
32+
extensions: {
33+
code: 'UNAUTHENTICATED',
34+
originalError: {
35+
statusCode: 401,
36+
message: 'Unauthorized',
37+
},
38+
},
3339
},
3440
],
3541
data: null,

packages/apollo/tests/e2e/pipes.spec.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,16 @@ describe('GraphQL - Pipes', () => {
3232
message: 'Bad Request Exception',
3333
locations: [{ line: 2, column: 3 }],
3434
path: ['addRecipe'],
35-
extensions: { code: 'BAD_REQUEST' },
35+
extensions: {
36+
code: 'BAD_REQUEST',
37+
originalError: {
38+
statusCode: 400,
39+
message: [
40+
'description must be longer than or equal to 30 characters',
41+
],
42+
error: 'Bad Request',
43+
},
44+
},
3645
},
3746
],
3847
});

0 commit comments

Comments
 (0)