2020-07-09 17:24:28 +02:00
|
|
|
import gql from "graphql-tag";
|
|
|
|
import { TAG_FRAGMENT } from "./tags";
|
|
|
|
|
|
|
|
export const POST_FRAGMENT = gql`
|
|
|
|
fragment PostFragment on Post {
|
|
|
|
id
|
|
|
|
title
|
|
|
|
slug
|
|
|
|
url
|
|
|
|
body
|
2020-12-01 09:55:24 +01:00
|
|
|
draft
|
2020-07-09 17:24:28 +02:00
|
|
|
author {
|
|
|
|
id
|
|
|
|
preferredUsername
|
|
|
|
name
|
|
|
|
domain
|
|
|
|
avatar {
|
2020-10-22 16:19:26 +02:00
|
|
|
id
|
2020-07-09 17:24:28 +02:00
|
|
|
url
|
|
|
|
}
|
|
|
|
}
|
|
|
|
attributedTo {
|
|
|
|
id
|
|
|
|
preferredUsername
|
|
|
|
name
|
|
|
|
domain
|
|
|
|
avatar {
|
2020-10-22 16:19:26 +02:00
|
|
|
id
|
2020-07-09 17:24:28 +02:00
|
|
|
url
|
|
|
|
}
|
|
|
|
}
|
|
|
|
insertedAt
|
|
|
|
updatedAt
|
|
|
|
publishAt
|
|
|
|
draft
|
|
|
|
visibility
|
|
|
|
tags {
|
|
|
|
...TagFragment
|
|
|
|
}
|
2020-10-01 15:07:15 +02:00
|
|
|
picture {
|
|
|
|
id
|
|
|
|
url
|
|
|
|
name
|
|
|
|
}
|
2020-07-09 17:24:28 +02:00
|
|
|
}
|
|
|
|
${TAG_FRAGMENT}
|
|
|
|
`;
|
|
|
|
|
|
|
|
export const POST_BASIC_FIELDS = gql`
|
|
|
|
fragment PostBasicFields on Post {
|
|
|
|
id
|
|
|
|
title
|
|
|
|
slug
|
|
|
|
url
|
|
|
|
author {
|
|
|
|
id
|
|
|
|
preferredUsername
|
|
|
|
name
|
2020-10-01 15:07:15 +02:00
|
|
|
domain
|
2020-07-09 17:24:28 +02:00
|
|
|
avatar {
|
2020-10-22 16:19:26 +02:00
|
|
|
id
|
2020-07-09 17:24:28 +02:00
|
|
|
url
|
|
|
|
}
|
|
|
|
}
|
|
|
|
attributedTo {
|
|
|
|
id
|
|
|
|
preferredUsername
|
|
|
|
name
|
2020-10-01 15:07:15 +02:00
|
|
|
domain
|
2020-07-09 17:24:28 +02:00
|
|
|
avatar {
|
2020-10-22 16:19:26 +02:00
|
|
|
id
|
2020-07-09 17:24:28 +02:00
|
|
|
url
|
|
|
|
}
|
|
|
|
}
|
|
|
|
insertedAt
|
|
|
|
updatedAt
|
|
|
|
publishAt
|
|
|
|
draft
|
2020-10-01 15:07:15 +02:00
|
|
|
visibility
|
|
|
|
picture {
|
|
|
|
id
|
|
|
|
url
|
|
|
|
name
|
|
|
|
}
|
2020-07-09 17:24:28 +02:00
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
export const FETCH_GROUP_POSTS = gql`
|
|
|
|
query GroupPosts($preferredUsername: String!, $page: Int, $limit: Int) {
|
|
|
|
group(preferredUsername: $preferredUsername) {
|
|
|
|
id
|
|
|
|
preferredUsername
|
|
|
|
domain
|
|
|
|
name
|
|
|
|
posts(page: $page, limit: $limit) {
|
|
|
|
total
|
|
|
|
elements {
|
|
|
|
...PostBasicFields
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
${POST_BASIC_FIELDS}
|
|
|
|
`;
|
|
|
|
|
|
|
|
export const FETCH_POST = gql`
|
|
|
|
query Post($slug: String!) {
|
|
|
|
post(slug: $slug) {
|
|
|
|
...PostFragment
|
|
|
|
}
|
|
|
|
}
|
|
|
|
${POST_FRAGMENT}
|
|
|
|
`;
|
|
|
|
|
|
|
|
export const CREATE_POST = gql`
|
|
|
|
mutation CreatePost(
|
|
|
|
$title: String!
|
|
|
|
$body: String
|
|
|
|
$attributedToId: ID!
|
|
|
|
$visibility: PostVisibility
|
|
|
|
$draft: Boolean
|
|
|
|
$tags: [String]
|
2020-11-26 11:41:13 +01:00
|
|
|
$picture: MediaInput
|
2020-07-09 17:24:28 +02:00
|
|
|
) {
|
|
|
|
createPost(
|
|
|
|
title: $title
|
|
|
|
body: $body
|
|
|
|
attributedToId: $attributedToId
|
|
|
|
visibility: $visibility
|
|
|
|
draft: $draft
|
|
|
|
tags: $tags
|
2020-10-01 15:07:15 +02:00
|
|
|
picture: $picture
|
2020-07-09 17:24:28 +02:00
|
|
|
) {
|
|
|
|
...PostFragment
|
|
|
|
}
|
|
|
|
}
|
|
|
|
${POST_FRAGMENT}
|
|
|
|
`;
|
|
|
|
|
|
|
|
export const UPDATE_POST = gql`
|
|
|
|
mutation UpdatePost(
|
|
|
|
$id: ID!
|
|
|
|
$title: String
|
|
|
|
$body: String
|
|
|
|
$attributedToId: ID
|
|
|
|
$visibility: PostVisibility
|
|
|
|
$draft: Boolean
|
|
|
|
$tags: [String]
|
2020-11-26 11:41:13 +01:00
|
|
|
$picture: MediaInput
|
2020-07-09 17:24:28 +02:00
|
|
|
) {
|
|
|
|
updatePost(
|
|
|
|
id: $id
|
|
|
|
title: $title
|
|
|
|
body: $body
|
|
|
|
attributedToId: $attributedToId
|
|
|
|
visibility: $visibility
|
|
|
|
draft: $draft
|
|
|
|
tags: $tags
|
2020-10-01 15:07:15 +02:00
|
|
|
picture: $picture
|
2020-07-09 17:24:28 +02:00
|
|
|
) {
|
|
|
|
...PostFragment
|
|
|
|
}
|
|
|
|
}
|
|
|
|
${POST_FRAGMENT}
|
|
|
|
`;
|
|
|
|
|
|
|
|
export const DELETE_POST = gql`
|
|
|
|
mutation DeletePost($id: ID!) {
|
|
|
|
deletePost(id: $id) {
|
|
|
|
id
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|