Replace custom field data in the find request results

I have a custom field that stores the ID of a collection type. Whenever this field is present in find requests (whether in collection types or components), I must replace the ID with the object data of the collection type. Does Strapi offer a way to search and replace the ID with its object data in the results of a collection type find request?

I use the lifecycle hook afterFindOne to get the collection type return response.
I check the collection type schema for the custom field and fetch the field name. Then I find the field by field name in the result and replace the value of the field. This becomes complicated to search if the custom field is used in components and if nested components are present.
Is there a better way I could do this?

This topic has been created from a Discord post (1255821790018797600) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord