Solved

API: bulk operations for database records

  • 24 July 2021
  • 2 replies
  • 452 views

Userlevel 2

Hi,

I am building an app to keep Database in pipefy in sync with external source. This database contains thousands of records that are added and updated on the daily basis.

I’ve tried to use recordsImporter in GraphQL API to sync records, but it seems like it can only create records, but not update it. Is it correct? 

Are there any other ways to create/update/delete records in bulk through API or is it only possible to do it one by one? 

 

Best Regards, 

Artem

icon

Best answer by genietim 26 July 2021, 18:46

View original

2 replies

Userlevel 2

Hi Artem,

 

For updates, I do not see an option as direct as the recordsImporter for creating new cards.

If your concern is the number of GraphQL requests your app/sync engine has to do, I would suggest to group multiple queries/mutations into one request:

mutation {
N0 :updateCardField(input: {card_id: 000, field_id: 000, new_value: "Test"}) {clientMutationId}
N1 :updateCardField(input: {card_id: 000, field_id: 000, new_value: "Test"}) {clientMutationId}
N2 :updateCardField(input: {card_id: 000, field_id: 000, new_value: "Test"}) {clientMutationId}
...
}

Note that there is a limit to how many queries you can send at once. I do not know the exact number, but I believe it is somewhere around 50.

 

Best,

 

Tim

Thank you, that’s what I was thinking. Was just making sure there is no way to do bulk upsert of records, that I’ve missed 

Userlevel 7
Badge +12

Hi Artem,

 

For updates, I do not see an option as direct as the recordsImporter for creating new cards.

If your concern is the number of GraphQL requests your app/sync engine has to do, I would suggest to group multiple queries/mutations into one request:

mutation {
N0 :updateCardField(input: {card_id: 000, field_id: 000, new_value: "Test"}) {clientMutationId}
N1 :updateCardField(input: {card_id: 000, field_id: 000, new_value: "Test"}) {clientMutationId}
N2 :updateCardField(input: {card_id: 000, field_id: 000, new_value: "Test"}) {clientMutationId}
...
}

Note that there is a limit to how many queries you can send at once. I do not know the exact number, but I believe it is somewhere around 50.

 

Best,

 

Tim

Reply