123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- import { gql } from "../../helpers/getGQL";
- import { actionPromise } from "../types/promiseTypes";
- export const actionAddComment = (postId, text) =>
- actionPromise(
- "addComment",
- gql(
- `mutation AddComment($comment:CommentInput){
- CommentUpsert(comment:$comment)
- {
- _id
- text
- createdAt
- }
- }`,
- {
- comment: {
- post: {
- _id: postId,
- },
- text
- },
- },
- ),
- )
- export const actionOnePost = (_id) =>
- actionPromise(
- 'onePost',
- gql(
- `query OneFind($post:String){
- PostFindOne(query:$post){
- _id createdAt title text
- images{_id url originalFileName}
- comments {
- _id createdAt text
- likes { _id owner {_id login nick avatar {_id url} }}
- owner {_id login nick
- avatar {_id url}
- }
- answers{
- _id
- }
- answerTo{_id}
- }
- likes{
- _id
- owner{
- _id login avatar {_id url}
- }
- }
- owner {_id login nick
- avatar {_id url}
- }
- }
- }
- `,
- {
- post: JSON.stringify([{ _id }]),
- },
- ),
- )
-
-
- export const actionGetCommentsOnePost = (postId) =>
- actionPromise('commentsOnePost',
- gql(`query commentFindPost ($id:String!){
- PostFindOne(query:$id){
- comments {
- _id text createdAt
- owner{
- _id nick login
- avatar{
- _id url
- }
- }
- likes{_id}
- }
- }
- }`, { id: JSON.stringify([{ _id: postId }]) }))
-
- export const actionFindSubComment = (findId) =>
- actionPromise(
- 'subComments',
- gql(
- `query commentFindOne ($id:String!){
- CommentFindOne(query:$id){
- _id text answers {
- _id text
- post {_id }
- answers { _id}
- createdAt
- likes { _id owner
- {_id avatar{_id url} login nick } }
- owner {
- _id login nick
- avatar { _id url }
- }
- }
- }
- }`,
- {
- id: JSON.stringify([
- {
- _id: findId,
- },
- ]),
- },
- ),
- )
- export const actionAddSubComment = (commentId, newResult) =>
- actionPromise(
- 'addSubComment',
- gql(
- `mutation AddComment($comment:CommentInput){
- CommentUpsert(comment:$comment)
- {
- _id
- text
- createdAt
- }
- }`,
- {
- comment: {
- answerTo: {
- _id: commentId,
- },
- text: newResult,
- },
- },
- ),
- )
|