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
0b47d540
Commit
0b47d540
authored
Sep 11, 2020
by
Tiger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add lookahead preloading for cluster agent tokens
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/40779
parent
28c3d8d4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
7 deletions
+30
-7
ee/app/graphql/ee/types/project_type.rb
ee/app/graphql/ee/types/project_type.rb
+1
-0
ee/app/graphql/resolvers/clusters/agents_resolver.rb
ee/app/graphql/resolvers/clusters/agents_resolver.rb
+14
-4
ee/spec/graphql/resolvers/clusters/agents_resolver_spec.rb
ee/spec/graphql/resolvers/clusters/agents_resolver_spec.rb
+15
-3
No files found.
ee/app/graphql/ee/types/project_type.rb
View file @
0b47d540
...
...
@@ -101,6 +101,7 @@ module EE
field
:cluster_agents
,
::
Types
::
Clusters
::
AgentType
.
connection_type
,
extras:
[
:lookahead
],
null:
true
,
description:
'Cluster agents associated with the project'
,
resolver:
::
Resolvers
::
Clusters
::
AgentsResolver
...
...
ee/app/graphql/resolvers/clusters/agents_resolver.rb
View file @
0b47d540
...
...
@@ -3,14 +3,24 @@
module
Resolvers
module
Clusters
class
AgentsResolver
<
BaseResolver
include
LooksAhead
type
Types
::
Clusters
::
AgentType
,
null:
true
alias_method
:project
,
:object
def
resolve
(
**
args
)
::
Clusters
::
AgentsFinder
.
new
(
project
,
context
[
:current_user
],
params:
args
)
.
execute
def
resolve_with_lookahead
(
**
args
)
apply_lookahead
(
::
Clusters
::
AgentsFinder
.
new
(
project
,
context
[
:current_user
],
params:
args
)
.
execute
)
end
private
def
preloads
{
tokens: :agent_tokens
}
end
end
end
...
...
ee/spec/graphql/resolvers/clusters/agents_resolver_spec.rb
View file @
0b47d540
...
...
@@ -5,24 +5,36 @@ require 'spec_helper'
RSpec
.
describe
Resolvers
::
Clusters
::
AgentsResolver
do
include
GraphqlHelpers
it
{
expect
(
described_class
).
to
be
<
LooksAhead
}
it
{
expect
(
described_class
.
type
).
to
eq
(
Types
::
Clusters
::
AgentType
)
}
it
{
expect
(
described_class
.
null
).
to
be_truthy
}
describe
'#resolve'
do
let_it_be
(
:user
)
{
create
(
:user
)
}
let
(
:finder
)
{
double
(
execute: :result
)
}
let
(
:finder
)
{
double
(
execute:
relation
)
}
let
(
:relation
)
{
double
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:args
)
{
Hash
(
key:
'value'
)
}
let
(
:ctx
)
{
Hash
(
current_user:
user
)
}
subject
{
resolve
(
described_class
,
obj:
project
,
args:
args
,
ctx:
ctx
)
}
let
(
:lookahead
)
do
double
(
selects?:
true
).
tap
do
|
selection
|
allow
(
selection
).
to
receive
(
:selection
).
and_return
(
selection
)
end
end
subject
{
resolve
(
described_class
,
obj:
project
,
args:
args
.
merge
(
lookahead:
lookahead
),
ctx:
ctx
)
}
it
'calls the agents finder'
do
expect
(
::
Clusters
::
AgentsFinder
).
to
receive
(
:new
)
.
with
(
project
,
user
,
params:
args
).
and_return
(
finder
)
expect
(
subject
).
to
eq
(
:result
)
expect
(
relation
).
to
receive
(
:preload
)
.
with
(
:agent_tokens
).
and_return
(
relation
)
expect
(
subject
).
to
eq
(
relation
)
end
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