Difficulty with cache consistency and local state sync in high-concurrency mobile environments

Hello everyone,

I’ve been working on an implementation using Apollo Client for a mobile-focused project, and I’ve run into a specific edge case regarding how the InMemoryCache handles rapid-fire updates when the device is under heavy load.

I’ve been doing some stress testing lately to see how our GraphQL queries hold up when the system resources are being stretched. While I was chatting about performance benchmarks over in the arceusx app community, I noticed that my local state variables aren’t always updating in sync with the server responses when there are other scripts or executors running on the device. It seems like the “readQuery” and “writeQuery” operations are occasionally lagging behind the actual network delivery.

Has anyone here dealt with race conditions in the Apollo cache specifically on mobile webviews? I’m also seeing some weirdness where the optimistic UI updates don’t seem to “roll back” correctly if the connection is interrupted while the CPU is spiking.

I’m trying to figure out if I should be looking into a more robust persistence layer or if there’s a way to prioritize the Apollo observer threads to prevent this kind of desync. If you have any experience with managing complex data flows in environments where external processes might be competing for resources, I’d really appreciate your perspective!