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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-11-14 11:41:52 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-11-14 11:41:52 +0300
commit585826cb22ecea5998a2c2a4675735c94bdeedac (patch)
tree5b05f0b30d33cef48963609e8a18a4dff260eab3 /app/graphql/resolvers/ci/catalog/resources_resolver.rb
parentdf221d036e5d0c6c0ee4d55b9c97f481ee05dee8 (diff)
Add latest changes from gitlab-org/gitlab@16-6-stable-eev16.6.0-rc42
Diffstat (limited to 'app/graphql/resolvers/ci/catalog/resources_resolver.rb')
-rw-r--r--app/graphql/resolvers/ci/catalog/resources_resolver.rb54
1 files changed, 54 insertions, 0 deletions
diff --git a/app/graphql/resolvers/ci/catalog/resources_resolver.rb b/app/graphql/resolvers/ci/catalog/resources_resolver.rb
new file mode 100644
index 00000000000..c6904dcd7f6
--- /dev/null
+++ b/app/graphql/resolvers/ci/catalog/resources_resolver.rb
@@ -0,0 +1,54 @@
+# frozen_string_literal: true
+
+module Resolvers
+ module Ci
+ module Catalog
+ class ResourcesResolver < BaseResolver
+ include LooksAhead
+
+ type ::Types::Ci::Catalog::ResourceType.connection_type, null: true
+
+ argument :scope, ::Types::Ci::Catalog::ResourceScopeEnum,
+ required: false,
+ default_value: :all,
+ description: 'Scope of the returned catalog resources.'
+
+ argument :search, GraphQL::Types::String,
+ required: false,
+ description: 'Search term to filter the catalog resources by name or description.'
+
+ argument :sort, ::Types::Ci::Catalog::ResourceSortEnum,
+ required: false,
+ description: 'Sort catalog resources by given criteria.'
+
+ # TODO: https://gitlab.com/gitlab-org/gitlab/-/issues/429636
+ argument :project_path, GraphQL::Types::ID,
+ required: false,
+ description: 'Project with the namespace catalog.'
+
+ def resolve_with_lookahead(scope:, project_path: nil, search: nil, sort: nil)
+ if project_path.present?
+ project = Project.find_by_full_path(project_path)
+
+ apply_lookahead(
+ ::Ci::Catalog::Listing
+ .new(context[:current_user])
+ .resources(namespace: project.root_namespace, sort: sort, search: search)
+ )
+ elsif scope == :all
+ apply_lookahead(::Ci::Catalog::Listing.new(context[:current_user]).resources(sort: sort, search: search))
+ end
+ end
+
+ private
+
+ def preloads
+ {
+ web_path: { project: { namespace: :route } },
+ readme_html: { project: :route }
+ }
+ end
+ end
+ end
+ end
+end