#Set multiple fields from an external api call

10 messages · Page 1 of 1 (latest)

paper mulch
#

how would you go about setting multiple fields from one external api call?

olive grailBOT
paper mulch
#

@anyone

raw crane
#

can t you use graphql api for this purpose ?

#

or maybe you want to be able to update multiple rows ? (e.g updateMany )

paper mulch
#

I want to update many rows.

#

4 rows with 2 fields each. The fields are populated from an extrnal API call and the user has the option to override them. With my current structure i call the external api for each field to grab a piece of data. I want to just make on reques to the external api to grab all the data and then populate all the fields

raw crane
#

Is it possible to write a raw SQL query to do that in our ORM? or use its functionalities to do bulk updates and stuff

paper mulch
#

I am not sure if that would work. I need the requests to the external api to run when the page is loaded (to grab any updates). Currently I just make the call in the AfterRead hook. In the AfterRead hook I call the api grab the field's value and then return it. this approach is causing me multiple issues.

  1. multiple unnecessary calls to the api (I call the api for every field just to extract teh data for that specific field)
  2. When I grab the global in a REST API to get data for other fields I end up triggering the afterReads for these api dependant field cause unneeded requests to the external api
raw crane
#

Oh, I see. I misunderstood; I thought the API you were referring to was a Payload API. Then I don’t have any ideas for your issue 😅 . Maybe you should try creating a GitHub issue. I'm sure it could help a lot of people who are not on Discord.
I hope you find an answer quickly! ☘️