debian-mirror-gitlab/app/graphql/resolvers/package_details_resolver.rb

27 lines
857 B
Ruby
Raw Normal View History

2021-03-08 18:12:59 +05:30
# frozen_string_literal: true
module Resolvers
class PackageDetailsResolver < BaseResolver
2021-04-29 21:17:54 +05:30
type ::Types::Packages::PackageDetailsType, null: true
2021-03-11 19:13:27 +05:30
2021-03-08 18:12:59 +05:30
argument :id, ::Types::GlobalIDType[::Packages::Package],
required: true,
2021-11-11 11:23:49 +05:30
description: 'Global ID of the package.'
2021-03-08 18:12:59 +05:30
2021-04-29 21:17:54 +05:30
def ready?(**args)
context[self.class] ||= { executions: 0 }
context[self.class][:executions] += 1
raise GraphQL::ExecutionError, "Package details can be requested only for one package at a time" if context[self.class][:executions] > 1
super
end
2021-03-08 18:12:59 +05:30
def resolve(id:)
# TODO: remove this line when the compatibility layer is removed
# See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
id = ::Types::GlobalIDType[::Packages::Package].coerce_isolated_input(id)
GitlabSchema.find_by_gid(id)
end
end
end