diff options
Diffstat (limited to 'app/graphql/resolvers')
-rw-r--r-- | app/graphql/resolvers/releases_resolver.rb | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/app/graphql/resolvers/releases_resolver.rb b/app/graphql/resolvers/releases_resolver.rb index 85892c2abeb..8e8127cf279 100644 --- a/app/graphql/resolvers/releases_resolver.rb +++ b/app/graphql/resolvers/releases_resolver.rb @@ -4,6 +4,10 @@ module Resolvers class ReleasesResolver < BaseResolver type Types::ReleaseType.connection_type, null: true + argument :sort, Types::ReleaseSortEnum, + required: false, default_value: :released_at_desc, + description: 'Sort releases by this criteria' + alias_method :project, :object # This resolver has a custom singular resolver @@ -11,12 +15,20 @@ module Resolvers Resolvers::ReleaseResolver end - def resolve(**args) + SORT_TO_PARAMS_MAP = { + released_at_desc: { order_by: 'released_at', sort: 'desc' }, + released_at_asc: { order_by: 'released_at', sort: 'asc' }, + created_desc: { order_by: 'created_at', sort: 'desc' }, + created_asc: { order_by: 'created_at', sort: 'asc' } + }.freeze + + def resolve(sort:) return unless Feature.enabled?(:graphql_release_data, project, default_enabled: true) ReleasesFinder.new( project, - current_user + current_user, + SORT_TO_PARAMS_MAP[sort] ).execute end end |