Automattic\WooCommerce\Vendor\GraphQL\Type\Definition
InputObjectField::assertValid
Method of the class: InputObjectField{}
No Hooks.
Returns
null. Nothing (null).
Usage
$InputObjectField = new InputObjectField(); $InputObjectField->assertValid( $parentType ): void;
- $parentType(Type&NamedType) (required)
- .
InputObjectField::assertValid() InputObjectField::assertValid code WC 10.9.4
public function assertValid(Type $parentType): void
{
$error = Utils::isValidNameError($this->name);
if ($error !== null) {
throw new InvariantViolation("{$parentType->name}.{$this->name}: {$error->getMessage()}");
}
$type = Type::getNamedType($this->getType());
if (! $type instanceof InputType) {
$notInputType = Utils::printSafe($this->type);
throw new InvariantViolation("{$parentType->name}.{$this->name} field type must be Input Type but got: {$notInputType}");
}
// @phpstan-ignore-next-line should not happen if used properly
if (array_key_exists('resolve', $this->config)) {
throw new InvariantViolation("{$parentType->name}.{$this->name} field has a resolve property, but Input Types cannot define resolvers.");
}
if ($this->isRequired() && $this->isDeprecated()) {
throw new InvariantViolation("Required input field {$parentType->name}.{$this->name} cannot be deprecated.");
}
}