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

model_detail_resolver.rb « ml « resolvers « graphql « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7a5fe7821ea25696ef9333e1c29296d711d73ba5 (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
26
27
# frozen_string_literal: true

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

      type ::Types::Ml::ModelType, null: true

      argument :id, ::Types::GlobalIDType[::Ml::Model],
        required: true,
        description: 'ID of the model.'

      def resolve(id:)
        Gitlab::Graphql::Lazy.with_value(find_object(id: id)) do |ml_model|
          ml_model if Ability.allowed?(current_user, :read_model_registry, ml_model&.project)
        end
      end

      private

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