Skip to content

Commit

Permalink
introspection: use consistent naming for 'resolve' args (#2418)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov authored Jan 30, 2020
1 parent 9d9f606 commit d680d07
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions src/type/introspection.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,19 @@ export const __Directive = new GraphQLObjectType({
({
name: {
type: GraphQLNonNull(GraphQLString),
resolve: obj => obj.name,
resolve: directive => directive.name,
},
description: {
type: GraphQLString,
resolve: obj => obj.description,
resolve: directive => directive.description,
},
isRepeatable: {
type: GraphQLNonNull(GraphQLBoolean),
resolve: obj => obj.isRepeatable,
resolve: directive => directive.isRepeatable,
},
locations: {
type: GraphQLNonNull(GraphQLList(GraphQLNonNull(__DirectiveLocation))),
resolve: obj => obj.locations,
resolve: directive => directive.locations,
},
args: {
type: GraphQLNonNull(GraphQLList(GraphQLNonNull(__InputValue))),
Expand Down Expand Up @@ -228,12 +228,12 @@ export const __Type = new GraphQLObjectType({
},
name: {
type: GraphQLString,
resolve: obj => (obj.name !== undefined ? obj.name : undefined),
resolve: type => (type.name !== undefined ? type.name : undefined),
},
description: {
type: GraphQLString,
resolve: obj =>
obj.description !== undefined ? obj.description : undefined,
resolve: type =>
type.description !== undefined ? type.description : undefined,
},
fields: {
type: GraphQLList(GraphQLNonNull(__Field)),
Expand Down Expand Up @@ -292,7 +292,7 @@ export const __Type = new GraphQLObjectType({
},
ofType: {
type: __Type,
resolve: obj => (obj.ofType !== undefined ? obj.ofType : undefined),
resolve: type => (type.ofType !== undefined ? type.ofType : undefined),
},
}: GraphQLFieldConfigMap<GraphQLType, mixed>),
});
Expand All @@ -305,27 +305,27 @@ export const __Field = new GraphQLObjectType({
({
name: {
type: GraphQLNonNull(GraphQLString),
resolve: obj => obj.name,
resolve: field => field.name,
},
description: {
type: GraphQLString,
resolve: obj => obj.description,
resolve: field => field.description,
},
args: {
type: GraphQLNonNull(GraphQLList(GraphQLNonNull(__InputValue))),
resolve: field => field.args,
},
type: {
type: GraphQLNonNull(__Type),
resolve: obj => obj.type,
resolve: field => field.type,
},
isDeprecated: {
type: GraphQLNonNull(GraphQLBoolean),
resolve: obj => obj.isDeprecated,
resolve: field => field.isDeprecated,
},
deprecationReason: {
type: GraphQLString,
resolve: obj => obj.deprecationReason,
resolve: field => field.deprecationReason,
},
}: GraphQLFieldConfigMap<GraphQLField<mixed, mixed>, mixed>),
});
Expand All @@ -338,22 +338,23 @@ export const __InputValue = new GraphQLObjectType({
({
name: {
type: GraphQLNonNull(GraphQLString),
resolve: obj => obj.name,
resolve: inputValue => inputValue.name,
},
description: {
type: GraphQLString,
resolve: obj => obj.description,
resolve: inputValue => inputValue.description,
},
type: {
type: GraphQLNonNull(__Type),
resolve: obj => obj.type,
resolve: inputValue => inputValue.type,
},
defaultValue: {
type: GraphQLString,
description:
'A GraphQL-formatted string representing the default value for this input value.',
resolve(inputVal) {
const valueAST = astFromValue(inputVal.defaultValue, inputVal.type);
resolve(inputValue) {
const { type, defaultValue } = inputValue;
const valueAST = astFromValue(defaultValue, type);
return valueAST ? print(valueAST) : null;
},
},
Expand All @@ -368,19 +369,19 @@ export const __EnumValue = new GraphQLObjectType({
({
name: {
type: GraphQLNonNull(GraphQLString),
resolve: obj => obj.name,
resolve: enumValue => enumValue.name,
},
description: {
type: GraphQLString,
resolve: obj => obj.description,
resolve: enumValue => enumValue.description,
},
isDeprecated: {
type: GraphQLNonNull(GraphQLBoolean),
resolve: obj => obj.isDeprecated,
resolve: enumValue => enumValue.isDeprecated,
},
deprecationReason: {
type: GraphQLString,
resolve: obj => obj.deprecationReason,
resolve: enumValue => enumValue.deprecationReason,
},
}: GraphQLFieldConfigMap<GraphQLEnumValue, mixed>),
});
Expand Down

0 comments on commit d680d07

Please sign in to comment.