Reduce workItemNotesByIid query complexity
What does this MR do and why?
Issue: #482512 (closed)
Reduce workItemNotesByIid query complexity
The workItemNotesByIid query exceeded the maximum complexity for anonymous (signed out) users, which is set to 200.
The query had a complexity of 218. By reducing the page size, we reduce that complexity to ~180, which gives us some room in the case we need to query more fields in the future.
Changelog: fixed
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
| Before | After |
|---|---|
How to set up and validate locally
- Visit a work item as a signed out user
- Before: notes did not load. After: notes are loading again
How to run the workItemNotesByIid query and see the complexity:
- Go to http://gdk.test:3000/-/graphql-explorer
- Paste the following query
Query
query workItemNotesByIid($fullPath: ID!, $iid: String!, $after: String, $pageSize: Int) {
queryComplexity {
score
limit
}
workspace: namespace(fullPath: $fullPath) {
id
workItem(iid: $iid) {
id
iid
namespace {
id
__typename
}
widgets {
... on WorkItemWidgetNotes {
type
discussions(first: $pageSize, after: $after, filter: ALL_NOTES) {
pageInfo {
...PageInfo
__typename
}
nodes {
id
notes {
nodes {
...WorkItemNote
__typename
}
__typename
}
__typename
}
__typename
}
__typename
}
__typename
}
__typename
}
__typename
}
}
fragment PageInfo on PageInfo {
hasNextPage
hasPreviousPage
startCursor
endCursor
__typename
}
fragment WorkItemNote on Note {
id
body
bodyHtml
system
internal
systemNoteIconName
createdAt
lastEditedAt
url
authorIsContributor
maxAccessLevelOfAuthor
lastEditedBy {
...User
webPath
__typename
}
discussion {
id
resolved
resolvable
resolvedBy {
id
name
__typename
}
__typename
}
author {
...User
__typename
}
awardEmoji {
nodes {
...AwardEmojiFragment
__typename
}
__typename
}
userPermissions {
adminNote
awardEmoji
readNote
createNote
resolveNote
repositionNote
__typename
}
systemNoteMetadata {
id
descriptionVersion {
id
description
diff
diffPath
deletePath
canDelete
deleted
__typename
}
__typename
}
__typename
}
fragment User on User {
id
avatarUrl
name
username
webUrl
webPath
__typename
}
fragment AwardEmojiFragment on AwardEmoji {
name
user {
id
name
__typename
}
__typename
}
- Set the variables (change
fullPathandiidaccordingly`:
{
"pageSize": 20,
"fullPath": "flightjs",
"iid": "235"
}
When changing the pageSize from 20 to 30 (previous default) you will see how the query complexity exceeds 200.
Setting it to 20 fixes it as the complexity is reduced to 180 (although queryComplexity query itself adds some complexity).