Add support for querying work items by references
Related to #427594 (closed)
What does this MR do and why?
To support using references in the linked items widget input we need to add support for querying work items by reference.
This query requires a context project and a list of references that can be:
-
URLs: The full URL for the work item, for example
"https://gitlab.com/gitlab-org/gitlab/-/work_items/427594"
-
Short references:
- A hash followed by the work item
IID
for items within the context project (e.g.#1
) - A project's full path followed by the IID for items that don't belong to the context project (e.g.
gitlab-org/plan-stage/okr-sandbox#674
).
- A hash followed by the work item
Note: We limit the number of items that can be queried at the time because rendering references is an expensive operation. This limit matches the maximum number of items that can be included in the work items input (10).
Note 2: The query doesn't support work items at the group level (either with a group context or a group-level reference) because these references are not supported yet. Regardless, group-level work items are still behind the FF namespace_level_work_items
, disabled by default.
Screenshots or screen recordings
How to set up and validate locally
Visit http://127.0.0.1:3000/-/graphql-explorer
and test the following query using existing references
query getWorkItems {
workItemsByReference(contextNamespacePath: "group-a/project-a", refs: ["#1", "group-a/project-a-2#4", "http://127.0.0.1:3000/public-group/public-project/-/work_items/6"]) {
edges {
node {
id
title
}
}
}
}
example response
{
"data": {
"workItemsByReference": {
"edges": [
{
"node": {
"id": "gid://gitlab/WorkItem/405",
"title": "Test Task"
}
},
{
"node": {
"id": "gid://gitlab/WorkItem/344",
"title": "Another Test Task"
}
},
{
"node": {
"id": "gid://gitlab/WorkItem/410",
"title": "Test Objective"
}
}
]
}
}
}
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.