Data consistency in GraphQL queries pagination

Good afternoon,

I wonder how data consistency looks for GraphQL queries which require pagination.

Let’s consider the case of fetching an Order using the GraphQL orders query and then paginating over its lineItems:
Am I right that if the order is being edited (e.g. the merchant is adding more items) as we’re paginating its lineItems (using GraphQL pagination), then the Order’s total price (which we got in the 1st response) might not add up to the sum of all the lineItems prices (which we managed ?

In other words, can GraphQL pagination lead to potential data inconsistencies (due to simultaneous changes to the data happening in the background)?

Thank you

Hi @Piotr_Wojcicki

Yes, what you’re describing is known as a race condition in software engineering.

You’re describing a case where merchants could potentially be editing an order as it’s being read as part of your application.

However, what you can do is set up a webhook that subscribes to the order_updated topic, that way you have the ability to update your database/perform the action based off of the latest version of the order’s line items list.

1 Like