Add _links object to the Package GraphQL API
Context
A package might have one of the following statuses: default, hidden, processing, error and pending_destruction.
Currently not all the statuses allow the package to be displayed in the details page.
The package details pages should be restricted to only packages with status default.
In order to be fully backward compatible and avoid any degradations on UX we agreed on the multi MRs implementation of necessary changes.
What does this MR do and why?
Add the _links
object with underlying web_path
property to the Package
type (GraphQL API).
Later on frontend will use web_path
to show the link to package details page.
Screenshots or screen recordings
Query project with a package
Query package
How to set up and validate locally
Preparation
-
Prepare a package
def fixture_file_upload(*args, **kwargs) Rack::Test::UploadedFile.new(*args, **kwargs) end FactoryBot.create(:npm_package, project: Project.first)
-
Grab required information
Packages::Package.last.id
Write it down somewhere or remember - it will be required at the later step.
Packages::Package.last.project_id
Write it down somewhere or remember - it will be required at the later step.
GraphQL API
-
Browse
http://gdk.test:3000/-/graphql-explorer
and query a package{ package(id: "gid://gitlab/Packages::Package/:package_id") { _links { webPath } } }
-
Verify response
{ "data": { "package": { "_links": { "webPath": "/gitlab-org/gitlab-test/-/packages/:package_id" } } } }
-
Browse
http://gdk.test:3000/-/graphql-explorer
and query a project with packages{ project(fullPath: "gitlab-org/gitlab-test") { id packages { edges { node { _links { webPath } } } } } }
-
Verify response
{ "data": { "project": { "id": "gid://gitlab/Project/:project_id", "packages": { "edges": [ { "node": { "_links": { "webPath": "/gitlab-org/gitlab-test/-/packages/:package_id" } } } ] } } } }
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #344257 (closed)