Skip to content

Commit

Permalink
Use consistent naming for config arguments (#2147)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed Sep 15, 2019
1 parent bd0c240 commit 124ec0b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
32 changes: 16 additions & 16 deletions src/type/definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -781,13 +781,13 @@ function defineFieldMap<TSource, TContext>(
`${config.name}.${fieldName} args must be an object with argument names as keys.`,
);
const args = objectEntries(argsConfig).map(([argName, arg]) => ({
const args = objectEntries(argsConfig).map(([argName, argConfig]) => ({
name: argName,
description: arg.description,
type: arg.type,
defaultValue: arg.defaultValue,
extensions: arg.extensions && toObjMap(arg.extensions),
astNode: arg.astNode,
description: argConfig.description,
type: argConfig.type,
defaultValue: argConfig.defaultValue,
extensions: argConfig.extensions && toObjMap(argConfig.extensions),
astNode: argConfig.astNode,
}));
return {
Expand Down Expand Up @@ -1277,24 +1277,24 @@ function defineEnumValues(
isPlainObj(valueMap),
`${typeName} values must be an object with value names as keys.`,
);
return objectEntries(valueMap).map(([valueName, value]) => {
return objectEntries(valueMap).map(([valueName, valueConfig]) => {
devAssert(
isPlainObj(value),
isPlainObj(valueConfig),
`${typeName}.${valueName} must refer to an object with a "value" key ` +
`representing an internal value but got: ${inspect(value)}.`,
`representing an internal value but got: ${inspect(valueConfig)}.`,
);
devAssert(
!('isDeprecated' in value),
!('isDeprecated' in valueConfig),
`${typeName}.${valueName} should provide "deprecationReason" instead of "isDeprecated".`,
);
return {
name: valueName,
description: value.description,
value: 'value' in value ? value.value : valueName,
isDeprecated: Boolean(value.deprecationReason),
deprecationReason: value.deprecationReason,
extensions: value.extensions && toObjMap(value.extensions),
astNode: value.astNode,
description: valueConfig.description,
value: 'value' in valueConfig ? valueConfig.value : valueName,
isDeprecated: Boolean(valueConfig.deprecationReason),
deprecationReason: valueConfig.deprecationReason,
extensions: valueConfig.extensions && toObjMap(valueConfig.extensions),
astNode: valueConfig.astNode,
};
});
}
Expand Down
12 changes: 6 additions & 6 deletions src/type/directives.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ export class GraphQLDirective {
`@${config.name} args must be an object with argument names as keys.`,
);

this.args = objectEntries(args).map(([argName, arg]) => ({
this.args = objectEntries(args).map(([argName, argConfig]) => ({
name: argName,
description: arg.description,
type: arg.type,
defaultValue: arg.defaultValue,
extensions: arg.extensions && toObjMap(arg.extensions),
astNode: arg.astNode,
description: argConfig.description,
type: argConfig.type,
defaultValue: argConfig.defaultValue,
extensions: argConfig.extensions && toObjMap(argConfig.extensions),
astNode: argConfig.astNode,
}));
}

Expand Down

0 comments on commit 124ec0b

Please sign in to comment.