Loading data from an external API for a calculation
Hello! I have a resource that I would like to enhance in certain reads with a calculation that needs to be based off data from an external API.
I'm mindful of not wanting to make the API request from within a transaction if possible.
I thought of adding a preparation to the read action that will fetch the API data and put it into the context, which the calculation can use.
Is this a reasonable approach? Are there any escape hatches to be able to avoid decoupling the API request from the calculation module while still ensuring the request runs outside of a transaction?
I'm mindful of not wanting to make the API request from within a transaction if possible.
I thought of adding a preparation to the read action that will fetch the API data and put it into the context, which the calculation can use.
Is this a reasonable approach? Are there any escape hatches to be able to avoid decoupling the API request from the calculation module while still ensuring the request runs outside of a transaction?
Solution
