2021-01-14 07:10:54 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Resolvers
|
|
|
|
class PackageDetailsResolver < BaseResolver
|
2021-04-09 17:09:22 -04:00
|
|
|
type ::Types::Packages::PackageDetailsType, null: true
|
2021-02-01 10:08:56 -05:00
|
|
|
|
2021-01-14 07:10:54 -05:00
|
|
|
argument :id, ::Types::GlobalIDType[::Packages::Package],
|
|
|
|
required: true,
|
2021-08-19 14:10:32 -04:00
|
|
|
description: 'Global ID of the package.'
|
2021-01-14 07:10:54 -05:00
|
|
|
|
2021-04-09 17:09:22 -04:00
|
|
|
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-01-14 07:10:54 -05:00
|
|
|
def resolve(id:)
|
|
|
|
GitlabSchema.find_by_gid(id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|