Class: Mutations::MarkAllNotificationsAsRead

Inherits:
BaseMutation
  • Object
show all
Defined in:
app/graphql/mutations/mark_all_notifications_as_read.rb

Instance Method Summary collapse

Instance Method Details

#resolveObject



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_countObject



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