Add tags connection to the GraphQL Repository type

The GraphQL API exposes Repository.branchNames and Repository.tagCount, and a Tag type already exists for the tag mutations, but there is no way to list the tags of a repository. releases only covers tags that have a release.

This MR adds Repository.tags, a forward-only connection (first/after, like Repository.commits) backed by TagsFinder, with the same options as the REST tags endpoint:

  • search — same matching rules as REST (^ prefix, $ suffix, * wildcard, exact match first).
  • sort — new TagSort enum: NAME_ASC|DESC, UPDATED_ASC|DESC, VERSION_ASC|DESC, default UPDATED_DESC.

Pagination mirrors the REST behaviour: without a search term the list is paginated by Gitaly (page_token = last tag name, base64-encoded as the cursor); with a search term the filtered list is paginated in memory, which is what GitalyKeysetPager does for REST as well. max_page_size is 100. Invalid or unknown cursors raise a GraphQL argument error.

Docs and both introspection JSON files are updated by hand (the compile rake tasks cannot run locally); I diffed the JSON edits against CommitConnection/CommitOrder so the shape matches the generated output.

Resolves #332144 (closed)

Differences

Before: No GraphQL field lists repository tags.

After:

{
  project(fullPath: "gitlab-org/gitlab") {
    repository {
      tags(sort: NAME_ASC, search: "v1", first: 20) {
        nodes { name message commit { sha } }
        pageInfo { hasNextPage endCursor }
      }
    }
  }
}

How to set up and Validate Locally:

  1. Open GraphiQL at /-/graphql-explorer and run the query above against a project with tags.
  2. Pass pageInfo.endCursor back as after and confirm the next page continues after the last tag of the previous page.
  3. Remove search and confirm the same paging works through Gitaly.
  4. Specs: bundle exec rspec spec/graphql/resolvers/repositories/tags_resolver_spec.rb spec/graphql/types/repositories/tag_sort_enum_spec.rb spec/graphql/types/repository_type_spec.rb spec/requests/api/graphql/project/repository_spec.rb
Edited by Jeston Singh

Merge request reports

Loading
Loading