Welcome to mirror list, hosted at ThFree Co, Russian Federation.

package_details_resolver.rb « resolvers « graphql « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c565fcb70e309f0281b0b7c6c6701892892c3863 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# frozen_string_literal: true

module Resolvers
  class PackageDetailsResolver < BaseResolver
    extension ::Gitlab::Graphql::Limit::FieldCallCount, limit: 1

    type ::Types::Packages::PackageDetailsType, null: true

    argument :id, ::Types::GlobalIDType[::Packages::Package],
      required: true,
      description: 'Global ID of the package.'

    def resolve(id:)
      Gitlab::Graphql::Lazy.with_value(find_object(id: id)) do |package|
        package if package.default?
      end
    end

    private

    def find_object(id:)
      GitlabSchema.find_by_gid(id)
    end
  end
end