private function coerceValue($value, $type, $blameNode, ?Path $path = null): CoercedValue
    {
        if ($type instanceof NonNullType) {
            return $this->coerceValueForNonNullType($value, $type, $blameNode, $path);
        }

        if (null === $value) {
            return new CoercedValue(null);
        }

        if ($type instanceof ScalarType) {
            return $this->coerceValueForScalarType($value, $type, $blameNode, $path);
        }

        if ($type instanceof EnumType) {
            return $this->coerceValueForEnumType($value, $type, $blameNode, $path);
        }

        if ($type instanceof ListType) {
            return $this->coerceValueForListType($value, $type, $blameNode, $path);
        }

        if ($type instanceof InputObjectType) {
            return $this->coerceValueForInputObjectType($value, $type, $blameNode, $path);
        }

        throw new GraphQLException('Unexpected type.');
    }