2020-09-14 11:09:28 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Resolvers
|
|
|
|
class MembersResolver < BaseResolver
|
|
|
|
include Gitlab::Graphql::Authorize::AuthorizeResource
|
|
|
|
include LooksAhead
|
|
|
|
|
2020-11-17 07:09:15 -05:00
|
|
|
type Types::MemberInterface.connection_type, null: true
|
|
|
|
|
2020-09-14 11:09:28 -04:00
|
|
|
argument :search, GraphQL::STRING_TYPE,
|
|
|
|
required: false,
|
2021-01-11 19:10:42 -05:00
|
|
|
description: 'Search query.'
|
2020-09-14 11:09:28 -04:00
|
|
|
|
|
|
|
def resolve_with_lookahead(**args)
|
|
|
|
authorize!(object)
|
|
|
|
|
2020-12-02 01:09:50 -05:00
|
|
|
relations = args.delete(:relations)
|
|
|
|
|
|
|
|
apply_lookahead(finder_class.new(object, current_user, params: args).execute(include_relations: relations))
|
2020-09-14 11:09:28 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2021-04-09 08:09:12 -04:00
|
|
|
def preloads
|
|
|
|
{
|
|
|
|
user: [:user, :source]
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2020-09-14 11:09:28 -04:00
|
|
|
def finder_class
|
|
|
|
# override in subclass
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|