In a large skillet, heat the olive oil over medium heat. Add the sliced onion, salt, and sugar. Cook, stirring occasionally, until the onions are caramelized and golden brown, about 15-20 minutes.
Stir in the minced garlic and thyme, cooking for an additional 1-2 minutes until fragrant.
Pour in the beef broth and heavy cream, stirring to combine. Bring the mixture to a simmer and let it cook for about 5 minutes to thicken slightly.
Meanwhile, cook the gnocchi according to package instructions until they float to the surface. Drain and set aside.
Preheat your oven to 375°F.
In a large baking dish, combine the cooked gnocchi with the onion mixture. Mix well to ensure the gnocchi are evenly coated.
Sprinkle the Gruyère and Parmesan cheeses evenly over the top.
Bake in the preheated oven for 20-25 minutes, or until the cheese is melted and bubbly.
Remove from the oven and let it cool for a few minutes. Garnish with fresh parsley before serving.