Class: Mutations::MarkAllNotificationsAsRead
- Inherits:
-
BaseMutation
- Object
- GraphQL::Schema::RelayClassicMutation
- BaseMutation
- Mutations::MarkAllNotificationsAsRead
- Defined in:
- app/graphql/mutations/mark_all_notifications_as_read.rb
Instance Method Summary collapse
Instance Method Details
#resolve ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/graphql/mutations/mark_all_notifications_as_read.rb', line 12 def resolve if context[:current_user].notifications.unread.update_all(read: true) { unread_count: unread_count } else { errors: ['something went wrong'] } end end |
#unread_count ⇒ Object
8 9 10 |
# File 'app/graphql/mutations/mark_all_notifications_as_read.rb', line 8 def unread_count context[:current_user].notifications.unread.size end |