Automattic\WooCommerce\Vendor\GraphQL\Type

Introspection::fromSchemapublic staticWC 1.0

Build an introspection query from a Schema.

Introspection is useful for utilities that care about type and field relationships, but do not need to traverse through those relationships.

This is the inverse of BuildClientSchema::build(). The primary use case is outside the server context, for instance when doing schema comparisons.

Method of the class: Introspection{}

No Hooks.

Returns

Array. array<mixed>>

Usage

$result = Introspection::fromSchema( $schema, $options ): array;
$schema(Schema) (required)
.
$options(IntrospectionOptions)
.
Default: []

Introspection::fromSchema() code WC 10.9.1

public static function fromSchema(Schema $schema, array $options = []): array
{
    $optionsWithDefaults = array_merge([
        'directiveIsRepeatable' => true,
        'schemaDescription' => true,
        'typeIsOneOf' => true,
    ], $options);

    $result = GraphQL::executeQuery(
        $schema,
        self::getIntrospectionQuery($optionsWithDefaults)
    );

    $data = $result->data;
    if ($data === null) {
        $noDataResult = Utils::printSafeJson($result);
        throw new InvariantViolation("Introspection query returned no data: {$noDataResult}.");
    }

    return $data;
}