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

52 lines
1.4 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
argument :ids,
[GraphQL::ID_TYPE],
required: false,
description: 'Filters designs by their ID'
argument :filenames,
[GraphQL::STRING_TYPE],
required: false,
description: 'Filters designs by their filename'
argument :at_version,
GraphQL::ID_TYPE,
required: false,
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'
def self.single
::Resolvers::DesignManagement::DesignResolver
end
def resolve(ids: nil, filenames: nil, at_version: nil)
::DesignManagement::DesignsFinder.new(
issue,
current_user,
ids: design_ids(ids),
filenames: filenames,
2020-10-24 23:57:45 +05:30
visible_at_version: version(at_version)
2020-05-24 23:13:21 +05:30
).execute
end
private
def version(at_version)
2020-10-24 23:57:45 +05:30
return unless at_version
GitlabSchema.object_from_id(at_version, expected_type: ::DesignManagement::Version)&.sync
2020-05-24 23:13:21 +05:30
end
def design_ids(ids)
2020-10-24 23:57:45 +05:30
ids&.map { |id| GlobalID.parse(id, expected_type: ::DesignManagement::Design).model_id }
2020-05-24 23:13:21 +05:30
end
def issue
object.issue
end
end
end
end