GraphQL\Validator\Rules\FragmentsOnCompositeTypes::__invoke PHP Method

__invoke() public method

public __invoke ( ValidationContext $context )
$context GraphQL\Validator\ValidationContext
    public function __invoke(ValidationContext $context)
    {
        return [NodeKind::INLINE_FRAGMENT => function (InlineFragmentNode $node) use($context) {
            $type = $context->getType();
            if ($node->typeCondition && $type && !Type::isCompositeType($type)) {
                $context->reportError(new Error(static::inlineFragmentOnNonCompositeErrorMessage($type), [$node->typeCondition]));
            }
        }, NodeKind::FRAGMENT_DEFINITION => function (FragmentDefinitionNode $node) use($context) {
            $type = $context->getType();
            if ($type && !Type::isCompositeType($type)) {
                $context->reportError(new Error(static::fragmentOnNonCompositeErrorMessage($node->name->value, Printer::doPrint($node->typeCondition)), [$node->typeCondition]));
            }
        }];
    }