npm install
npm run devThe project highlights a bug in Apollo Client where useQuery will return stale data after setting skip: true, calling client.clearStore() or client.cache.updateQuery(), and setting skip: false.
This happens in a real-world application where the user is logged out and the query is skipped. When the user logs in again, stale data is returned matching the previous user.
- Login as user-1
- Logout
- Login as user-2
Check the console: https://gyazo.com/7de9ea69aa7b7aedcbb82c06149f4295
=> useQuery's cache is stale and the query returns the wrong user, even though the Apollo cache is empty.
Expected: the query returns undefined.
- Login as user-1
- Logout
- Click "Alter cache"
- Login as user-2
Check the console: https://gyazo.com/c0ea27f5c85149a5fb438c01fbd50a56
=> useQuery's cache is stale and the query returns the wrong user, even though the Apollo cache was updated with another user.
Expected: the query returns user-3.