GraphQL\Validator\Messages::fragmentOnNonCompositeErrorMessage PHP Метод

fragmentOnNonCompositeErrorMessage() статический публичный Метод

static public fragmentOnNonCompositeErrorMessage ( $fragName, $typeName )
    static function fragmentOnNonCompositeErrorMessage($fragName, $typeName)
    {
        return "Fragment {$fragName} cannot condition on non composite type \"{$typeName}\".";
    }

Usage Example

 public function __invoke(ValidationContext $context)
 {
     return [Node::INLINE_FRAGMENT => function (InlineFragment $node) use($context) {
         $typeName = $node->typeCondition->value;
         $type = $context->getSchema()->getType($typeName);
         $isCompositeType = $type instanceof CompositeType;
         if (!$isCompositeType) {
             return new Error("Fragment cannot condition on non composite type \"{$typeName}\".", [$node->typeCondition]);
         }
     }, Node::FRAGMENT_DEFINITION => function (FragmentDefinition $node) use($context) {
         $typeName = $node->typeCondition->value;
         $type = $context->getSchema()->getType($typeName);
         $isCompositeType = $type instanceof CompositeType;
         if (!$isCompositeType) {
             return new Error(Messages::fragmentOnNonCompositeErrorMessage($node->name->value, $typeName), [$node->typeCondition]);
         }
     }];
 }
All Usage Examples Of GraphQL\Validator\Messages::fragmentOnNonCompositeErrorMessage