Class: Resolvers::GroupMembers::NotificationEmailResolver

Inherits:
BaseResolver
  • Object
show all
Includes:
Gitlab::Graphql::Authorize::AuthorizeResource
Defined in:
app/graphql/resolvers/group_members/notification_email_resolver.rb

Constant Summary

Constants included from Gitlab::Graphql::Authorize::AuthorizeResource

Gitlab::Graphql::Authorize::AuthorizeResource::ConfigurationError, Gitlab::Graphql::Authorize::AuthorizeResource::RESOURCE_ACCESS_ERROR

Instance Method Summary collapse

Methods included from Gitlab::Graphql::Authorize::AuthorizeResource

#authorized_find!, #authorized_resource?, #find_object, #raise_resource_not_available_error!

Methods inherited from BaseResolver

as_single, authorization, authorized?, before_connection_authorization, before_connection_authorization_block, calls_gitaly!, complexity, complexity_multiplier, #current_user, field_options, last, #object, #offset_pagination, requires_argument!, resolver_complexity, #select_result, single, #single?, single_definition_blocks, singular_type, when_single

Methods included from Gitlab::Utils::Override

#extended, extensions, #included, #method_added, #override, #prepended, #queue_verification, verify!

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Instance Method Details

#authorize!Object


20
21
22
# File 'app/graphql/resolvers/group_members/notification_email_resolver.rb', line 20

def authorize!
  raise_resource_not_available_error! unless user_is_admin?
end

#resolveObject


10
11
12
13
14
15
16
17
18
# File 'app/graphql/resolvers/group_members/notification_email_resolver.rb', line 10

def resolve
  authorize!

  BatchLoader::GraphQL.for(object.user_id).batch do |user_ids, loader|
    User.find(user_ids).each do |user|
      loader.call(user.id, user.notification_email_for(object.group))
    end
  end
end

#user_is_admin?Boolean

Returns:

  • (Boolean)

24
25
26
# File 'app/graphql/resolvers/group_members/notification_email_resolver.rb', line 24

def user_is_admin?
  context[:current_user].present? && context[:current_user].can_admin_all_resources?
end