debian-mirror-gitlab/app/graphql/resolvers/achievements/achievements_resolver.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

36 lines
962 B
Ruby
Raw Normal View History

2023-05-27 22:25:52 +05:30
# frozen_string_literal: true
module Resolvers
module Achievements
class AchievementsResolver < BaseResolver
include LooksAhead
type ::Types::Achievements::AchievementType.connection_type, null: true
2023-06-20 00:43:36 +05:30
argument :ids, [::Types::GlobalIDType[::Achievements::Achievement]],
required: false,
description: 'Filter achievements by IDs.'
2023-05-27 22:25:52 +05:30
alias_method :namespace, :object
2023-06-20 00:43:36 +05:30
def resolve_with_lookahead(**args)
2023-05-27 22:25:52 +05:30
return ::Achievements::Achievement.none if Feature.disabled?(:achievements, namespace)
2023-06-20 00:43:36 +05:30
params = {}
params[:ids] = args[:ids].map(&:model_id) if args[:ids].present?
achievements = ::Achievements::AchievementsFinder.new(namespace, params).execute
apply_lookahead(achievements)
2023-05-27 22:25:52 +05:30
end
private
def preloads
{
user_achievements: [{ user_achievements: [:user, :awarded_by_user, :revoked_by_user] }]
}
end
end
end
end