Commit 30918929 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Implement singular iid for IssuesResolver and ProjectType

parent 564b86a3
......@@ -2,7 +2,9 @@
module Resolvers
class IssuesResolver < BaseResolver
extend ActiveSupport::Concern
argument :iid, GraphQL::ID_TYPE,
required: false,
description: 'The IID of the issue, e.g., "1"'
argument :iids, [GraphQL::ID_TYPE],
required: false,
......@@ -22,6 +24,7 @@ module Resolvers
# Will need to be be made group & namespace aware with
# https://gitlab.com/gitlab-org/gitlab-ce/issues/54520
args[:project_id] = project.id
args[:iids] ||= [args[:iid]].compact
IssuesFinder.new(context[:current_user], args).execute
end
......
......@@ -17,7 +17,7 @@ module Resolvers
def resolve(**args)
return unless project.present?
args[:iids] ||= [args[:iid]]
args[:iids] ||= [args[:iid]].compact
args[:iids].map(&method(:batch_load))
.select(&:itself) # .compact doesn't work on BatchLoader
......
......@@ -85,6 +85,11 @@ module Types
null: true,
resolver: Resolvers::IssuesResolver
field :issue,
Types::IssueType,
null: true,
resolver: Resolvers::IssuesResolver.single
field :pipelines,
Types::Ci::PipelineType.connection_type,
null: false,
......
......@@ -33,6 +33,10 @@ describe Resolvers::IssuesResolver do
expect(resolve_issues).to contain_exactly(issue, issue2)
end
it 'finds a specific issue with iid' do
expect(resolve_issues(iid: issue.iid)).to contain_exactly(issue)
end
it 'finds a specific issue with iids' do
expect(resolve_issues(iids: issue.iid)).to contain_exactly(issue)
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