I wrote an exegetical paper once that tried to prove that the water imagery throughout the Gospel of John is a reference to the Holy Spirit.
St. Thomas Aquinas holds a more nuanced position: the Holy Spirit is the fountain of living water, and the water itself is the grace given by the Holy Spirit. These few paragraphs from his Commentary on John concerning this Sunday’s gospel are enlightening on that score.
577 We may begin with what is last, and we should know first what is to be understood by water. And we should say that water signifies the grace of the Holy Spirit. Sometimes this grace is called fire, and at other times water, to show that it is neither one of these in its nature, but like them in the way it acts. It is called fire because it lifts up our hearts by its ardor and heat: “ardent in Spirit” (Rom 12:11), and because it burns up sins: “Its light is fire and flame” (Sg 8:6). Grace is called water because it cleanses: “I will pour clean water upon you, and you will be cleansed from all your uncleanness (Ez 36:25), and because it brings a refreshing relief from the heat of temptation: “Water quenches a flaming fire” (Sir 3:33), and also because it satisfies our desires, in contrast to our thirst for earthly things and all temporal things whatever: “Come to the waters, all you who thirst” (Is 55:1).
Now water is of two kinds: living and non-living. Non-living water is water which is not connected or united with the source from which it springs, but is collected from the rain or in other ways into ponds and cisterns, and there it stands, separated from its source. But living water is connected with its source and flows from it. So according to this understanding, the grace of the Holy Spirit is correctly called living water, because the grace of the Holy Spirit is given to man in such a way that the source itself of the grace is also given, that is, the Holy Spirit. Indeed, grace is given by the Holy Spirit: “The love of God is poured out into our hearts by the Holy Spirit, who has been given to us” (Rom 5:5). For the Holy Spirit is the unfailing fountain from whom all gifts of grace flow. “One and the same Spirit does all these things (1 Cor 12:11). And so, if anyone has a gift [here Thomas is speaking of “gift” in wide sense] of the Holy Spirit without having the Spirit, the water is not united with its source, and so is not living but dead: “Faith without works is dead” (Jas 2:20).
578 Then we are shown hat in the case of adults, living water, i.e., grace, is obtained by desiring it, i.e.e, by asking. “The Lord has heard the desire of the poor” (Ps. 9:17), for grace is not given to anyone without their asking and desiring it. Thus we say that in the justification of a sinner an act of free will is necessary to detest sin and to desire grace, according to Matthew (7:7): “Ask and you will receive). In fact, desire is so important that even the Son himself is told to ask: Ask me, and I will give it to you” (Ps 2:8). Therefore, no one who resists grace receives it, unless he first desires it; this is clear in the case of Paul who, before he received grace, desired it, saying, “Lord, what do you want me to do?” (Acts 9:6). Thus it is significant that he says, you perhaps would have asked him. He says perhaps on account of free will, with which a person sometimes desires and asks for grace, and sometimes does not.
579 There are two things which lead a person to desire and ask for grace: a knowledge of the good to be desired and a knowledge of the giver. So, Christ offers these two to her. First of all, a knowledge of the gift itself; hence he says, If you knew the gift of God, which is every desirable good which comes from the Holy spirit: “I know that I cannot control myself unless God grants it to me” (Wis 8:21). And this is a gift of God, and so forth. Secondly, he mentions the giver; and he says, and realized who it is who says to you, i.e.e, if you knew the one who can give it, namely, that it is I: “When the Paraclete comes, whom I will send you from the Father, the Spirit of truth … he will bear witness to me” (below 15:26); “You have given gifts to men” (Ps 67:19).