Skip to content
Snippets Groups Projects
Commit 30918929 authored by Lin Jen-Shin's avatar Lin Jen-Shin
Browse files

Implement singular iid for IssuesResolver and ProjectType

parent 564b86a3
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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,
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -3,8 +3,8 @@
module Resolvers
class MergeRequestsResolver < BaseResolver
argument :iid, GraphQL::ID_TYPE,
required: false,
description: 'The IID of the merge request, e.g., "1"'
required: false,
description: 'The IID of the merge request, e.g., "1"'
 
argument :iids, [GraphQL::ID_TYPE],
required: false,
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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,
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment