Automattic\WooCommerce\Vendor\GraphQL\Utils

ASTDefinitionBuilder::makeSchemaDefFromConfigprivateWC 1.0

Метод класса: ASTDefinitionBuilder{}

Хуков нет.

Возвращает

CustomScalarType|EnumType|InputObjectType|InterfaceType|ObjectType|UnionType.

Использование

// private - только в коде основоного (родительского) класса
$result = $this->makeSchemaDefFromConfig( $def, $config ): Type;
$def(Node) (обязательный)
.
$config(массив) (обязательный)
.

Код ASTDefinitionBuilder::makeSchemaDefFromConfig() WC 11.0.1

private function makeSchemaDefFromConfig(Node $def, array $config): Type
{
    switch (true) {
        case $def instanceof ObjectTypeDefinitionNode:
            // @phpstan-ignore-next-line assume the config matches
            return new ObjectType($config);

        case $def instanceof InterfaceTypeDefinitionNode:
            // @phpstan-ignore-next-line assume the config matches
            return new InterfaceType($config);

        case $def instanceof EnumTypeDefinitionNode:
            // @phpstan-ignore-next-line assume the config matches
            return new EnumType($config);

        case $def instanceof UnionTypeDefinitionNode:
            // @phpstan-ignore-next-line assume the config matches
            return new UnionType($config);

        case $def instanceof ScalarTypeDefinitionNode:
            // @phpstan-ignore-next-line assume the config matches
            return new CustomScalarType($config);

        case $def instanceof InputObjectTypeDefinitionNode:
            // @phpstan-ignore-next-line assume the config matches
            return new InputObjectType($config);

        default:
            throw new Error("Type kind of {$def->kind} not supported.");
    }
}