Skip to content

Commit

Permalink
Fix: isLeafType matches type definition.
Browse files Browse the repository at this point in the history
This was ambiguous before. Other isCompositeType / isAbstractType checks below do not include named type unwrapping, and it did not match the type definition above. Only one callsite actually relied on named type unwrapping, so moved this check there.
  • Loading branch information
leebyron committed Jan 27, 2017
1 parent 8122ba7 commit 12b2137
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/type/definition.js
Expand Up @@ -135,10 +135,9 @@ export type GraphQLLeafType =
GraphQLEnumType;

export function isLeafType(type: ?GraphQLType): boolean {
const namedType = getNamedType(type);
return (
namedType instanceof GraphQLScalarType ||
namedType instanceof GraphQLEnumType
type instanceof GraphQLScalarType ||
type instanceof GraphQLEnumType
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/validation/rules/ScalarLeafs.js
Expand Up @@ -11,7 +11,7 @@
import type { ValidationContext } from '../index';
import { GraphQLError } from '../../error';
import type { FieldNode } from '../../language/ast';
import { isLeafType } from '../../type/definition';
import { getNamedType, isLeafType } from '../../type/definition';
import type { GraphQLType } from '../../type/definition';


Expand Down Expand Up @@ -42,7 +42,7 @@ export function ScalarLeafs(context: ValidationContext): any {
Field(node: FieldNode) {
const type = context.getType();
if (type) {
if (isLeafType(type)) {
if (isLeafType(getNamedType(type))) {
if (node.selectionSet) {
context.reportError(new GraphQLError(
noSubselectionAllowedMessage(node.name.value, type),
Expand Down

0 comments on commit 12b2137

Please sign in to comment.