Automattic\WooCommerce\Vendor\GraphQL\Utils

SchemaPrinter::printFieldsprotected staticWC 1.0

Method of the class: SchemaPrinter{}

No Hooks.

Returns

null. Nothing (null).

Usage

$result = SchemaPrinter::printFields( $options, $type ): string;
$options(array) (required)
.
$type(ObjectType|InterfaceType) (required)
.

SchemaPrinter::printFields() code WC 10.9.1

protected static function printFields(array $options, $type): string
{
    $fields = [];
    $firstInBlock = true;
    $previousHasDescription = false;
    $fieldDefinitions = $type->getFields();

    if (isset($options['sortFields']) && $options['sortFields']) {
        ksort($fieldDefinitions);
    }

    foreach ($fieldDefinitions as $f) {
        $hasDescription = $f->description !== null;
        if ($previousHasDescription && ! $hasDescription) {
            $fields[] = '';
        }

        $fields[] = static::printDescription($options, $f, '  ', $firstInBlock)
            . '  '
            . $f->name
            . static::printArgs($options, $f->args, '  ')
            . ': '
            . $f->getType()->toString()
            . static::printDeprecated($f);
        $firstInBlock = false;
        $previousHasDescription = $hasDescription;
    }

    return static::printBlock($fields);
}