GraphQL\Validator\Messages::requiredSubselectionMessage PHP Method

requiredSubselectionMessage() static public method

static public requiredSubselectionMessage ( $field, $type )
    static function requiredSubselectionMessage($field, $type)
    {
        return "Field \"{$field}\" of type {$type} must have a sub selection.";
    }

Usage Example

Example #1
0
 public function __invoke(ValidationContext $context)
 {
     return [Node::FIELD => function (Field $node) use($context) {
         $type = $context->getType();
         if ($type) {
             if (Type::isLeafType($type)) {
                 if ($node->selectionSet) {
                     return new Error(Messages::noSubselectionAllowedMessage($node->name->value, $type), [$node->selectionSet]);
                 }
             } else {
                 if (!$node->selectionSet) {
                     return new Error(Messages::requiredSubselectionMessage($node->name->value, $type), [$node]);
                 }
             }
         }
     }];
 }
All Usage Examples Of GraphQL\Validator\Messages::requiredSubselectionMessage