Peel squash and cut in half lengthwise. Remove center seeds and strings, and then slice thinly. Heat butter in a skillet, over a medium flame. Add onions and sauté for 10 minutes. Combine apples and flour-toss to coat well.
Place half of the squash into a buttered 9x13x2-inch baking dish or hotel pan. Arrange half the apples in a layer on top of the squash place the remaining squash on top of the apples. Cover with the remaining apples. Top with the sautéed onions. Pour stock over all.
Bake 350 degrees for 45 minutes, until squash is tender combine breadcrumbs, cheese, and bacon-mix well. Spread mixture over the gratin.
Bake 350 degrees for 15-25 minutes, until lightly browned remove from heat and allow to cool slightly before serving. Serve hot.