Admin UI: opening an item page refetches KsFetchAdminMeta and KsFetchItem ("Apollo Client stopped refetching")
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- graphql, node.js, react, typescript
- Domain
- frontend, performance
Research direction
Start with the Admin UI InMemoryCache in packages/core/src/admin-ui/context.tsx and the KsFetchAdminMeta and KsFetchItem queries described in the issue. Check how Apollo Client caches their shared KeystoneMeta and KeystoneAdminMeta objects. Done means opening an item page sends each query once and shows no stopped-refetching warning.
Written by the indexing model from the issue text.
Description
Steps to reproduce
- In a project on the published
@keystone-6/core9.0.0 (examples/assets-localwith a freshnpm installwill do), runkeystone devand create one item. - Open the item's page in the Admin UI, with the browser's console and network panel open.
The item page sends both of its queries twice, and the console warns:
Apollo Client stopped refetching 'KsFetchAdminMeta' because the same incomplete cache result was already refetched.
Automatic refetching was halted to prevent an endless cycle of network requests.
| Page | GraphQL requests |
|---|---|
| Dashboard | KsFetchAdminMeta, KsFetchListCounts |
| Item page | KsFetchAdminMeta, KsFetchItem, KsFetchAdminMeta, KsFetchItem |
In keystone dev, Next forwards the warning to the terminal as [browser] Apollo Client stopped refetching 'KsFetchAdminMeta'.
Expected
The item page sends KsFetchAdminMeta and KsFetchItem once each, without a warning.
Cause
Both queries select fields of the same object: KsFetchAdminMeta reads keystone { adminMeta { lists { … } } }, and KsFetchItem reads keystone { adminMeta { list(key: $listKey, itemId: $id) { … } } }. KeystoneMeta and KeystoneAdminMeta have no id, and the Admin UI's InMemoryCache (packages/core/src/admin-ui/context.tsx) has no typePolicies, so storing KsFetchItem's result replaces the cached adminMeta object, and its lists field is lost.
KsFetchAdminMeta then finds its cache result incomplete and refetches, which KsFetchItem overwrites again, until Apollo Client 4 stops the loop.
With new InMemoryCache({ typePolicies: { KeystoneMeta: { merge: true }, KeystoneAdminMeta: { merge: true } } }) the item page sends each query once and the warning is gone (tried in the same project).
Context
macOS, Node 24.18.0; @keystone-6/core 9.0.0 with its @apollo/client 4.3.8. Nothing breaks: the page and the navigation work. The cost is the two extra requests on every item page, and KsFetchAdminMeta is the Admin UI's largest query.
- Dominant language
- TypeScript
- Stars
- 10k
- Forks
- 1.3k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 38
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from keystonejs/keystone
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
keystonejs/keystone#10141 ·
Maintainers usually reply within 1 day
-
[bug] List view search field becomes disabled when search returns no results, interrupting IME inputPossibly taken @ltxhhz claimed this 17 days ago. Open
Difficulty 1/5 Under an hour Newbie friendliness 85/100
keystonejs/keystone#10097 ·
Maintainers usually reply within 1 day
-
Document Fields Demo page of docs refers to form that doesn't existMay be free again @Mthize claimed this 189 days ago, and no pull request is open. Open
Difficulty 1/5 Under an hour Newbie friendliness 72/100
keystonejs/keystone#9766 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 75/100
keystonejs/keystone#10142 ·
Maintainers usually reply within 1 day
-
bigInt field defaultValue { kind: 'autoincrement' } triggers missing value validationMay be free again A pull request for this issue was closed without being merged. Open
Difficulty 3/5 1-2 days Newbie friendliness 45/100
keystonejs/keystone#10048 ·
Maintainers usually reply within 1 day
All issues in keystonejs/keystone
Similar issues
-
Media browser returns "Not found" for repositories using the SHA-256 object formatPossibly taken @adamchodera claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Follow-ups from #312Open
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
janhesters/remixcn#318 ·
Maintainers usually reply within 1 day
-
Interceptor LaunchTestProfile.sh: no Windows (Git Bash/MSYS) branch, test profile never launchesOpen
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
danielmiessler/LifeOS#3150 ·
Maintainers usually reply within 5 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
Make the "%" unit spacing the same in the web and in A10Possibly taken @kragent66-glitch claimed this today. Openbug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
maiychrus25/OpenTea-DX-OS#226 · 1 comment ·