debian-mirror-gitlab/app/graphql/resolvers/ci/variables_resolver.rb

28 lines
693 B
Ruby
Raw Normal View History

2023-04-23 21:23:45 +05:30
# frozen_string_literal: true
module Resolvers
module Ci
class VariablesResolver < BaseResolver
type Types::Ci::InstanceVariableType.connection_type, null: true
argument :sort, ::Types::Ci::VariableSortEnum,
required: false,
description: 'Sort order of results.'
def resolve(**args)
if parent.is_a?(Group) || parent.is_a?(Project)
parent.variables.order_by(args[:sort])
elsif current_user&.can_admin_all_resources?
::Ci::InstanceVariable.order_by(args[:sort])
end
end
private
def parent
object.respond_to?(:sync) ? object.sync : object
end
end
end
end