8000 Disable launches type policy keyArgs to fix pagination · nirus/fullstack-tutorial@6b41ad1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6b41ad1

Browse files
committed
Disable launches type policy keyArgs to fix pagination
When launches are originally fetched, they are fetched without any pagination parameters. This means by default they're stored in the cache under a key of `launches({})`. Then when the next batch of launches is fetched through pagination, an `after` parameter is used to mark the next batch of launches to be loaded. By default, the cache will use parameters as part of the key it stores values under, which means the next batch of launches is stored under a key that looks something like `launches({"after":"1558665000"})`. When the launches merge function tries to merge previous results with new incoming results, it doesn't see any previous results when a new batch of launches is received, because each time that batch is stored under a separate cache key. Setting `keyArgs: false` for the `launches` field policy tells the cache to ignore the `after` parameter, making sure all launches are stored under the same cache key. This helps the merge function load previous launches, and merge in the new launches.
1 parent bb08d38 commit 6b41ad1

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

final/client/src/cache.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export const cache: InMemoryCache = new InMemoryCache({
1111
return cartItemsVar();
1212
},
1313
launches: {
14+
keyArgs: false,
1415
merge(existing, incoming) {
1516
let launches: Reference[] = [];
1617
if (existing && existing.launches) {

0 commit comments

Comments
 (0)
0