Loading
Fetch work item to-do items in their own query
What does this MR do and why?
To-do items were part of the work item detail query even though a logged-out visitor can never have any. This moves them into a dedicated query owned by a new WorkItemTodosWidget, which skips the request entirely when the user isn't signed in. The detail query keeps only currentUserTodos { type }, which costs nothing now that the widget accessors are free, and is what the toolbar gates on.
Implementation notes
Here's a high level summary of what this MR does:
- We've split the
currentUserTodoswidget from base work item query to its own query and subscription. - When page loads and if user is logged in,
namespaceWorkItemwould fetch onlytypefor this widget, which is returned only if widget is supported on a given work item type, this also controls widget visibility like it used to inmaster. - The
work_items/components/work_item_todos_widget.vuecomponent now owns its query & subscription to fetch todo state for current user, as well as observes work item for any changes to todo state (eg; usage of/todoor/donequick actions by same user from anywhere else).- Having a subscription ensures that real-time behaviour or component remains intact even after query has split.
- If you enabled
work_item_features_fieldflag globally on GDK and access any work item anonymously, you'd still see the errorWork Item not foundas this MR alone won't solve that issue, it is part of a series of MRs where we're splitting widgets into their own queries.currentUserTodos- This MRlinkedResources- !252578 (merged)crmContacts- !252569 (merged)- Only after all 3 MRs get merged is when we'll be able to access work items anonymously with FF enabled globally, assuming something else isn't added to main query again to breach complexity.
😬
References
- To-do widget migration: #603236 (closed)
- Rollout issue: #587972
- Migration epic: gitlab-org#20609
Screenshots or screen recordings
| Logged In | Anonymous |
|---|---|
How to set up and validate locally
- Enable the flag with
Feature.enable(:work_item_features_field). - Open a work item and confirm the to-do toggle renders with the correct label.
- Toggle it and confirm in the network tab that only
workItemUpdateCurrentUserTodosfires, with nonamespaceWorkItemorworkItemCurrentUserTodosrefetch. - Reload and confirm the state persisted.
- Sign out, open a public work item, and confirm
workItemCurrentUserTodosis never requested.- Note that we're still not under the query limit so while being signed-out, you'll still see
namespaceWorkItemquery to fail withQuery has complexity of 217, which exceeds max complexity of 200error, but you only need to verify thatworkItemCurrentUserTodosis not called.
- Note that we're still not under the query limit so while being signed-out, you'll still see
- Repeat signed in with the flag disabled to check the
widgetspath.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Edited by Kushal Pandya