summaryrefslogtreecommitdiff
path: root/app/graphql/resolvers/members_resolver.rb
blob: 827db54134a1d4c1d6d02de654733a863e0634c5 (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
25
26
27
28
29
30
31
32
33
34
# frozen_string_literal: true

module Resolvers
  class MembersResolver < BaseResolver
    include Gitlab::Graphql::Authorize::AuthorizeResource
    include LooksAhead

    type Types::MemberInterface.connection_type, null: true

    argument :search, GraphQL::Types::String,
              required: false,
              description: 'Search query.'

    def resolve_with_lookahead(**args)
      authorize!(object)

      relations = args.delete(:relations)

      apply_lookahead(finder_class.new(object, current_user, params: args).execute(include_relations: relations))
    end

    private

    def preloads
      {
        user: [:user, :source]
      }
    end

    def finder_class
      # override in subclass
    end
  end
end