Skip to content

Commit 9d4ca8b

Browse files
committed
fixes for wrong data being returned in errors
1 parent f8c0b8c commit 9d4ca8b

File tree

4 files changed

+37
-9
lines changed

4 files changed

+37
-9
lines changed

dist/index.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export declare class ApolloError extends ExtendableError {
2525
locations: any;
2626
_showLocations: boolean;
2727
_showPath: boolean;
28-
constructor(name: string, config: ErrorConfig, ctorData: any);
28+
constructor(name: string, config: ErrorConfig, ctorConfig: ErrorConfig);
2929
serialize(): ErrorInfo;
3030
}
3131
export declare const isInstance: (e: any) => boolean;

dist/index.js

+16-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/spec.js

+19
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,25 @@ describe('createError', () => {
4040
foo: 'bar'
4141
});
4242
});
43+
it('uses original message and merges original data', () => {
44+
const FooError = createError('FooError', {
45+
message: 'A foo error has occurred',
46+
data: {
47+
hello: 'world'
48+
},
49+
options: {
50+
showLocations: false,
51+
showPath: true
52+
}
53+
});
54+
const e = new FooError({data: {foo: 'bar'}});
55+
56+
const { message, name, time_thrown, data } = e.serialize();
57+
expect(message).to.equal('A foo error has occurred');
58+
expect(name).to.equal('FooError');
59+
expect(time_thrown).to.equal(e.time_thrown);
60+
expect(data).to.eql({ hello: 'world', foo: 'bar' });
61+
});
4362
});
4463
context('when missing a config as the second parameter', () => {
4564
it('throws an assertion error with a useful message', () => {

0 commit comments

Comments
 (0)