How to split apart the word order in English?
Solution 1:
I don't understand why you think that Rowling has made some error. The formulation is just like: " A sip of tea from a porcelain cup refreshes the spirits." The phrase "through the branches" is adjectival, distinguishing the ray of moonlight from other rays of moonlight that have not passed through branches. Whether other less wealthy writers would have chosen those words has no bearing on whether the rules of grammar, such as they are, have been broken.
Solution 2:
Rowling's version is fine grammatically. Prepositional phrases can serve as adjective phrases as well as adverb phrases, and prepositional phrases modifying verbs can appear before the verb.
You are right that through, leading a prepositional phrase, tends to follow a verb, whether that would be lit or your hypothetical gerundive shining.
However, through, like other prepositional phrases, can also follow a noun. In this case, through may modify moonlight directly. Merriam Webster features a pair of examples:
a highway through the forest
a road through the desert
Here's an example from the 2016 novel Promised to the Crown, where "light" is modified by through her cell window without a clear verb correspondent:
Seeing the dawn light through her cell window proved a disappointment that morning and many afterward.
In a more scientific context, here's a passage about light transmitted through a vacuum without using a verb like "transmitted":
The speed of light through a vacuum is exactly 299,792,458 meters per second, or 670,616,629 mph
In these examples, it is clear that the first noun is somehow moving or being transmitted through the preposition's object. No verb and no rearrangement of the syntax to follow a verb is necessary.
Even if we wanted to consider "through" as an adverbial phrase modifying the verb "lit," moving the phrase "through" to precede the verb occasionally happens in literary use. Samuel Taylor Coleridge affects a lyrical style in Rime of the Ancient Mariner to do just that:
And every tongue thro' utter drouth / Was wither'd at the root
Or John Milton in Samson Agonistes:
If he through frailty err
The expressions sound distinct, and we could discuss further whether Rowling's style entirely works here (she's no poet), but the usage is fine grammatically.