Automattic\WooCommerce\Vendor\GraphQL\Executor
ReferenceExecutor::completeLeafValue
Complete a Scalar or Enum by serializing to a valid value, throwing if serialization is not possible.
Method of the class: ReferenceExecutor{}
No Hooks.
Returns
Mixed.
Usage
// protected - for code of main (parent) or child class $result = $this->completeLeafValue( $returnType, $result );
- $returnType(LeafType) (required)
- .
- $result(mixed) (required)
- .
ReferenceExecutor::completeLeafValue() ReferenceExecutor::completeLeafValue code WC 10.9.1
protected function completeLeafValue(LeafType $returnType, $result)
{
try {
return $returnType->serialize($result);
} catch (\Throwable $error) {
$safeReturnType = Utils::printSafe($returnType);
$safeResult = Utils::printSafe($result);
throw new InvariantViolation("Expected a value of type {$safeReturnType} but received: {$safeResult}. {$error->getMessage()}", 0, $error);
}
}