Automattic\WooCommerce\Vendor\GraphQL\Utils

BuildClientSchema::buildUnionDefprivateWC 1.0

Method of the class: BuildClientSchema{}

No Hooks.

Returns

null. Nothing (null).

Usage

// private - for code of main (parent) class only
$result = $this->buildUnionDef( $union ): UnionType;
$union(array) (required)
.

BuildClientSchema::buildUnionDef() code WC 10.9.1

private function buildUnionDef(array $union): UnionType
{
    if (! array_key_exists('possibleTypes', $union)) {
        $safeUnion = Utils::printSafeJson($union);
        throw new InvariantViolation("Introspection result missing possibleTypes: {$safeUnion}.");
    }

    return new UnionType([
        'name' => $union['name'],
        'description' => $union['description'],
        'types' => fn (): array => array_map(
            [$this, 'getObjectType'],
            $union['possibleTypes']
        ),
    ]);
}