Heat the oven to 180C/350F/Gas 4.
Put two tablespoons of groundnut oil into a preheated pan. Add the onions and fry gently until golden. Now add the mushrooms. Sauté for a few minutes until softened and lightly coloured. Season and remove from the heat.
Butter the slices of bread and cut each one into two triangles. Cover the base of a greased ovenproof dish with half of the bread.
Scatter over half each of the onion and mushroom mixture followed by half the grated gruyère. Repeat with the remaining bread, onions, mushrooms and gruyère.
Whisk the eggs, milk, crème fraîche, parmesan and some seasoning in a large bowl and pour over the top.
Place the gratin dish inside a roasting dish with warm water to come two thirds of the way up the sides (a bain marie) and bake for 35 minutes until puffy and golden.
Serve immediately while the cheese and custard are molten and gooey.