Skip to content

Commit 47a8e67

Browse files
Merge pull request #35 from lxcid/lxcid/spec-compliant
Make serialized error spec compliant
2 parents d57470d + c3d938a commit 47a8e67

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/index.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ export interface ErrorConfig {
1616

1717
export interface ErrorInfo {
1818
message: string;
19-
name: string;
20-
time_thrown: string;
21-
data?: object;
2219
path?: string;
2320
locations?: any;
21+
extensions?: {
22+
name: string;
23+
time_thrown: string;
24+
data?: object;
25+
};
2426
}
2527

2628
export class ApolloError extends ExtendableError {
@@ -59,11 +61,13 @@ export class ApolloError extends ExtendableError {
5961

6062
let error: ErrorInfo = {
6163
message,
62-
name,
63-
time_thrown,
64-
data,
6564
path,
66-
locations
65+
locations,
66+
extensions: {
67+
name,
68+
time_thrown,
69+
data
70+
}
6771
};
6872

6973
if (_showLocations) {

test/spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe('createError', () => {
3131
},
3232
});
3333

34-
const { message, name, time_thrown, data } = e.serialize();
34+
const { message, extensions: { name, time_thrown, data } } = e.serialize();
3535
expect(message).to.equal('A foo 2.0 error has occurred');
3636
expect(name).to.equal('FooError');
3737
expect(time_thrown).to.equal(e.time_thrown);

0 commit comments

Comments
 (0)