in this context to look at something Tolkien wrote very shortly after coming home, in fact while he was still recovering and the slaughter in the trenches was still going on:

Quote

"O [Eriol], go never to a war - or hast thou ever yet?"

"Aye, often enough." said Eriol, "but not to the great wars of the earthly kings, which are cruel and bitter, and many fair lands and lovely things and even women and sweet maids such as thou Veanne Melinir are whelmed by them in ruin; yet gallant affrays have I seen wherein small bands of brave men do sometimes meet and swift blows are dealt."

--Turambar and the Foaloke

I find this very interesting, that Tolkien could view grimly the "cruel and bitter" great wars, but still have a romantic attachment to "gallant affrays."

First, we need to distinguish different stories and different stages of the Legendarium. It seems to me that the earliest incarnations were the ones most affected by Tolkien's own experiences (the dragon-like tanks in Gondolin). John Garth, reconstructing the earliest Silmarillion, suggests that Tolkien had self-insert characters within his imaginary setting. It all kind of falls into play with a time in which Tolkien's universe much more overly faded into our own.

Second, we need to distinguish the ways in which real-life can affect fiction. Some of the influences are quite generic: Tolkien experienced a great war, and his fiction has great wars. But than, great wars are the stuff of legend and epics, aren't they?

That Tolkien had an aversion for war and destruction I think goes beyond is experiences in World War I and relates more specifically to his humanity and peace-loving demeanour.

Surely, some stuff in his works is derived from his experiences: The Dead Marshes are very clearly inspired by the drenched Somme. But even in that case we need to distinguish between shorthand and allegory. Tolkien used the former, drawing from history and geography as well as from his own life; but he never used the former. Even if The Dead Marshes draw on the Somme, it doesn't mean that they are allegorical of the Somme.

I'm also a fan of Michael Moorcock's, and perhaps that has primed me to consider both Smeagol aka Gollum and Frodo as addicts, in a manner similar to Elric of Melnibone, Prince of Ruins.

And one of the least pleasant facets of JRR Tolkien's war experience may have been encountering those returned servicemen who became addicted to morphine, one of the only pain-killers available at the time.

Of course, Frodo's post-traumatic stress disorder and overall depression is also a feature of surviving combat. I have no doubt that JRR Tolkien's marriage and his faith were crucial in him pulling through.