If I ready a action (spell) in response to a companion’s attack, what is a fair GM rulling over the order of events?

In our campaign, I have a cleric who wished to use Ready an Action as his move. His idea behind this was that he wanted to ready Guiding Bolt and the condition he set was that, when one of the player (fighter) attacked a creature (one of 2 trolls), he would release the bolt beforehand. Therefore the figther would have advantage on her attack if the Guiding Bolt hit first.

I ruled that the fighter hit first, but I’m not so sure now – and feel like I was unfair in my ruling, maybe.

I can see both points of view:

  1. If I was the cleric readying my spell, I would cast the spell as soon as I noticed my fighter’s companion intention to attack a creature.

  2. But, also if I’m the fighter and I’m 5′ away from a creature, maybe my attack would land first, before the Guiding Bolt.

I would like some RAW guidance on this please. But, if not explicitly available, then a response with lived experience of a GM on a similar ruling to do with resolving oder of events.