Preheat oven to 400°F (200°C) and line a baking sheet with parchment paper.
Slice the spaghetti squash in half lengthwise, remove the seeds, and brush the flesh with olive oil.
Place the squash cut-side down on the baking sheet and roast for 40 minutes until the skin is easily pierced with a fork.
Remove squash from the oven and reduce the oven temperature to 375°F (190°C).
Scrape the squash into strands using a fork and place them in a colander for 5 minutes to drain excess moisture.
In a small saucepan over medium heat, combine heavy cream, minced garlic, thyme, salt, and pepper; simmer for 5 minutes until slightly thickened.
Transfer the drained squash strands to a greased 1.5-quart baking dish.
Add half of the Parmesan and Gruyère cheeses to the squash and toss to combine.
Pour the cream mixture over the squash and top with the remaining cheese.
Bake for 15 to 20 minutes until the cheese is golden brown and the sauce is bubbling.