Commit f07be71b authored by pburdette's avatar pburdette

Apply reviewer feedback

Move authorize to resolver
and fix a few problems.
parent 67cc6cdd
......@@ -2,16 +2,19 @@
module Resolvers
class ProjectJobsResolver < BaseResolver
include Gitlab::Graphql::Authorize::AuthorizeResource
include LooksAhead
type ::Types::Ci::JobType.connection_type, null: true
alias_method :project, :object
authorize :read_build
authorizes_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
......@@ -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,
......
......@@ -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
......
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