Skip to content

Draft: Increase max page size of child items to 1000

Rajan Mistry requested to merge 463881-load-child-items-in-batch into master

What does this MR do and why?

Increase the max_page_size on Child items widget of work items in the backend.

️ Note: This change will be temporary and will be removed once pagination is available after closing #463881 (closed).

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

No visual changes

How to set up and validate locally

Prerequisites:

  1. Enable the OKRs feature as mentioned in the OKRs docs (e.g. ::Feature.enabled?(:okrs_mvc, Project.find(<PROJECT_ID>)) and the namespace must have Ultimate plan).
  2. Enable Epic work items
    1. Feature.enable(:namespace_level_work_items)
    2. Feature.enable(:work_item_epics)

Steps to verify:

  1. Login with any user

  2. Go to any Groups > Epics

  3. Create a Epic

  4. Run the following script

    parent_epic = Epic.last # Epic.last for last created epic
    parent_epic_work_item = parent_epic.work_item 
    project = Project.find(27) # project where you want to create the issues in
    user = User.where(username: 'root').first # the user you want to create the work item with
    
    (0..105).each do |i|
      WorkItems::CreateService.new(container: project, perform_spam_check: false, current_user: user, params: { title: "Work item #{i}" }, widget_params: { hierarchy_widget: { parent: parent_epic_work_item } } ).execute
    end
  5. Apply the diff for frontend changes

    diff --git a/app/assets/javascripts/graphql_shared/issuable_client.js b/app/assets/javascripts/graphql_shared/issuable_client.js
    index 903cd27232acc64..35e0363f473f3b3 100644
    --- a/app/assets/javascripts/graphql_shared/issuable_client.js
    +++ b/app/assets/javascripts/graphql_shared/issuable_client.js
    @@ -80,6 +80,15 @@ export const config = {
               },
             },
           },
    +      WorkItemWidgetHierarchy: {
    +        fields: {
    +          // If we add any key args, the children field becomes children({"first":10}) and
    +          // kills any possibility to handle it on the widget level without hardcoding a string.
    +          children: {
    +            keyArgs: false,
    +          },
    +        },
    +      },
           WorkItem: {
             fields: {
               // widgets policy because otherwise the subscriptions invalidate the cache
    diff --git a/app/assets/javascripts/work_items/graphql/work_item_tree.query.graphql b/app/assets/javascripts/work_items/graphql/work_item_tree.query.graphql
    index 7784ae61580853e..9e9a47ef9de54e7 100644
    --- a/app/assets/javascripts/work_items/graphql/work_item_tree.query.graphql
    +++ b/app/assets/javascripts/work_items/graphql/work_item_tree.query.graphql
    @@ -23,7 +23,7 @@ query workItemTreeQuery($id: WorkItemID!) {
             parent {
               id
             }
    -        children {
    +        children(first: 1000) {
               nodes {
                 id
                 iid
    diff --git a/app/assets/javascripts/work_items/graphql/work_item_widgets.fragment.graphql b/app/assets/javascripts/work_items/graphql/work_item_widgets.fragment.graphql
    index 76ce3de770ee35f..d7f458a8022511c 100644
    --- a/app/assets/javascripts/work_items/graphql/work_item_widgets.fragment.graphql
    +++ b/app/assets/javascripts/work_items/graphql/work_item_widgets.fragment.graphql
    @@ -69,7 +69,7 @@ fragment WorkItemWidgets on WorkItemWidget {
             iconName
           }
         }
    -    children {
    +    children(first: 1000) {
           nodes {
             id
             iid
    diff --git a/ee/app/assets/javascripts/work_items/graphql/work_item_widgets.fragment.graphql b/ee/app/assets/javascripts/work_items/graphql/work_item_widgets.fragment.graphql
    index fdc9262b62031e1..705458170ada8d5 100644
    --- a/ee/app/assets/javascripts/work_items/graphql/work_item_widgets.fragment.graphql
    +++ b/ee/app/assets/javascripts/work_items/graphql/work_item_widgets.fragment.graphql
    @@ -79,7 +79,7 @@ fragment WorkItemWidgets on WorkItemWidget {
             iconName
           }
         }
    -    children {
    +    children(first: 1000) {
           nodes {
             id
             iid
     
  6. Go to Epic detail page

  7. Check if 105 items are loaded

Related to #463881 (closed)

Edited by Rajan Mistry

Merge request reports

Loading