diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2019-02-12 19:31:18 +0300 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2019-02-14 10:52:17 +0300 |
commit | 30918929ad079a591b85303d6662ec0a43c5df04 (patch) | |
tree | f35921b065d6d8a748768c2ec1bb05bbe401003b /app | |
parent | 564b86a3145cd5f7eae8071ef244dc684bcd5031 (diff) |
Implement singular iid for IssuesResolver and ProjectType
Diffstat (limited to 'app')
-rw-r--r-- | app/graphql/resolvers/issues_resolver.rb | 5 | ||||
-rw-r--r-- | app/graphql/resolvers/merge_requests_resolver.rb | 6 | ||||
-rw-r--r-- | app/graphql/types/project_type.rb | 5 |
3 files changed, 12 insertions, 4 deletions
diff --git a/app/graphql/resolvers/issues_resolver.rb b/app/graphql/resolvers/issues_resolver.rb index 95e66fb3b7c..fd1b46ba860 100644 --- a/app/graphql/resolvers/issues_resolver.rb +++ b/app/graphql/resolvers/issues_resolver.rb @@ -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 diff --git a/app/graphql/resolvers/merge_requests_resolver.rb b/app/graphql/resolvers/merge_requests_resolver.rb index 15055db633a..0b394386f97 100644 --- a/app/graphql/resolvers/merge_requests_resolver.rb +++ b/app/graphql/resolvers/merge_requests_resolver.rb @@ -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, @@ -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 diff --git a/app/graphql/types/project_type.rb b/app/graphql/types/project_type.rb index 9d21a7dee67..d25c8c8bd90 100644 --- a/app/graphql/types/project_type.rb +++ b/app/graphql/types/project_type.rb @@ -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, |