diff options
Diffstat (limited to 'app/graphql/resolvers/todo_resolver.rb')
-rw-r--r-- | app/graphql/resolvers/todo_resolver.rb | 66 |
1 files changed, 7 insertions, 59 deletions
diff --git a/app/graphql/resolvers/todo_resolver.rb b/app/graphql/resolvers/todo_resolver.rb index f0be1b6e9a5..0653cd27b4d 100644 --- a/app/graphql/resolvers/todo_resolver.rb +++ b/app/graphql/resolvers/todo_resolver.rb @@ -2,68 +2,16 @@ module Resolvers class TodoResolver < BaseResolver - type Types::TodoType.connection_type, null: true + description 'Retrieve a single to-do item' - alias_method :target, :object + type Types::TodoType, null: true - argument :action, [Types::TodoActionEnum], - required: false, - description: 'Action to be filtered.' + argument :id, Types::GlobalIDType[Todo], + required: true, + description: 'ID of the to-do item.' - argument :author_id, [GraphQL::Types::ID], - required: false, - description: 'ID of an author.' - - argument :project_id, [GraphQL::Types::ID], - required: false, - description: 'ID of a project.' - - argument :group_id, [GraphQL::Types::ID], - required: false, - description: 'ID of a group.' - - argument :state, [Types::TodoStateEnum], - required: false, - description: 'State of the todo.' - - argument :type, [Types::TodoTargetEnum], - required: false, - description: 'Type of the todo.' - - before_connection_authorization do |nodes, current_user| - Preloaders::UserMaxAccessLevelInProjectsPreloader.new( - nodes.map(&:project).compact, - current_user - ).execute - end - - def resolve(**args) - return Todo.none unless current_user.present? && target.present? - return Todo.none if target.is_a?(User) && target != current_user - - TodosFinder.new(current_user, todo_finder_params(args)).execute.with_entity_associations - end - - private - - def todo_finder_params(args) - { - state: args[:state], - type: args[:type], - group_id: args[:group_id], - author_id: args[:author_id], - action_id: args[:action], - project_id: args[:project_id] - }.merge(target_params) - end - - def target_params - return {} unless TodosFinder::TODO_TYPES.include?(target.class.name) - - { - type: target.class.name, - target_id: target.id - } + def resolve(id:) + GitlabSchema.find_by_gid(id) end end end |