Peel onions and cut them into rings. Peel, quarter and slice apples. Melt butter in a pan. Fry the onions for about 2 minutes at low heat, stirring occasionally.
Add sugar and let it caramelize for another 2-3 minutes. Wash the thyme, shake dry and chop finely, except for a few stems for garnishing. Add apples and thyme to the onions. Steam for another 5 minutes.
Season to taste with salt and pepper. Leave to cool on a flat plate.
Take the puff pastry out of the refrigerator 5-10 minutes before use. Coarsely grate the cheese. Unroll puff pastry and cut in half crosswise. Place pieces on a baking tray. Spread onion and apple mixture evenly on both halves.
Leave a margin of approx. 1 cm all around. Sprinkle cheese over the topping. Whisk the egg yolks with 2 tbsp. water. Brush the edges of the dough and bake in a preheated oven (electric cooker: 200 °C/ convection oven: 175 °C/ gas: see
manufacturer) Bake for 15-20 minutes until golden brown. Remove from the oven and let cool on a cake rack for about 5 minutes. Arrange warm on plates and cut into pieces.