Skip to content

Graphql: N+1 in IssueType

This is a follow-up from https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/11575#note_167036203).

When listing issues with assignees and labels, then N+1 SQL queries are done. The problem is that these associations use only the basic connection_type: https://gitlab.com/gitlab-org/gitlab-ce/blob/11-11-stable/app/graphql/types/issue_type.rb#L23

To avoid N+1 issue, we should use a batchloader or a resolver to load assignees/labels.

You can reproduce this by running following query in locally using graphql-explorer:

query{
  project(fullPath:"flightjs/flight") {
    name
    issues {
      edges {
        node {
          labels {
            edges {
              node {
                title
              }
            }
          }
          assignees {
            edges {
              node {
                name
              }
            }
          }
        }
      }
    }
  }
}
Edited by 🤖 GitLab Bot 🤖