public function coerceVariableValues(Schema $schema, array $variableDefinitionNodes, array $inputs): CoercedValue
    {
        $coercedValues = [];
        $errors        = [];

        foreach ($variableDefinitionNodes as $variableDefinitionNode) {
            $variableName = $variableDefinitionNode->getVariable()->getNameValue();
            $variableType = TypeASTConverter::convert($schema, $variableDefinitionNode->getType());

            if (!$this->isInputType($variableType)) {
                $variableTypeName = (string)$variableType;

                if ($variableTypeName === '') {
                    $variableTypeName = (string)$variableDefinitionNode;
                }

                $errors[] = $this->buildCoerceException(
                    sprintf(
                        'Variable "$%s" expected value of type "%s" which cannot be used as an input type',
                        $variableName,
                        $variableTypeName
                    ),
                    $variableDefinitionNode,
                    null
                );
            } else {
                if (!array_key_exists($variableName, $inputs)) {
                    if ($variableType instanceof NonNullType) {
                        $errors[] = $this->buildCoerceException(
                            sprintf(
                                'Variable "$%s" of required type "%s" was not provided',
                                $variableName,
                                (string)$variableType
                            ),
                            $variableDefinitionNode,
                            null
                        );
                    } elseif ($variableDefinitionNode->getDefaultValue() !== null) {
                        $coercedValues[$variableName] = ValueASTConverter::convert(
                            $variableDefinitionNode->getDefaultValue(),
                            $variableType
                        );
                    }
                } else {
                    $value        = $inputs[$variableName];
                    $coercedValue = $this->coerceValue($value, $variableType, $variableDefinitionNode);
                    if ($coercedValue->hasErrors()) {
                        $messagePrelude = sprintf(
                            'Variable "$%s" got invalid value %s',
                            $variableName, json_encode($value)
                        );
                        foreach ($coercedValue->getErrors() as $error) {
                            $errors[] = $this->buildCoerceException(
                                $messagePrelude,
                                $variableDefinitionNode,
                                null,
                                $error->getMessage(),
                                $error
                            );
                        }
                    } else {
                        $coercedValues[$variableName] = $coercedValue->getValue();
                    }
                }
            }
        }

        return new CoercedValue($coercedValues, $errors);
    }