From ee60128cefae3122f21987b72c60a268ddc8f6b9 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Thu, 31 Jan 2019 01:18:18 +0800 Subject: Add argument iids to IssuesResolver --- app/graphql/resolvers/issues_resolver.rb | 4 ++++ ...w-arguments-iid-for-issuesresolver-in-graphql.yml | 5 +++++ spec/graphql/resolvers/issues_resolver_spec.rb | 20 ++++++++++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 changelogs/unreleased/57063-implement-new-arguments-iid-for-issuesresolver-in-graphql.yml diff --git a/app/graphql/resolvers/issues_resolver.rb b/app/graphql/resolvers/issues_resolver.rb index 4ab3c13787a..95e66fb3b7c 100644 --- a/app/graphql/resolvers/issues_resolver.rb +++ b/app/graphql/resolvers/issues_resolver.rb @@ -4,6 +4,10 @@ module Resolvers class IssuesResolver < BaseResolver extend ActiveSupport::Concern + argument :iids, [GraphQL::ID_TYPE], + required: false, + description: 'The list of IIDs of issues, e.g., [1, 2]' + argument :search, GraphQL::STRING_TYPE, required: false argument :sort, Types::Sort, diff --git a/changelogs/unreleased/57063-implement-new-arguments-iid-for-issuesresolver-in-graphql.yml b/changelogs/unreleased/57063-implement-new-arguments-iid-for-issuesresolver-in-graphql.yml new file mode 100644 index 00000000000..b05ab07e14c --- /dev/null +++ b/changelogs/unreleased/57063-implement-new-arguments-iid-for-issuesresolver-in-graphql.yml @@ -0,0 +1,5 @@ +--- +title: Add argument iids for issues in GraphQL +merge_request: 24802 +author: +type: added diff --git a/spec/graphql/resolvers/issues_resolver_spec.rb b/spec/graphql/resolvers/issues_resolver_spec.rb index ca90673521c..1a54ab540fc 100644 --- a/spec/graphql/resolvers/issues_resolver_spec.rb +++ b/spec/graphql/resolvers/issues_resolver_spec.rb @@ -32,6 +32,26 @@ describe Resolvers::IssuesResolver do expect(resolve_issues).to contain_exactly(issue, issue2) end + + it 'finds a specific issue with iids' do + expect(resolve_issues(iids: issue.iid)).to contain_exactly(issue) + end + + it 'finds multiple issues with iids' do + expect(resolve_issues(iids: [issue.iid, issue2.iid])) + .to contain_exactly(issue, issue2) + end + + it 'finds only the issues within the project we are looking at' do + another_project = create(:project) + iids = [issue, issue2].map(&:iid) + + iids.each do |iid| + create(:issue, project: another_project, iid: iid) + end + + expect(resolve_issues(iids: iids)).to contain_exactly(issue, issue2) + end end def resolve_issues(args = {}, context = { current_user: current_user }) -- cgit v1.2.1