function(FieldNode $node) use ($context) { $type = $context->getType(); if ($type) { if (Type::isLeafType(Type::getNamedType($type))) { if ($node->selectionSet) { $context->reportError(new Error( self::noSubselectionAllowedMessage($node->name->value, $type), [$node->selectionSet] )); } } else if (!$node->selectionSet) { $context->reportError(new Error( self::requiredSubselectionMessage($node->name->value, $type), [$node] )); } } } ]; } }