pupilfirst/pupilfirst

View on GitHub
app/graphql/mutations/mark_all_notifications.rb

Summary

Maintainability
A
35 mins
Test Coverage
B
83%
module Mutations
  class MarkAllNotifications < GraphQL::Schema::Mutation
    description "Mark all notifications as read"

    field :success, Boolean, null: false

    def resolve
      mutator = MarkAllNotificationsMutator.new(context, {})
      success = if mutator.valid?
        mutator.mark_all
        true
      else
        mutator.notify_errors
        false
      end

      { success: success }
    end
  end
end