The first step is to put a layer of sliced or diced onions in the bottom of a baking dish. Drizzle some olive oil over the onions. Cut into disks an eggplant or two, a zucchini or two, and a few tomatoes. Arrange them in the baking dish on top of the onions as in the photo on the left, alternating the different vegetables.
Season the dish with thyme, salt, pepper, and more olive oil. Peel and slice a couple of garlic cloves and slip the slices in among the vegetables. Bake the dish in a medium-hot oven for at least an hour, until it is browned and the vegetables are soft and more or less confits (slow roasted, almost "candied") in the oil and their own juices. Add a little water or diluted tomato sauce as needed to keep everything from drying out as the dish bakes.
I had more eggplant and zucchini than tomato, so I made another gratin using just those vegetables, with the same seasoning. I cut the larger eggplant and zucchini slices in half before arranging them in the baking dish as shown.
Even though there were no tomato slices in the mix, I used some thin tomato sauce to keep the vegetables from drying out. Optionally, you could peel the zucchini and eggplant before cutting them into slices, but I didn't bother.