likeQuery.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import { gql } from "../../helpers/getGQL";
  2. import { actionPromise } from "../types/promiseTypes";
  3. export const actionAddLike = (postId) =>
  4. actionPromise(
  5. 'addLike',
  6. gql(
  7. `mutation AddLike($like:LikeInput){
  8. LikeUpsert(like:$like)
  9. {
  10. _id
  11. }
  12. }`,
  13. {
  14. like: {
  15. post: {
  16. _id: postId,
  17. },
  18. },
  19. },
  20. ),
  21. )
  22. export const actionDeleteLike = (likeId, postId) =>
  23. actionPromise(
  24. 'deleteLike',
  25. gql(
  26. `mutation DeleteLike($like:LikeInput){
  27. LikeDelete(like: $like)
  28. {
  29. _id
  30. }
  31. }`,
  32. {
  33. like: {
  34. _id: likeId,
  35. post: {
  36. _id: postId,
  37. },
  38. },
  39. },
  40. ),
  41. )
  42. export const actionFindLikes = (_id) =>
  43. actionPromise(
  44. 'onePostLikes',
  45. gql(
  46. `query OnePostLikes($post:String){
  47. PostFindOne(query:$post){
  48. likes{
  49. _id
  50. owner{
  51. _id login avatar {url}
  52. }
  53. }
  54. }
  55. }`,
  56. {
  57. post: JSON.stringify([{ _id }]),
  58. },
  59. ),
  60. )
  61. // export const actionGetFindLiked = (_id) =>
  62. // actionPromise(
  63. // 'findLiked',
  64. // gql(
  65. // ` query LikeFindPost($id:String!) {
  66. // LikeFind(query:$id){
  67. // owner { _id nick login
  68. // avatar{_id url}
  69. // }
  70. // }
  71. // } `,
  72. // {
  73. // id: JSON.stringify([{ 'post._id': _id }]),
  74. // },
  75. // ),
  76. // )