Loading
Skip the cache write when a CI subscription leaves data unchanged
What does this MR do and why?
Fixes Apollo cache warnings when CI feature specs subscribe to GraphQL subscriptions.
When subscribeToMore handlers returned previous data unchanged, Apollo read an incomplete cache, wrote the incomplete result back, and logged Missing field warnings for every field the cache did not have. This occurred in two scenarios:
- Pipelines list: When query variables changed (tab switch, pagination), the cache had no
pipelinesfield for the new variables yet. The handler returned previous data unchanged, causing writes of incomplete results. Handlers now returnundefinedon paths that do not change the result. - Jobs list: The subscription selected fewer fields than the query (no
browseArtifactsPath, nocommitunderpipeline). New jobs and merged updates caused cache writes to miss those fields. A new fragmentjobs_table_job.fragment.graphqlis shared between query and subscription so they always select the same fields.
This MR eliminates the warnings in console output by:
- Creating a shared fragment for job node selection.
- Updating
updateQueryhandlers across CI pages to returnundefinedinstead of previous data when the result does not change. - Keeping handlers that build a new result unchanged.
References
- Part of section D of #628901 (console errors in feature specs)
- Console check and baseline allowlist MR that surfaced it: !255207 (closed)
- Reveal pipeline jobs showing the errors: https://gitlab.com/gitlab-org/gitlab/-/jobs/16462296271 and https://gitlab.com/gitlab-org/gitlab/-/jobs/16462296251
- Apollo Client source of the behaviour:
ObservableQuery.updateQueryin @apollo/client 3.5 (partial diff read, then writeQuery of the returned value)
Screenshots or screen recordings
Not applicable. This fix addresses console warnings only. The UI is unchanged.
How to set up and validate locally
- Run
yarn jest spec/frontend/ci/jobs_page spec/frontend/ci/pipelines_page. - In GDK open a project's CI/CD > Jobs page with the browser console open.
- Retry a job.
- On master the console shows
Missing field 'browseArtifactsPath' while writing resultandMissing field 'commit' while writing result. - On this branch the console shows nothing and the new job row appears.
- Open the Pipelines page.
- Click the Finished tab while a pipeline is running.
- Confirm no
Missing field 'pipelines'message appears.
MR acceptance checklist
This MR was evaluated against the acceptance checklist.