Looking for an equivalent of an upsert mutation so I can perform add or update operations based on whether a particular ID exists in the database.
For example, lets say have a dynamic data source that looks something like this:
Record ID
Name
# of Cats
A
Dave
0
B
Alex
1
C
Tanya
9
And I’m trying to periodically sync all those records and their latest data into my Fibery database, which currently looks like this:
Fibery Entity ID
Record ID
Name
# of Cats
0c3
C
Tanya
8
7p4
D
Jade
0
6e8
E
Chris
2
So the the sync would have to look something like this:
Check what records in my data source already have a matching entity in my Fibery database using the Record ID
Update the matching entities in my Fibery database
Add to my Fibery database the rest of the “new” records in my data source
So at the end of the upsert operation my Fibery database would look like this:
Fibery Entity ID
Record ID
Name
# of Cats
0c3
C
Tanya
9
7p4
D
Jade
0
6e8
E
Chris
2
n4w
A
Dave
0
z02
B
Alex
1
I got about this far and then ran into the issue where I’m not familiar with GraphQL and wasnt sure how to do batch update operations for matching records:
Batch update can be used to perform multiple mutations over set of records. It means that when you find some records you can perform the same mutations for these records. Your mutation
I’ve spend a while now and still can’t figure out how to do the kind of updates I want using GraphQL without hundreds of requests. Can you please assist? Here is another example of what I am trying to do:
So to clarify, if I want to apply a different update to 5 separate records I need to do 5 separate GraphQL API requests? Or is there a way to do many different update mutations in a single GraphQL API request.
EDIT: I think this might be the way to update multiple records in one request, is this suitable for 100s of updates at once?
Please use multiple requests. Also I suggest to use paging if mutations applied for a huge amount of records. The explanation can be found Fibery GraphQL API