Welcome to mirror list, hosted at ThFree Co, Russian Federation.

autocompleted_user_type.rb « users « types « graphql « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8a70f398954cdecede91f367c006601ce03026c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# frozen_string_literal: true

module Types
  module Users
    class AutocompletedUserType < ::Types::UserType
      graphql_name 'AutocompletedUser'

      authorize :read_user

      field :merge_request_interaction, Types::UserMergeRequestInteractionType,
        null: true,
        description: 'Merge request state related to the user.' do
          argument :id, ::Types::GlobalIDType[::MergeRequest], required: true,
            description: 'Global ID of the merge request.'
        end

      def merge_request_interaction(id: nil)
        Gitlab::Graphql::Lazy.with_value(GitlabSchema.object_from_id(id, expected_class: ::MergeRequest)) do |mr|
          ::Users::MergeRequestInteraction.new(user: object.user, merge_request: mr) if mr
        end
      end
    end
  end
end