postFeedQuery.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import { gql } from '../../helpers/getGQL'
  2. import { actionPromise } from '../types/promiseTypes'
  3. export const actionPostsFeed = (myFollowing, skip) =>
  4. actionPromise(
  5. 'postsFeed',
  6. gql(
  7. `query PostsFeed($ownerId:String){
  8. PostFind(query:$ownerId){
  9. owner{_id login avatar{url}}
  10. images{_id url originalFileName} title text
  11. _id likesCount
  12. likes{
  13. _id
  14. owner{
  15. _id login avatar {_id url}
  16. }
  17. }
  18. comments{
  19. _id, createdAt, text owner{_id login avatar{_id url}}
  20. answers{
  21. _id, createdAt, text owner{_id login avatar{_id url}}
  22. }
  23. }
  24. }
  25. }`,
  26. {
  27. ownerId: JSON.stringify([
  28. {
  29. ___owner: {
  30. $in: myFollowing,
  31. },
  32. },
  33. {
  34. sort: [{ _id: -1 }],
  35. skip: [skip || 0],
  36. limit: [10],
  37. },
  38. ]),
  39. },
  40. ),
  41. )
  42. export const actionPostsFeedCount = (myFollowing) =>
  43. actionPromise(
  44. 'postsFeedCount',
  45. gql(
  46. ` query CountAllPostsFeed($_id:String!){
  47. PostCount(query:$_id)
  48. }`,
  49. {
  50. _id: JSON.stringify([
  51. {
  52. ___owner: {
  53. $in: myFollowing,
  54. },
  55. },
  56. ]),
  57. },
  58. ),
  59. )