Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b7fdcd9

Browse files
committed
Rename ctorData to ctorConfig
Summary: Previously, ctorData is accessing all the attributes listed in ErrorConfig so it should be define as ErrorConfig instance and renamed as ctorConfig. The common use case will bind the first 2 arguments of ApolloError.constructor() to name and a common configuration object, leaving the ctorConfig to provide the final customization. We make sure that ctorConfig take precedence over config and merge them whenever necessary.
1 parent d57470d commit b7fdcd9

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

‎src/index.ts‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,17 @@ export class ApolloError extends ExtendableError {
3636
// NOTE: The object passed to the Constructor is actually `ctorData`.
3737
// We are binding the constructor to the name and config object
3838
// for the first two parameters inside of `createError`
39-
constructor(name: string, config: ErrorConfig, ctorData: any) {
40-
super((ctorData && ctorData.message) || '');
41-
42-
const t = (ctorData && ctorData.time_thrown) || (new Date()).toISOString();
43-
const m = (ctorData && ctorData.message) || '';
44-
const configData = (ctorData && ctorData.data) || {};
45-
const d = { ...this.data, ...configData };
46-
const opts = ((ctorData && ctorData.options) || {});
39+
constructor(name: string, config: ErrorConfig, ctorConfig: ErrorConfig) {
40+
super((ctorConfig && ctorConfig.message) || (config && config.message) || '');
41+
42+
const t = (ctorConfig && ctorConfig.time_thrown) || (config && config.time_thrown) || (new Date()).toISOString();
43+
const m = (ctorConfig && ctorConfig.message) || (config && config.message) || '';
44+
const ctorData = (ctorConfig && ctorConfig.data) || {};
45+
const configData = (config && config.data) || {};
46+
const d = { ...this.data, ...configData, ...ctorData };
47+
const ctorOptions = (ctorConfig && ctorConfig.options) || {};
48+
const configOptions = (config && config.options) || {};
49+
const opts = { ...configOptions, ...ctorOptions };
4750

4851

4952
this.name = name;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /