Commit aabe5f35 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'fix-n1-for-award-emoji-epics' into 'master'

Fix n+1 for award_emoji field when fetching epics

See merge request gitlab-org/gitlab!69528
parents 6596a65d 1d4bf92a
......@@ -98,7 +98,8 @@ module Resolvers
def preloads
{
parent: [:parent],
events: { events: [:target] }
events: { events: [:target] },
award_emoji: [:award_emoji]
}
end
......
......@@ -145,7 +145,8 @@ module Types
field :award_emoji,
Types::AwardEmojis::AwardEmojiType.connection_type,
null: true,
description: 'A list of award emojis associated with the epic.'
description: 'A list of award emojis associated with the epic.',
authorize: :read_emoji
field :ancestors, Types::EpicType.connection_type,
null: true,
......
......@@ -130,6 +130,37 @@ RSpec.describe 'getting epics information' do
end
end
describe 'N+1 query checks' do
let_it_be(:epic_a) { create(:epic, group: group) }
let_it_be(:epic_b) { create(:epic, group: group) }
let(:extra_iid_for_second_query) { epic_b.iid.to_s }
let(:search_params) { { iids: [epic_a.iid.to_s] } }
def execute_query
query = graphql_query_for(
:group,
{ full_path: group.full_path },
query_graphql_field(
:epics, search_params,
query_graphql_field(:nodes, nil, requested_fields)
)
)
post_graphql(query, current_user: user)
end
context 'when requesting `award_emoji`' do
let(:requested_fields) { 'awardEmoji { nodes { name } }' }
before do
create(:award_emoji, awardable: epic_a, user: user)
create(:award_emoji, awardable: epic_b, user: user)
end
include_examples 'N+1 query check'
end
end
def query_epics_with_events(number)
epics_field = <<~NODE
epics {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment