src/Executor/ReferenceExecutor.php
private function ensureValidRuntimeType(
        $runtimeTypeOrName,
        AbstractType $returnType,
        ResolveInfo $info,
        &$result
    ) {
        $runtimeType = is_string($runtimeTypeOrName) ?
            $this->exeContext->schema->getType($runtimeTypeOrName) :
            $runtimeTypeOrName;
        if (! $runtimeType instanceof ObjectType) {
            throw new InvariantViolation(
                sprintf(
                    'Abstract type %s must resolve to an Object type at ' .
                    'runtime for field %s.%s with value "%s", received "%s". ' .
                    'Either the %s type should provide a "resolveType" ' .
                    'function or each possible type should provide an "isTypeOf" function.',
                    $returnType,
                    $info->parentType,
                    $info->fieldName,
                    Utils::printSafe($result),
                    Utils::printSafe($runtimeType),
                    $returnType
                )
            );
        }
        if (! $this->exeContext->schema->isPossibleType($returnType, $runtimeType)) {
            throw new InvariantViolation(
                sprintf('Runtime Object type "%s" is not a possible type for "%s".', $runtimeType, $returnType)
            );
        }
        if ($runtimeType !== $this->exeContext->schema->getType($runtimeType->name)) {
            throw new InvariantViolation(
                sprintf(
                    'Schema must contain unique named types but contains multiple types named "%s". ' .
                    'Make sure that `resolveType` function of abstract type "%s" returns the same ' .
                    'type instance as referenced anywhere else within the schema ' .
                    '(see http://webonyx.github.io/graphql-php/type-system/#type-registry).',
                    $runtimeType,
                    $returnType
                )
            );
        }

        return $runtimeType;
    }
private function ensureValidRuntimeType(
        $runtimeTypeOrName,
        AbstractType $returnType,
        ResolveInfo $info,
        &$result
    ) {
        $runtimeType = is_string($runtimeTypeOrName) ?
            $this->exeContext->schema->getType($runtimeTypeOrName) :
            $runtimeTypeOrName;
        if (! $runtimeType instanceof ObjectType) {
            throw new InvariantViolation(
                sprintf(
                    'Abstract type %s must resolve to an Object type at ' .
                    'runtime for field %s.%s with value "%s", received "%s". ' .
                    'Either the %s type should provide a "resolveType" ' .
                    'function or each possible type should provide an "isTypeOf" function.',
                    $returnType,
                    $info->parentType,
                    $info->fieldName,
                    Utils::printSafe($result),
                    Utils::printSafe($runtimeType),
                    $returnType
                )
            );
        }
        if (! $this->exeContext->schema->isPossibleType($returnType, $runtimeType)) {
            throw new InvariantViolation(
                sprintf('Runtime Object type "%s" is not a possible type for "%s".', $runtimeType, $returnType)
            );
        }
        if ($runtimeType !== $this->exeContext->schema->getType($runtimeType->name)) {
            throw new InvariantViolation(
                sprintf(
                    'Schema must contain unique named types but contains multiple types named "%s". ' .
                    'Make sure that `resolveType` function of abstract type "%s" returns the same ' .
                    'type instance as referenced anywhere else within the schema ' .
                    '(see http://webonyx.github.io/graphql-php/type-system/#type-registry).',
                    $runtimeType,
                    $returnType
                )
            );
        }

        return $runtimeType;
    }
private function ensureValidRuntimeType ( $ runtimeTypeOrName , AbstractType $ returnType , ResolveInfo $ info , & $ result ) { $ runtimeType = is_string ( $ runtimeTypeOrName ) ? $ this -> exeContext -> schema -> getType ( $ runtimeTypeOrName ) : $ runtimeTypeOrName ; if ( ! $ runtimeType instanceof ObjectType ) { throw new InvariantViolation ( sprintf ( 'Abstract type %s must resolve to an Object type at ' . 'runtime for field %s.%s with value "%s", received "%s". ' . 'Either the %s type should provide a "resolveType" ' . 'function or each possible type should provide an "isTypeOf" function.' , $ returnType , $ info -> parentType , $ info -> fieldName , Utils :: printSafe ( $ result ) , Utils :: printSafe ( $ runtimeType ) , $ returnType ) ) ; } if ( ! $ this -> exeContext -> schema -> isPossibleType ( $ returnType , $ runtimeType ) ) { throw new InvariantViolation ( sprintf ( 'Runtime Object type "%s" is not a possible type for "%s".' , $ runtimeType , $ returnType ) ) ; } if ( $ runtimeType !== $ this -> exeContext -> schema -> getType ( $ runtimeType -> name ) ) { throw new InvariantViolation ( sprintf ( 'Schema must contain unique named types but contains multiple types named "%s". ' . 'Make sure that `resolveType` function of abstract type "%s" returns the same ' . 'type instance as referenced anywhere else within the schema ' . '(see http://webonyx.github.io/graphql-php/type-system/#type-registry).' , $ runtimeType , $ returnType ) ) ; } return $ runtimeType ; }
@param string|ObjectType|null $runtimeTypeOrName
@param FieldNode[]            $fieldNodes
@param mixed                  $result

@return ObjectType
@param string|ObjectType|null $runtimeTypeOrName @param FieldNode [] $fieldNodes @param mixed $result