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— newTagSortenum:NAME_ASC|DESC,UPDATED_ASC|DESC,VERSION_ASC|DESC, defaultUPDATED_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:
- Open GraphiQL at
/-/graphql-explorerand run the query above against a project with tags. - Pass
pageInfo.endCursorback asafterand confirm the next page continues after the last tag of the previous page. - Remove
searchand confirm the same paging works through Gitaly. - 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