Automattic\WooCommerce\Vendor\GraphQL\Utils

BuildClientSchema::buildDirectivepublicWC 1.0

Method of the class: BuildClientSchema{}

No Hooks.

Returns

null. Nothing (null).

Usage

$BuildClientSchema = new BuildClientSchema();
$BuildClientSchema->buildDirective( $directive ): Directive;
$directive(array) (required)
.

BuildClientSchema::buildDirective() code WC 10.9.1

public function buildDirective(array $directive): Directive
{
    if (! array_key_exists('args', $directive)) {
        $safeDirective = Utils::printSafeJson($directive);
        throw new InvariantViolation("Introspection result missing directive args: {$safeDirective}.");
    }

    if (! array_key_exists('locations', $directive)) {
        $safeDirective = Utils::printSafeJson($directive);
        throw new InvariantViolation("Introspection result missing directive locations: {$safeDirective}.");
    }

    return new Directive([
        'name' => $directive['name'],
        'description' => $directive['description'],
        'args' => $this->buildInputValueDefMap($directive['args']),
        'isRepeatable' => $directive['isRepeatable'] ?? false,
        'locations' => $directive['locations'],
    ]);
}