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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
0f14b628
Commit
0f14b628
authored
May 20, 2019
by
Brett Walker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use BatchModelLoader for parent in GroupType
parent
d951f047
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
2 deletions
+36
-2
app/graphql/types/group_type.rb
app/graphql/types/group_type.rb
+4
-2
spec/graphql/resolvers/group_resolver_spec.rb
spec/graphql/resolvers/group_resolver_spec.rb
+32
-0
No files found.
app/graphql/types/group_type.rb
View file @
0f14b628
...
...
@@ -8,14 +8,16 @@ module Types
expose_permissions
Types
::
PermissionTypes
::
Group
field
:web_url
,
GraphQL
::
STRING_TYPE
,
null:
tru
e
field
:web_url
,
GraphQL
::
STRING_TYPE
,
null:
fals
e
field
:avatar_url
,
GraphQL
::
STRING_TYPE
,
null:
true
,
resolve:
->
(
group
,
args
,
ctx
)
do
group
.
avatar_url
(
only_path:
false
)
end
if
::
Group
.
supports_nested_objects?
field
:parent
,
GroupType
,
null:
true
field
:parent
,
GroupType
,
null:
true
,
resolve:
->
(
obj
,
_args
,
_ctx
)
{
Gitlab
::
Graphql
::
Loaders
::
BatchModelLoader
.
new
(
Group
,
obj
.
parent_id
).
find
}
end
end
end
spec/graphql/resolvers/group_resolver_spec.rb
0 → 100644
View file @
0f14b628
# frozen_string_literal: true
require
'spec_helper'
describe
Resolvers
::
GroupResolver
do
include
GraphqlHelpers
set
(
:group1
)
{
create
(
:group
)
}
set
(
:group2
)
{
create
(
:group
)
}
describe
'#resolve'
do
it
'batch-resolves groups by full path'
do
paths
=
[
group1
.
full_path
,
group2
.
full_path
]
result
=
batch
(
max_queries:
1
)
do
paths
.
map
{
|
path
|
resolve_group
(
path
)
}
end
expect
(
result
).
to
contain_exactly
(
group1
,
group2
)
end
it
'resolves an unknown full_path to nil'
do
result
=
batch
{
resolve_group
(
'unknown/project'
)
}
expect
(
result
).
to
be_nil
end
end
def
resolve_group
(
full_path
)
resolve
(
described_class
,
args:
{
full_path:
full_path
})
end
end
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