Skip to content

Use consistent naming for config arguments #2147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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