From 4c9619302740a52d2160afd69cac6c3b79185479 Mon Sep 17 00:00:00 2001 From: Vladimir Razuvaev Date: Tue, 4 Jul 2017 13:17:09 +0700 Subject: [PATCH] Fix: isLeafType should not return true for ListOfType and NonNull wrappers --- src/Type/Definition/Type.php | 3 +-- src/Validator/Rules/ScalarLeafs.php | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Type/Definition/Type.php b/src/Type/Definition/Type.php index c4d07fc..69a3789 100644 --- a/src/Type/Definition/Type.php +++ b/src/Type/Definition/Type.php @@ -138,8 +138,7 @@ abstract class Type implements \JsonSerializable */ public static function isLeafType($type) { - $nakedType = self::getNamedType($type); - return $nakedType instanceof LeafType; + return $type instanceof LeafType; } /** diff --git a/src/Validator/Rules/ScalarLeafs.php b/src/Validator/Rules/ScalarLeafs.php index 6da1723..de1f7d6 100644 --- a/src/Validator/Rules/ScalarLeafs.php +++ b/src/Validator/Rules/ScalarLeafs.php @@ -25,7 +25,7 @@ class ScalarLeafs NodeKind::FIELD => function(FieldNode $node) use ($context) { $type = $context->getType(); if ($type) { - if (Type::isLeafType($type)) { + if (Type::isLeafType(Type::getNamedType($type))) { if ($node->selectionSet) { $context->reportError(new Error( self::noSubselectionAllowedMessage($node->name->value, $type),