static public fragmentOnNonCompositeErrorMessage ( $fragName, $typeName ) |
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]); } }]; }
private function error($fragName, $typeName, $line, $column) { return new FormattedError(Messages::fragmentOnNonCompositeErrorMessage($fragName, $typeName), [new SourceLocation($line, $column)]); }