Skip to content

Create CI Catalog resolver for a single resource

Kasia Misirli requested to merge 408722/Return_ci_resources_by_id into master

What does this MR do and why?

Adding a single catalog resource graphQL endpoint. Addressing following issue.

Screenshots or screen recordings

See below.

How to set up and validate locally (command line)

  1. Enable feature flags:
Feature.enable(:ci_namespace_catalog_experimental)
Feature.enable(:ci_namespace_catalog)
License.feature_available?(:ci_namespace_catalog) #get license if this is not true.
  1. Create a project that belongs to a namespace.
  2. Add the current user (id: 1) as owner to the namespace.
  3. Create Ci::Catalog::Resource in your console
project = Project.last
resource = Ci::Catalog::Resource.new(project: project)
resource.save!
  1. In the console:
current_user = User.find_by_id(1)

query = <<~EOQ
query getCiCatalogResource($id: CiCatalogResourceID!) 
{
  ciCatalogResource(id: $id) {
    id
    description
    name
    icon
  } 
}
EOQ

variables = {"id": "gid://gitlab/Ci::Catalog::Resource/1"}

result = GitlabSchema.execute(query, variables: variables, context: { current_user: current_user })
result.to_h

Screenshot_2023-05-12_at_18.27.30

How to set up and validate locally (graphQL interface)

When user is authorised to see a catalog resource

Screenshot_2023-05-22_at_18.52.06!

When user is not authorised to see a catalog resource

Screenshot_2023-05-22_at_18.52.33

When requested resource does not exist

Screenshot_2023-05-22_at_18.52.33

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Furkan Ayhan

Merge request reports

Loading