GraphQL\Type\Definition\Type::getNamedType PHP Метод

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

public static getNamedType ( $type ) : UnmodifiedType
$type
Результат UnmodifiedType
    public static function getNamedType($type)
    {
        if (null === $type) {
            return null;
        }
        while ($type instanceof WrappingType) {
            $type = $type->getWrappedType();
        }
        return self::resolve($type);
    }

Usage Example

 public function __invoke(ValidationContext $context)
 {
     return [Node::INLINE_FRAGMENT => function (InlineFragment $node) use($context) {
         $fragType = Type::getNamedType($context->getType());
         $parentType = $context->getParentType();
         if ($fragType && $parentType && !$this->doTypesOverlap($fragType, $parentType)) {
             return new Error(self::typeIncompatibleAnonSpreadMessage($parentType, $fragType), [$node]);
         }
     }, Node::FRAGMENT_SPREAD => function (FragmentSpread $node) use($context) {
         $fragName = $node->name->value;
         $fragType = Type::getNamedType($this->getFragmentType($context, $fragName));
         $parentType = $context->getParentType();
         if ($fragType && $parentType && !$this->doTypesOverlap($fragType, $parentType)) {
             return new Error(self::typeIncompatibleSpreadMessage($fragName, $parentType, $fragType), [$node]);
         }
     }];
 }
All Usage Examples Of GraphQL\Type\Definition\Type::getNamedType