Automattic\WooCommerce\Vendor\GraphQL\Type

SchemaValidationContext::validateTypespublicWC 1.0

Method of the class: SchemaValidationContext{}

No Hooks.

Returns

null. Nothing (null).

Usage

$SchemaValidationContext = new SchemaValidationContext();
$SchemaValidationContext->validateTypes(): void;

SchemaValidationContext::validateTypes() code WC 10.9.1

public function validateTypes(): void
{
    $typeMap = $this->schema->getTypeMap();
    foreach ($typeMap as $type) {
        // Ensure all provided types are in fact Automattic\WooCommerce\Vendor\GraphQL type.
        // @phpstan-ignore-next-line The generic type says this should not happen, but a user may use it wrong nonetheless
        if (! $type instanceof NamedType) {
            $notNamedType = Utils::printSafe($type);
            // @phpstan-ignore-next-line The generic type says this should not happen, but a user may use it wrong nonetheless
            $node = $type instanceof Type
                ? $type->astNode
                : null;

            $this->reportError("Expected Automattic\WooCommerce\Vendor\GraphQL named type but got: {$notNamedType}.", $node);
            continue;
        }

        $this->validateName($type);

        if ($type instanceof ObjectType) {
            $this->validateFields($type);
            $this->validateInterfaces($type);
            $this->validateDirectivesAtLocation($this->getDirectives($type), DirectiveLocation::OBJECT);
        } elseif ($type instanceof InterfaceType) {
            $this->validateFields($type);
            $this->validateInterfaces($type);
            $this->validateDirectivesAtLocation($this->getDirectives($type), DirectiveLocation::IFACE);
        } elseif ($type instanceof UnionType) {
            $this->validateUnionMembers($type);
            $this->validateDirectivesAtLocation($this->getDirectives($type), DirectiveLocation::UNION);
        } elseif ($type instanceof EnumType) {
            $this->validateEnumValues($type);
            $this->validateDirectivesAtLocation($this->getDirectives($type), DirectiveLocation::ENUM);
        } elseif ($type instanceof InputObjectType) {
            $this->validateInputFields($type);
            $this->validateDirectivesAtLocation($this->getDirectives($type), DirectiveLocation::INPUT_OBJECT);
            $this->inputObjectCircularRefs->validate($type);
        } else {
            assert($type instanceof ScalarType, 'only remaining option');
            $this->validateDirectivesAtLocation($this->getDirectives($type), DirectiveLocation::SCALAR);
        }
    }
}