Automattic\WooCommerce\Vendor\GraphQL\Utils

ASTDefinitionBuilder::makeInputValuesprivateWC 1.0

Method of the class: ASTDefinitionBuilder{}

No Hooks.

Returns

Array. UnnamedInputObjectFieldConfig>

Usage

// private - for code of main (parent) class only
$result = $this->makeInputValues( $values ): array;
$values(NodeList) (required)
.

ASTDefinitionBuilder::makeInputValues() code WC 10.9.1

private function makeInputValues(NodeList $values): array
{
    /** @var array<string, UnnamedInputObjectFieldConfig> $map */
    $map = [];
    foreach ($values as $value) {
        // Note: While this could make assertions to get the correctly typed
        // value, that would throw immediately while type system validation
        // with validateSchema() will produce more actionable results.
        /** @var Type&InputType $type */
        $type = $this->buildWrappedType($value->type);

        $config = [
            'name' => $value->name->value,
            'type' => $type,
            'description' => $value->description->value ?? null,
            'deprecationReason' => $this->getDeprecationReason($value),
            'astNode' => $value,
        ];

        if ($value->defaultValue !== null) {
            $config['defaultValue'] = AST::valueFromAST($value->defaultValue, $type);
        }

        $map[$value->name->value] = $config;
    }

    return $map;
}