Automattic\WooCommerce\Vendor\GraphQL\Executor
ReferenceExecutor::ensureValidRuntimeType
Метод класса: ReferenceExecutor{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->ensureValidRuntimeType( $runtimeTypeOrName, $returnType, $info, $result ): ObjectType;
- $runtimeTypeOrName(разное) (обязательный)
- .
- $returnType(AbstractType&Type) (обязательный)
- .
- $info(ResolveInfo) (обязательный)
- .
- $result(разное) (обязательный)
- .
Код ReferenceExecutor::ensureValidRuntimeType() ReferenceExecutor::ensureValidRuntimeType WC 11.1.0
protected function ensureValidRuntimeType(
$runtimeTypeOrName,
AbstractType $returnType,
ResolveInfo $info,
$result
): ObjectType {
$runtimeType = is_string($runtimeTypeOrName)
? $this->exeContext->schema->getType($runtimeTypeOrName)
: $runtimeTypeOrName;
if (! $runtimeType instanceof ObjectType) {
$safeResult = Utils::printSafe($result);
$notObjectType = Utils::printSafe($runtimeType);
throw new InvariantViolation("Abstract type {$returnType} must resolve to an Object type at runtime for field {$info->parentType}.{$info->fieldName} with value {$safeResult}, received \"{$notObjectType}\". Either the {$returnType} type should provide a \"resolveType\" function or each possible type should provide an \"isTypeOf\" function.");
}
if (! $this->exeContext->schema->isSubType($returnType, $runtimeType)) {
throw new InvariantViolation("Runtime Object type \"{$runtimeType}\" is not a possible type for \"{$returnType}\".");
}
assert(
$this->exeContext->schema->getType($runtimeType->name) !== null,
"Schema does not contain type \"{$runtimeType}\". This can happen when an object type is only referenced indirectly through abstract types and never directly through fields.List the type in the option \"types\" during schema construction, see https://webonyx.github.io/graphql-php/schema-definition/#configuration-options."
);
assert(
$runtimeType === $this->exeContext->schema->getType($runtimeType->name),
"Schema must contain unique named types but contains multiple types named \"{$runtimeType}\". Make sure that `resolveType` function of abstract type \"{$returnType}\" returns the same type instance as referenced anywhere else within the schema (see https://webonyx.github.io/graphql-php/type-definitions/#type-registry)."
);
return $runtimeType;
}