GraphQL returns different data than a webhook

When we update an entry, and send a webhook, the webhook provides the new data correctly. however, if in that same webhook, we then immediately query the data via the Graphql api, the api returns the old data! I assume this is because the webhook is faster than the cache invalidation for the Graphql API, as if we query the data 5 seconds after, we get the new data. However, this is a big problem for us, as the Webhook uses the Graphql API to update other information, and if we call it immediately after getting the webhook, we are upding with old data. Is there any way to invalidate the cache automatically before calling the graphql API, so we get the correct data? How long does it take for the cache to invalidate?

hello @osseonews

CDN purging and webhooks are async operations that we launch at the same time when we have to notify that an item has been changed (such as when you update an item via REST API or via admin interface).

Purges are completed across the entire global edge cache in around 150ms, but there is no guarantee in this either.

Adding a pause of 1 or 2 seconds in your code right before doing a graphql request should be enough in most of the cases

Hope this helps!