File tree Expand file tree Collapse file tree 2 files changed +27
-34
lines changed Expand file tree Collapse file tree 2 files changed +27
-34
lines changed Original file line number Diff line number Diff line change @@ -728,23 +728,20 @@ function defineFieldMap<TSource, TContext>(
728
728
`${config . name } . ${fieldName } field resolver must be a function if ` +
729
729
`provided , but got : ${inspect ( field . resolve ) } . `,
730
730
);
731
- const argsConfig = fieldConfig.args;
732
- if (!argsConfig) {
733
- field.args = [];
734
- } else {
735
- invariant(
736
- isPlainObj(argsConfig),
737
- ` $ { config . name } . $ { fieldName } args must be an object with argument ` +
738
- 'names as keys.',
739
- );
740
- field.args = objectEntries(argsConfig).map(([argName, arg]) => ({
741
- name: argName,
742
- description: arg.description === undefined ? null : arg.description,
743
- type: arg.type,
744
- defaultValue: arg.defaultValue,
745
- astNode: arg.astNode,
746
- }));
747
- }
731
+ const argsConfig = fieldConfig.args || {};
732
+ invariant(
733
+ isPlainObj(argsConfig),
734
+ ` $ { config . name } . $ { fieldName } args must be an object with argument ` +
735
+ 'names as keys.',
736
+ );
737
+
738
+ field.args = objectEntries(argsConfig).map(([argName, arg]) => ({
739
+ name: argName,
740
+ description: arg.description === undefined ? null : arg.description,
741
+ type: arg.type,
742
+ defaultValue: arg.defaultValue,
743
+ astNode: arg.astNode,
744
+ }));
748
745
resultFieldMap[fieldName] = field;
749
746
}
750
747
return resultFieldMap;
Original file line number Diff line number Diff line change @@ -66,23 +66,19 @@ export class GraphQLDirective {
66
66
'Must provide locations for directive.' ,
67
67
) ;
68
68
69
- const args = config . args ;
70
- if ( ! args ) {
71
- this . args = [ ] ;
72
- } else {
73
- invariant (
74
- ! Array . isArray ( args ) ,
75
- `@${ config . name } args must be an object with argument names as keys.` ,
76
- ) ;
77
-
78
- this . args = objectEntries ( args ) . map ( ( [ argName , arg ] ) => ( {
79
- name : argName ,
80
- description : arg . description === undefined ? null : arg . description ,
81
- type : arg . type ,
82
- defaultValue : arg . defaultValue ,
83
- astNode : arg . astNode ,
84
- } ) ) ;
85
- }
69
+ const args = config . args || { } ;
70
+ invariant (
71
+ ! Array . isArray ( args ) ,
72
+ `@${ config . name } args must be an object with argument names as keys.` ,
73
+ ) ;
74
+
75
+ this . args = objectEntries ( args ) . map ( ( [ argName , arg ] ) => ( {
76
+ name : argName ,
77
+ description : arg . description === undefined ? null : arg . description ,
78
+ type : arg . type ,
79
+ defaultValue : arg . defaultValue ,
80
+ astNode : arg . astNode ,
81
+ } ) ) ;
86
82
}
87
83
88
84
toString ( ) : string {
You can’t perform that action at this time.
0 commit comments