Automattic\WooCommerce\Vendor\GraphQL\Type

Introspection::_inputValuepublic staticWC 1.0

Method of the class: Introspection{}

No Hooks.

Returns

null. Nothing (null).

Usage

$result = Introspection::_inputValue(): ObjectType;

Introspection::_inputValue() code WC 10.9.1

public static function _inputValue(): ObjectType
{
    return self::$cachedInstances[self::INPUT_VALUE_OBJECT_NAME] ??= new ObjectType([ // @phpstan-ignore missingType.checkedException (static configuration is known to be correct)
        'name' => self::INPUT_VALUE_OBJECT_NAME,
        'isIntrospection' => true,
        'description' => 'Arguments provided to Fields or Directives and the input fields of an '
                . 'InputObject are represented as Input Values which describe their type '
                . 'and optionally a default value.',
        'fields' => static fn (): array => [
            'name' => [
                'type' => Type::nonNull(Type::string()),
                /** @param Argument|InputObjectField $inputValue */
                'resolve' => static fn ($inputValue): string => $inputValue->name,
            ],
            'description' => [
                'type' => Type::string(),
                /** @param Argument|InputObjectField $inputValue */
                'resolve' => static fn ($inputValue): ?string => $inputValue->description,
            ],
            'type' => [
                'type' => Type::nonNull(self::_type()),
                /** @param Argument|InputObjectField $inputValue */
                'resolve' => static fn ($inputValue): Type => $inputValue->getType(),
            ],
            'defaultValue' => [
                'type' => Type::string(),
                'description' => 'A GraphQL-formatted string representing the default value for this input value.',
                /** @param Argument|InputObjectField $inputValue */
                'resolve' => static function ($inputValue): ?string {
                    if ($inputValue->defaultValueExists()) {
                        $defaultValueAST = AST::astFromValue($inputValue->defaultValue, $inputValue->getType());

                        if ($defaultValueAST === null) {
                            $inconvertibleDefaultValue = Utils::printSafe($inputValue->defaultValue);
                            throw new InvariantViolation("Unable to convert defaultValue of argument {$inputValue->name} into AST: {$inconvertibleDefaultValue}.");
                        }

                        return Printer::doPrint($defaultValueAST);
                    }

                    return null;
                },
            ],
            'isDeprecated' => [
                'type' => Type::nonNull(Type::boolean()),
                /** @param Argument|InputObjectField $inputValue */
                'resolve' => static fn ($inputValue): bool => $inputValue->isDeprecated(),
            ],
            'deprecationReason' => [
                'type' => Type::string(),
                /** @param Argument|InputObjectField $inputValue */
                'resolve' => static fn ($inputValue): ?string => $inputValue->deprecationReason,
            ],
        ],
    ]);
}