[PR #5383] [MERGED] feature: add alphabetical sort for user and team collections #5183

Closed
opened 2026-03-17 02:39:18 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hoppscotch/hoppscotch/pull/5383
Author: @mirarifhasan
Created: 9/10/2025
Status: Merged
Merged: 9/23/2025
Merged by: @jamesgeorge007

Base: nextHead: feat/collection-sorting


📝 Commits (10+)

  • ae0642e feat: add sorting for team collections and requests
  • 5589b80 feat: add sorting and subscription support for user collections
  • 0dd1a7c chore: feedback resolve
  • 37b7c43 feat: add UI slots for sorting and add store functions
  • 6576094 chore: port team collection adapter to service architecture
  • 185b2d9 chore: new req version ( add _ref_id to request schema)
  • f958cc7 fix: tests
  • 764e18d fix: inter module imports
  • 58d9f35 fix: use GqlTeamMemberGuard in sort mutation
  • a79f4f7 refactor: sort event payloads to use structured data

📊 Changes

63 files changed (+3476 additions, -339 deletions)

View changed files

📝 packages/hoppscotch-backend/src/app.module.ts (+2 -0)
📝 packages/hoppscotch-backend/src/gql-schema.ts (+4 -0)
packages/hoppscotch-backend/src/orchestration/sort/sort-team-collection.resolver.ts (+104 -0)
packages/hoppscotch-backend/src/orchestration/sort/sort-user-collection.resolver.ts (+74 -0)
packages/hoppscotch-backend/src/orchestration/sort/sort.model.ts (+16 -0)
packages/hoppscotch-backend/src/orchestration/sort/sort.module.ts (+25 -0)
packages/hoppscotch-backend/src/orchestration/sort/sort.service.spec.ts (+180 -0)
packages/hoppscotch-backend/src/orchestration/sort/sort.service.ts (+92 -0)
📝 packages/hoppscotch-backend/src/pubsub/topicsDefs.ts (+5 -0)
📝 packages/hoppscotch-backend/src/team-collection/team-collection.service.spec.ts (+70 -0)
📝 packages/hoppscotch-backend/src/team-collection/team-collection.service.ts (+54 -0)
📝 packages/hoppscotch-backend/src/team-request/team-request.service.spec.ts (+84 -5)
📝 packages/hoppscotch-backend/src/team-request/team-request.service.ts (+54 -0)
packages/hoppscotch-backend/src/types/SortOptions.ts (+10 -0)
📝 packages/hoppscotch-backend/src/user-collection/user-collection.service.ts (+51 -0)
📝 packages/hoppscotch-backend/src/user-request/user-request.module.ts (+1 -0)
📝 packages/hoppscotch-backend/src/user-request/user-request.service.ts (+54 -1)
📝 packages/hoppscotch-common/locales/en.json (+4 -1)
📝 packages/hoppscotch-common/src/components/collections/Collection.vue (+111 -2)
📝 packages/hoppscotch-common/src/components/collections/MyCollections.vue (+69 -8)

...and 43 more files

📄 Description

Closes BE-646 FE-901 FE-1005 FE-699 #4353

What's changed

This pull request introduces support for sorting user and team collections and their requests, including GraphQL mutations and subscriptions for sort events. It adds new resolvers, services, and enum types to handle sorting by title (ascending/descending) or default order, and publishes sort events via pub/sub for real-time updates.

Sorting Functionality Implementation

  • Added SortOptions enum to src/types/SortOptions.ts to specify supported sorting criteria (TITLE_ASC, TITLE_DESC).
  • Implemented sorting methods in UserCollectionService, TeamCollectionService, UserRequestService, and TeamRequestService to reorder items based on the selected sort option and update their orderIndex. [1] [2] [3] [4]

GraphQL API Extensions

  • Added SortUserCollectionResolver and SortTeamCollectionResolver to provide mutations for sorting collections and subscriptions for sort events. [1] [2]
  • Registered new resolvers in the GraphQL schema and created SortModule for dependency injection. [1] [2] [3]

Pub/Sub Integration for Sort Events

  • Extended topic definitions to include sort events for root and child collections for both users and teams, enabling real-time notifications. [1] [2]

These changes collectively enable sorting of collections and requests, expose the functionality via GraphQL, and notify clients of sort events for improved UX.

Other changes in FE

  • The Team collection adapter has been ported to new service architecture, now a single initialisation can be used to fetch collections rather initialising it every time and the team ID watcher is added so that collection is automatically updated.
  • updateInheritedPropertiesForAffectedRequests helper function is updated where the latest inheritedProperties is fetched each time there is change in the effectedTabs. This fixes the existing bug's with updating inheritedProperties.
  • Request schema version 16 is added with _ref_id as a parameter, which is a unique id to attach the request when its order is updated or moved around.
  • Added current sort value service to store and handle the current collection/folder sort order (asc or desc), since the BE currently does not store the value which can be iterated in the future with other sorting parameters if required. So the collection order of each entities now reside in the FE.

Notes to reviewers

Nil


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/hoppscotch/hoppscotch/pull/5383 **Author:** [@mirarifhasan](https://github.com/mirarifhasan) **Created:** 9/10/2025 **Status:** ✅ Merged **Merged:** 9/23/2025 **Merged by:** [@jamesgeorge007](https://github.com/jamesgeorge007) **Base:** `next` ← **Head:** `feat/collection-sorting` --- ### 📝 Commits (10+) - [`ae0642e`](https://github.com/hoppscotch/hoppscotch/commit/ae0642eabf4097d01d2d19d6ebacf730e8656678) feat: add sorting for team collections and requests - [`5589b80`](https://github.com/hoppscotch/hoppscotch/commit/5589b804470d929c2f359b247745888678057d2c) feat: add sorting and subscription support for user collections - [`0dd1a7c`](https://github.com/hoppscotch/hoppscotch/commit/0dd1a7cd76a2b23e05d6e3981b544827c97e8c49) chore: feedback resolve - [`37b7c43`](https://github.com/hoppscotch/hoppscotch/commit/37b7c431aeb098b5b0587ae19749b35308ea93a8) feat: add UI slots for sorting and add store functions - [`6576094`](https://github.com/hoppscotch/hoppscotch/commit/6576094fdf6d4bf1f35bdb06466b9923bb3bb5b5) chore: port team collection adapter to service architecture - [`185b2d9`](https://github.com/hoppscotch/hoppscotch/commit/185b2d98723ac89e09b8f50e9b2f27db47b3175e) chore: new req version ( add _ref_id to request schema) - [`f958cc7`](https://github.com/hoppscotch/hoppscotch/commit/f958cc75f3e7ae3ce74fdf638b4cbb0276689bf0) fix: tests - [`764e18d`](https://github.com/hoppscotch/hoppscotch/commit/764e18d78974ec4826db2f07a7972bcb5c52f345) fix: inter module imports - [`58d9f35`](https://github.com/hoppscotch/hoppscotch/commit/58d9f35537ae5551a4e7fff7f03ab6284d159683) fix: use GqlTeamMemberGuard in sort mutation - [`a79f4f7`](https://github.com/hoppscotch/hoppscotch/commit/a79f4f725c9fac178e21b4d82303fa514cd50248) refactor: sort event payloads to use structured data ### 📊 Changes **63 files changed** (+3476 additions, -339 deletions) <details> <summary>View changed files</summary> 📝 `packages/hoppscotch-backend/src/app.module.ts` (+2 -0) 📝 `packages/hoppscotch-backend/src/gql-schema.ts` (+4 -0) ➕ `packages/hoppscotch-backend/src/orchestration/sort/sort-team-collection.resolver.ts` (+104 -0) ➕ `packages/hoppscotch-backend/src/orchestration/sort/sort-user-collection.resolver.ts` (+74 -0) ➕ `packages/hoppscotch-backend/src/orchestration/sort/sort.model.ts` (+16 -0) ➕ `packages/hoppscotch-backend/src/orchestration/sort/sort.module.ts` (+25 -0) ➕ `packages/hoppscotch-backend/src/orchestration/sort/sort.service.spec.ts` (+180 -0) ➕ `packages/hoppscotch-backend/src/orchestration/sort/sort.service.ts` (+92 -0) 📝 `packages/hoppscotch-backend/src/pubsub/topicsDefs.ts` (+5 -0) 📝 `packages/hoppscotch-backend/src/team-collection/team-collection.service.spec.ts` (+70 -0) 📝 `packages/hoppscotch-backend/src/team-collection/team-collection.service.ts` (+54 -0) 📝 `packages/hoppscotch-backend/src/team-request/team-request.service.spec.ts` (+84 -5) 📝 `packages/hoppscotch-backend/src/team-request/team-request.service.ts` (+54 -0) ➕ `packages/hoppscotch-backend/src/types/SortOptions.ts` (+10 -0) 📝 `packages/hoppscotch-backend/src/user-collection/user-collection.service.ts` (+51 -0) 📝 `packages/hoppscotch-backend/src/user-request/user-request.module.ts` (+1 -0) 📝 `packages/hoppscotch-backend/src/user-request/user-request.service.ts` (+54 -1) 📝 `packages/hoppscotch-common/locales/en.json` (+4 -1) 📝 `packages/hoppscotch-common/src/components/collections/Collection.vue` (+111 -2) 📝 `packages/hoppscotch-common/src/components/collections/MyCollections.vue` (+69 -8) _...and 43 more files_ </details> ### 📄 Description <!-- Thanks for creating this pull request 🤗 Please make sure that the pull request is limited to one type (docs, feature, etc.) and keep it as small as possible. You can open multiple prs instead of opening a huge one. --> <!-- If this pull request closes an issue, please mention the issue number below --> <!-- Issue # here --> Closes BE-646 FE-901 FE-1005 FE-699 #4353 <!-- Add an introduction into what this PR tries to solve in a couple of sentences --> ### What's changed <!-- Describe point by point the different things you have changed in this PR --> This pull request introduces support for sorting user and team collections and their requests, including GraphQL mutations and subscriptions for sort events. It adds new resolvers, services, and enum types to handle sorting by title (ascending/descending) or default order, and publishes sort events via pub/sub for real-time updates. **Sorting Functionality Implementation** * Added `SortOptions` enum to `src/types/SortOptions.ts` to specify supported sorting criteria (`TITLE_ASC`, `TITLE_DESC`). * Implemented sorting methods in `UserCollectionService`, `TeamCollectionService`, `UserRequestService`, and `TeamRequestService` to reorder items based on the selected sort option and update their `orderIndex`. [[1]](diffhunk://#diff-10f5652209a5c72cdb83eca17273ee4d91eb45ce31208cc9d4a246bddce41de1R1316-R1365) [[2]](diffhunk://#diff-44232038c89b87d709417bb9f258ca3e898ddb05d8b19fd8103066d8293d002bR1471-R1523) [[3]](diffhunk://#diff-8d5d4dda01f5ec5428cee15efb391f17500cf59b7a02662585713fb700daa66eR490-R537) [[4]](diffhunk://#diff-853cd6526ea101ec37675c67bb21e706b7fe0c314d5694968ba708adbb5778e9R506-R556) **GraphQL API Extensions** * Added `SortUserCollectionResolver` and `SortTeamCollectionResolver` to provide mutations for sorting collections and subscriptions for sort events. [[1]](diffhunk://#diff-23ad71fbf7b058a736f1806663b57e9ca950b5192eca3346e41f7e7e24dbcab5R1-R73) [[2]](diffhunk://#diff-c833937f41499738e1aeebf66ddeaaeac12bcc61f31b024a02f07bbae74c4fabR1-R105) * Registered new resolvers in the GraphQL schema and created `SortModule` for dependency injection. [[1]](diffhunk://#diff-b36bfa757f4d74c6d24d5f3233da4179245a375cca5fd3a834a02d6fa7043992R33) [[2]](diffhunk://#diff-b36bfa757f4d74c6d24d5f3233da4179245a375cca5fd3a834a02d6fa7043992R66) [[3]](diffhunk://#diff-70e38bcf81603a8a5a10160497be299a3274cc6aeddc52ee965ec94d9bed3a94R1-R11) **Pub/Sub Integration for Sort Events** * Extended topic definitions to include sort events for root and child collections for both users and teams, enabling real-time notifications. [[1]](diffhunk://#diff-e174f00a57f55a8d76f93b092ebbe0319b127600d0ba2892a5688bea7b6ab7c2R56-R57) [[2]](diffhunk://#diff-e174f00a57f55a8d76f93b092ebbe0319b127600d0ba2892a5688bea7b6ab7c2R69-R70) These changes collectively enable sorting of collections and requests, expose the functionality via GraphQL, and notify clients of sort events for improved UX. <!-- You can also choose to add a list of changes and if they have been completed or not by using the markdown to-do list syntax - [ ] Not Completed - [x] Completed --> ### Other changes in FE - The Team collection adapter has been ported to new service architecture, now a single initialisation can be used to fetch collections rather initialising it every time and the team ID watcher is added so that collection is automatically updated. - `updateInheritedPropertiesForAffectedRequests` helper function is updated where the latest inheritedProperties is fetched each time there is change in the effectedTabs. This fixes the existing bug's with updating inheritedProperties. - Request schema version 16 is added with _ref_id as a parameter, which is a unique id to attach the request when its order is updated or moved around. - Added current sort value service to store and handle the current collection/folder sort order (asc or desc), since the BE currently does not store the value which can be iterated in the future with other sorting parameters if required. So the collection order of each entities now reside in the FE. ### Notes to reviewers <!-- Any information you feel the reviewer should know about when reviewing your PR --> Nil --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-17 02:39:18 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#5183
No description provided.