Fix WorkItem Hierarchy paginaton cursor issue
What does this MR do and why?
Fix pagination issue with work_item children
Issue: #466229 (closed)
Steps to test
- Create a Epic work item
- Add enough children to paginate in the list
- Use the following query and check if we are getting correct results for every page
Query
query workItemChildItems(
  $fullPath: ID!
  $iid: String!
  $after: String
  $pageSize: Int
) {
  workspace: namespace(fullPath: $fullPath) {
    id
    workItem(iid: $iid) {
      id
      iid
      widgets {
        ... on WorkItemWidgetHierarchy {
          children(first: $pageSize, after: $after) {
            pageInfo {
              ...PageInfo
              __typename
            }
            nodes {
              id
              iid
              title
            }
          }
        }
      }      
    }    
  }
}
fragment PageInfo on PageInfo {
  hasNextPage
  hasPreviousPage
  startCursor
  endCursor
  __typename
}Variables:
{
  "fullPath": "flightjs",
  "iid": "6",
  "after": "",
  "pageSize": 5
}SQL Queries
First Page
SELECT "issues"."id", "issues"."title", "issues"."author_id", "issues"."project_id", "issues"."created_at", "issues"."updated_at",
 "issues"."description", "issues"."milestone_id", "issues"."iid", "issues"."updated_by_id", "issues"."weight", "issues"."confidential",
 "issues"."due_date", "issues"."moved_to_id", "issues"."lock_version", "issues"."title_html", "issues"."description_html",
 "issues"."time_estimate", "issues"."relative_position", "issues"."service_desk_reply_to", "issues"."cached_markdown_version",
 "issues"."last_edited_at", "issues"."last_edited_by_id", "issues"."discussion_locked", "issues"."closed_at", "issues"."closed_by_id",
 "issues"."state_id", "issues"."duplicated_to_id", "issues"."promoted_to_epic_id", "issues"."health_status", "issues"."external_key",
 "issues"."sprint_id", "issues"."blocking_issues_count", "issues"."upvotes_count", "issues"."work_item_type_id", "issues"."namespace_id",
 "issues"."start_date", "issues"."imported_from", "work_item_parent_links"."relative_position" AS parent_link_relative_position 
FROM "issues" INNER JOIN "work_item_parent_links" ON "issues"."id" = "work_item_parent_links"."work_item_id" 
WHERE "work_item_parent_links"."work_item_parent_id" = 648 
ORDER BY "work_item_parent_links"."relative_position" ASC NULLS LAST, "issues"."id" DESC LIMIT 6Second Page
SELECT "issues"."id", "issues"."title", "issues"."author_id", "issues"."project_id", "issues"."created_at", "issues"."updated_at",
 "issues"."description", "issues"."milestone_id", "issues"."iid", "issues"."updated_by_id", "issues"."weight", "issues"."confidential",
 "issues"."due_date", "issues"."moved_to_id", "issues"."lock_version", "issues"."title_html", "issues"."description_html",
 "issues"."time_estimate", "issues"."relative_position", "issues"."service_desk_reply_to", "issues"."cached_markdown_version",
 "issues"."last_edited_at", "issues"."last_edited_by_id", "issues"."discussion_locked", "issues"."closed_at", "issues"."closed_by_id",
 "issues"."state_id", "issues"."duplicated_to_id", "issues"."promoted_to_epic_id", "issues"."health_status", "issues"."external_key",
 "issues"."sprint_id", "issues"."blocking_issues_count", "issues"."upvotes_count", "issues"."work_item_type_id", "issues"."namespace_id",
 "issues"."start_date", "issues"."imported_from", "work_item_parent_links"."relative_position" AS parent_link_relative_position,
 "work_item_parent_links"."relative_position" AS parent_link_relative_position 
FROM "issues" INNER JOIN "work_item_parent_links" ON "issues"."id" = "work_item_parent_links"."work_item_id" 
WHERE "work_item_parent_links"."work_item_parent_id" = 648 AND (2309 IS NULL AND "work_item_parent_links"."relative_position" IS NULL AND "issues"."id" < 656 OR 2309 IS NOT NULL AND "work_item_parent_links"."relative_position" IS NULL OR 2309 IS NOT NULL AND "work_item_parent_links"."relative_position" > 2309 OR 2309 IS NOT NULL AND "work_item_parent_links"."relative_position" = 2309 AND "issues"."id" < 656) 
ORDER BY "work_item_parent_links"."relative_position" ASC NULLS LAST, "issues"."id" DESC LIMIT 6Edited  by Abhilash Kotte