In a medium saucepan, heat the oil or butter over medium-high heat. Add the shallots and sauté until beginning to soften but not brown, about 6 minutes. Add the garlic and rosemary and cook for another 2 minutes. Sprinkle the flour over the vegetables and cook, stirring often, until lightly browned, about 2 minutes.
Gradually add the stock, 1/2 cup at a time, whisking vigorously before adding more. Once all of the liquid is incorporated, bring the mixture to a rapid simmer over high heat. Add the cider and reduce the heat to medium-low. Simmer gently, stirring every 3 to 5 minutes, until thick enough to coat the back of a spoon, about 15 minutes. Add the vinegar and season with salt and pepper to taste. The gravy can be made up to 3 days in advance up until this point, or further in advance and frozen.
Before serving (or when your turkey is finished roasting), add the pan drippings, if using, and bring the mixture to a simmer. Cook over medium-low heat until the sauce has thickened again, about 5 minutes.