1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- import { gql } from "../../helpers/getGQL";
- import { actionPromise } from "../types/promiseTypes";
- 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 {url} }}
- owner {_id login nick
- avatar {url}
- }
- answers{
- _id
- }
- answerTo{_id}
- }
- likes{
- _id
- owner{
- _id login avatar {url}
- }
- }
- owner {_id login nick
- avatar {url}
- }
- }
- }
- `,
- {
- post: JSON.stringify([{ _id }]),
- },
- ),
- )
- export const actionPostUpsert = (post, postId) =>
- actionPromise(
- 'postUpsert',
- gql(
- `
- mutation PostUpsert($post:PostInput){
- PostUpsert(post:$post){
- _id title text images{_id url}
- }
- }`,
- {
- post: {
- ...post,
- _id:postId,
- images: post.images.map(({ _id }) => ({ _id })),
- },
- },
- ),
- )
|