Class: Mutations::MarkNotificationAsRead
- Inherits:
-
BaseMutation
- Object
- GraphQL::Schema::RelayClassicMutation
- BaseMutation
- Mutations::MarkNotificationAsRead
- Defined in:
- app/graphql/mutations/mark_notification_as_read.rb
Instance Method Summary collapse
Instance Method Details
#resolve(id:) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/graphql/mutations/mark_notification_as_read.rb', line 15 def resolve(id:) notification = Notification.find(id) if notification.read? { notification: notification, unread_count: unread_count, errors: ["Notification already marked as 'read'"] } elsif notification.unread? if notification.read! # SUCCESS { notification: notification, unread_count: unread_count, errors: [] } else # TODO: error {} end end end |
#unread_count ⇒ Object
9 10 11 |
# File 'app/graphql/mutations/mark_notification_as_read.rb', line 9 def unread_count context[:current_user].notifications.unread.size end |