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
f07be71b
Commit
f07be71b
authored
Mar 31, 2021
by
pburdette
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Apply reviewer feedback
Move authorize to resolver and fix a few problems.
parent
67cc6cdd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
11 deletions
+12
-11
app/graphql/resolvers/project_jobs_resolver.rb
app/graphql/resolvers/project_jobs_resolver.rb
+9
-6
app/graphql/types/project_type.rb
app/graphql/types/project_type.rb
+2
-4
spec/graphql/resolvers/project_jobs_resolver_spec.rb
spec/graphql/resolvers/project_jobs_resolver_spec.rb
+1
-1
No files found.
app/graphql/resolvers/project_jobs_resolver.rb
View file @
f07be71b
...
...
@@ -2,16 +2,19 @@
module
Resolvers
class
ProjectJobsResolver
<
BaseResolver
include
Gitlab
::
Graphql
::
Authorize
::
AuthorizeResource
include
LooksAhead
type
::
Types
::
Ci
::
JobType
.
connection_type
,
null:
true
a
lias_method
:project
,
:object
authorize
:read_build
a
uthorizes_object!
argument
:statuses
,
[
::
Types
::
Ci
::
JobStatusEnum
],
required:
false
,
description:
'Filter jobs by status.'
alias_method
:project
,
:object
def
ready?
(
**
args
)
context
[
self
.
class
]
||=
{
executions:
0
}
context
[
self
.
class
][
:executions
]
+=
1
...
...
@@ -29,10 +32,10 @@ module Resolvers
private
def
preloads
[
{
artifacts: :job_artifacts
}
,
{
pipeline: :user
}
]
{
artifacts:
[
:job_artifacts
]
,
pipeline:
[
:user
]
}
end
end
end
app/graphql/types/project_type.rb
View file @
f07be71b
...
...
@@ -186,10 +186,8 @@ module Types
field
:jobs
,
Types
::
Ci
::
JobType
.
connection_type
,
null:
true
,
description:
'Jobs of a project, only jobs of a single project can be requested at a time.'
,
extras:
[
:lookahead
],
resolver:
Resolvers
::
ProjectJobsResolver
,
authorize: :read_build
description:
'Jobs of a single project.'
,
resolver:
Resolvers
::
ProjectJobsResolver
field
:pipelines
,
null:
true
,
...
...
spec/graphql/resolvers/project_jobs_resolver_spec.rb
View file @
f07be71b
...
...
@@ -21,7 +21,7 @@ RSpec.describe Resolvers::ProjectJobsResolver do
describe
'#resolve'
do
context
'with statuses argument'
do
let
(
:args
)
{
{
statuses:
[
Types
::
Ci
::
JobStatusEnum
.
values
[
'SUCCESS'
].
value
]
}
}
let
(
:args
)
{
{
statuses:
[
Types
::
Ci
::
JobStatusEnum
.
coerce_isolated_input
(
'SUCCESS'
)
]
}
}
it
{
is_expected
.
to
contain_exactly
(
build_one
,
build_two
)
}
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