In a large pot, melt the butter over medium heat. Add the chopped onions and sauté until they become translucent. Add the minced garlic and sliced mushrooms, and cook until the mushrooms are tender.
Sprinkle the flour over the mushroom mixture and stir well to combine. Cook for 2-3 minutes to get rid of the raw flour taste.
Gradually pour in the chicken or vegetable broth while continuously stirring to avoid lumps. Add the milk and stir until well combined.
Bring the soup to a simmer and let it cook for about 10-15 minutes until it thickens slightly. Stir occasionally to prevent sticking.
Reduce the heat to low and slowly add the shredded cheddar cheese, stirring constantly until the cheese is melted and the soup becomes creamy.
Season the soup with salt, pepper, and dried thyme (if using). Adjust the seasoning according to your taste.
For added richness, you can stir in the heavy cream at this point.
Ladle the soup into bowls and garnish with chopped parsley if desired.