Skip to content

Commit

Permalink
Minor edits to match spec text
Browse files Browse the repository at this point in the history
  • Loading branch information
leebyron committed Apr 18, 2018
1 parent e38d042 commit 4c17d15
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/validation/rules/VariablesInAllowedPosition.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function VariablesInAllowedPosition(
const varType = typeFromAST(schema, varDef.type);
if (
varType &&
!allowedInPosition(
!allowedVariableUsage(
schema,
varType,
varDef.defaultValue,
Expand All @@ -84,26 +84,26 @@ export function VariablesInAllowedPosition(
}

/**
* Returns true if the variable is allowed in the position it was found,
* Returns true if the variable is allowed in the location it was found,
* which includes considering if default values exist for either the variable
* or the location at which it is located.
*/
function allowedInPosition(
function allowedVariableUsage(
schema: GraphQLSchema,
varType: GraphQLType,
varDefaultValue: ?ValueNode,
locationType: GraphQLType,
locationDefaultValue: ?mixed,
): boolean {
if (isNonNullType(locationType) && !isNonNullType(varType)) {
const hasLocationDefaultValue = locationDefaultValue !== undefined;
const hasNonNullVariableDefaultValue =
varDefaultValue && varDefaultValue.kind !== Kind.NULL;
if (!hasLocationDefaultValue && !hasNonNullVariableDefaultValue) {
const hasLocationDefaultValue = locationDefaultValue !== undefined;
if (!hasNonNullVariableDefaultValue && !hasLocationDefaultValue) {
return false;
}
const locationNullableType = locationType.ofType;
return isTypeSubTypeOf(schema, varType, locationNullableType);
const nullableLocationType = locationType.ofType;
return isTypeSubTypeOf(schema, varType, nullableLocationType);
}
return isTypeSubTypeOf(schema, varType, locationType);
}

0 comments on commit 4c17d15

Please sign in to comment.