In a medium saucepan, melt 2 tbsp. butter over medium heat. Add the onion and cook, stirring often, until golden, 6 to 7 minutes. Add the flour and stir for 2 minutes. Gradually whisk in the broth in a steady stream. Simmer until thickened slightly, about 2 minutes; season with salt and pepper. Let cool. (The sauce will continue to thicken as it cools.)
Preheat the oven to 400°. Meanwhile, grease a medium casserole dish. In a food processor fitted with the slicing disk, thinly slice the sweet potatoes. Arrange half in the prepared dish in an even layer. Thinly slice the apples in the food processor. Place in a single layer on top of the sweet potatoes. Top with half of the onion sauce, the remaining sweet potatoes, then the remaining sauce. Cover the dish snugly with foil and bake until the sweet potatoes are tender when pierced with a fork, about 45 minutes.
Make ahead: Let cool completely; refrigerate for up to 2 days. Remove and let stand at room temperature for 1 hour before proceeding.
Lower the oven temperature to 350°. Rub the remaining 1 tbsp. butter into the gingersnap crumbs; sprinkle on top of the casserole. Bake the gratin, uncovered, until hot, about 25 minutes.