subscribeQuery.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { gql } from '../../helpers/getGQL'
  2. import { actionPromise } from '../types/promiseTypes'
  3. export const actionChangeSubscribe = (oldFollowing) =>
  4. actionPromise(
  5. 'changeSubscribe',
  6. gql(
  7. `mutation changeSubscribe($user:UserInput) {
  8. UserUpsert(user: $user) {
  9. _id
  10. }
  11. }
  12. `,
  13. {
  14. user: oldFollowing,
  15. },
  16. ),
  17. )
  18. export const actionGetFollowing = (_id) =>
  19. actionPromise(
  20. 'getFollowing',
  21. gql(
  22. `query GetFollowing($userId:String){
  23. UserFindOne(query:$userId)
  24. {
  25. following{_id login nick avatar{_id url}}
  26. }
  27. }`,
  28. {
  29. userId: JSON.stringify([{ _id }]),
  30. },
  31. ),
  32. )
  33. export const actionGetFollowers = (userId) =>
  34. actionPromise(
  35. 'getFollowers',
  36. gql(
  37. `query GetFollowers($userId:String){
  38. UserFindOne(query:$userId)
  39. {
  40. _id
  41. followers{_id login nick avatar{_id url}}
  42. }
  43. }`,
  44. {
  45. userId: JSON.stringify([{ _id: userId }]),
  46. },
  47. ),
  48. )