Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
1d4bf92a
Commit
1d4bf92a
authored
Sep 03, 2021
by
Eulyeon Ko
Committed by
Eulyeon Ko
Sep 06, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix n+1 for award_emoji field when fetching epics
Changelog: performance EE: true
parent
08fb7d51
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
2 deletions
+35
-2
ee/app/graphql/resolvers/epics_resolver.rb
ee/app/graphql/resolvers/epics_resolver.rb
+2
-1
ee/app/graphql/types/epic_type.rb
ee/app/graphql/types/epic_type.rb
+2
-1
ee/spec/requests/api/graphql/epics/epic_resolver_spec.rb
ee/spec/requests/api/graphql/epics/epic_resolver_spec.rb
+31
-0
No files found.
ee/app/graphql/resolvers/epics_resolver.rb
View file @
1d4bf92a
...
...
@@ -98,7 +98,8 @@ module Resolvers
def
preloads
{
parent:
[
:parent
],
events:
{
events:
[
:target
]
}
events:
{
events:
[
:target
]
},
award_emoji:
[
:award_emoji
]
}
end
...
...
ee/app/graphql/types/epic_type.rb
View file @
1d4bf92a
...
...
@@ -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
,
...
...
ee/spec/requests/api/graphql/epics/epic_resolver_spec.rb
View file @
1d4bf92a
...
...
@@ -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 {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment