debian-mirror-gitlab/app/graphql/resolvers/design_management/designs_resolver.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

60 lines
1.7 KiB
Ruby
Raw Normal View History

2020-05-24 23:13:21 +05:30
# frozen_string_literal: true
module Resolvers
module DesignManagement
class DesignsResolver < BaseResolver
2021-01-29 00:20:46 +05:30
DesignID = ::Types::GlobalIDType[::DesignManagement::Design]
VersionID = ::Types::GlobalIDType[::DesignManagement::Version]
type ::Types::DesignManagement::DesignType.connection_type, null: true
2022-01-26 12:08:38 +05:30
argument :at_version, VersionID,
2020-05-24 23:13:21 +05:30
required: false,
2022-01-26 12:08:38 +05:30
description: 'Filters designs to only those that existed at the version. ' \
'If argument is omitted or nil then all designs will reflect the latest version'
2021-10-27 15:23:28 +05:30
argument :filenames, [GraphQL::Types::String],
2020-05-24 23:13:21 +05:30
required: false,
2021-03-08 18:12:59 +05:30
description: 'Filters designs by their filename.'
2022-01-26 12:08:38 +05:30
argument :ids, [DesignID],
2020-05-24 23:13:21 +05:30
required: false,
2022-01-26 12:08:38 +05:30
description: 'Filters designs by their ID.'
2020-05-24 23:13:21 +05:30
def self.single
::Resolvers::DesignManagement::DesignResolver
end
def resolve(ids: nil, filenames: nil, at_version: nil)
2022-07-16 23:28:13 +05:30
context.scoped_set!(:at_version_argument, at_version) if at_version
::Gitlab::Graphql::Lazy.with_value(version(at_version)) do |visible_at|
::DesignManagement::DesignsFinder.new(
issue,
current_user,
ids: design_ids(ids),
filenames: filenames,
visible_at_version: visible_at
).execute
end
2020-05-24 23:13:21 +05:30
end
private
def version(at_version)
2020-10-24 23:57:45 +05:30
return unless at_version
2022-07-16 23:28:13 +05:30
GitlabSchema.find_by_gid(at_version)
2020-05-24 23:13:21 +05:30
end
2021-01-29 00:20:46 +05:30
def design_ids(gids)
return if gids.nil?
gids.map(&:model_id)
2020-05-24 23:13:21 +05:30
end
def issue
object.issue
end
end
end
end