Guest User

Untitled

a guest
Feb 16th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. // ...
  2.  
  3. const subscribeToNewChats = () => {
  4. chatsQuery.subscribeToMore({
  5. document: gql`
  6. subscription MessageSentSubscription {
  7. messageSent {
  8. id
  9. content
  10. from
  11. createdAt
  12. }
  13. }
  14. `,
  15. updateQuery: (previousData, { subscriptionData }) => {
  16. return {
  17. chats: [
  18. subscriptionData.data.messageSent,
  19. ...previousData.chats
  20. ].splice(0, 8)
  21. };
  22. }
  23. });
  24. };
  25.  
  26. // ...
Add Comment
Please, Sign In to add comment