Make operation counter include non-deduplicated queries

What does this MR do and why?

The window.pendingApolloRequests counter tracks pending GraphQL operations for the wait_for_requests helpers in feature specs and QA suites. It counts deduplicated queries (via inFlightLinkObservables) plus mutations via a separate counter. Queries that opt out of deduplication would be invisible to this counter, which would let wait_for_requests return while such a query is still in flight.

This MR extends the counter to track every operation that skips inFlightLinkObservables: mutations and queries whose context carries Apollo's forceFetch flag (set when deduplication is off). It renames pendingApolloMutations to pendingApolloNonDedupedOperations and mutationCounterLink to operationCounterLink to reflect this.

It also makes getOperationFinishedLink run the finished callback exactly once per operation, including when the operation is unsubscribed before completion, so the counter cannot get stuck.

One query opts out of deduplication at the moment, but this MR will not have a big change in current behavior. It improves/prepares the test infrastructure for !252222 (merged), which introduces more non-deduplicated queries and should merge after this MR, so wait_for_requests counts those queries from the start.

Screenshots or screen recordings

No visual change. This is test-infrastructure accuracy work with no user-facing effect.

How to set up and validate locally

Run the Jest suites for operation counting:

yarn jest spec/frontend/lib/graphql_pending_requests_spec.js spec/frontend/lib/apollo/operation_finished_link_spec.js spec/frontend/lib/graphql_spec.js

The new graphql_pending_requests_spec.js exercises window.pendingApolloRequests through a real client. Its tests for non-deduplicated queries fail without this change (the counter reads 0 while such requests are in flight). The pre-existing suites pass unchanged, confirming no behavior change for current (fully deduplicated) operations.

References

Edited by Miguel Rincon

Merge request reports

Loading
Loading