Automattic\WooCommerce\Vendor\GraphQL\Type\Definition

Argument::assertValidpublicWC 1.0

Method of the class: Argument{}

No Hooks.

Returns

null. Nothing (null).

Usage

$Argument = new Argument();
$Argument->assertValid( $parentField, $parentType ): void;
$parentField(FieldDefinition) (required)
.
$parentType(Type&NamedType) (required)
.

Argument::assertValid() code WC 10.9.1

public function assertValid(FieldDefinition $parentField, Type $parentType): void
{
    $error = Utils::isValidNameError($this->name);
    if ($error !== null) {
        throw new InvariantViolation("{$parentType->name}.{$parentField->name}({$this->name}:) {$error->getMessage()}");
    }

    $type = Type::getNamedType($this->getType());

    if (! $type instanceof InputType) {
        $notInputType = Utils::printSafe($this->type);
        throw new InvariantViolation("{$parentType->name}.{$parentField->name}({$this->name}): argument type must be Input Type but got: {$notInputType}");
    }

    if ($this->isRequired() && $this->isDeprecated()) {
        throw new InvariantViolation("Required argument {$parentType->name}.{$parentField->name}({$this->name}:) cannot be deprecated.");
    }
}