In a large skillet, heat the olive oil over medium heat. Add the sliced onion and salt, stirring occasionally. Cook for about 15-20 minutes, or until the onions are caramelized and golden brown. Remove from heat and set aside.
In a large pot, bring salted water to a boil. Add the gnocchi and cook according to package instructions, usually about 2-3 minutes or until they float to the surface. Drain and set aside.
In the same skillet used for the onions, add the heavy cream, black pepper, and nutmeg. Stir to combine and bring to a gentle simmer.
Add the cooked gnocchi to the skillet and stir gently to coat them in the cream sauce.
Fold in the caramelized onions and half of the grated Gruyère cheese. Stir until the cheese is melted and everything is well combined.
Transfer the mixture to a greased baking dish and sprinkle the remaining Gruyère cheese on top.
Preheat your oven to 400°F. Bake for 15-20 minutes, or until the cheese is bubbly and golden.
Remove from the oven and let cool for a few minutes. Garnish with fresh parsley before serving.