2020-07-09 15:24:28 +00: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 08:55:24 +00:00
|
|
|
draft
|
2020-07-09 15:24:28 +00:00
|
|
|
author {
|
|
|
|
id
|
|
|
|
preferredUsername
|
|
|
|
name
|
|
|
|
domain
|
|
|
|
avatar {
|
2020-10-22 14:19:26 +00:00
|
|
|
id
|
2020-07-09 15:24:28 +00:00
|
|
|
url
|
|
|
|
}
|
|
|
|
}
|
|
|
|
attributedTo {
|
|
|
|
id
|
|
|
|
preferredUsername
|
|
|
|
name
|
|
|
|
domain
|
|
|
|
avatar {
|
2020-10-22 14:19:26 +00:00
|
|
|
id
|
2020-07-09 15:24:28 +00:00
|
|
|
url
|
|
|
|
}
|
|
|
|
}
|
|
|
|
insertedAt
|
|
|
|
updatedAt
|
|
|
|
publishAt
|
|
|
|
draft
|
|
|
|
visibility
|
|
|
|
tags {
|
|
|
|
...TagFragment
|
|
|
|
}
|
2020-10-01 13:07:15 +00:00
|
|
|
picture {
|
|
|
|
id
|
|
|
|
url
|
|
|
|
name
|
2021-06-15 15:25:33 +00:00
|
|
|
metadata {
|
|
|
|
height
|
|
|
|
width
|
|
|
|
blurhash
|
|
|
|
}
|
2020-10-01 13:07:15 +00:00
|
|
|
}
|
2020-07-09 15:24:28 +00:00
|
|
|
}
|
|
|
|
${TAG_FRAGMENT}
|
|
|
|
`;
|
|
|
|
|
|
|
|
export const POST_BASIC_FIELDS = gql`
|
|
|
|
fragment PostBasicFields on Post {
|
|
|
|
id
|
|
|
|
title
|
|
|
|
slug
|
|
|
|
url
|
|
|
|
author {
|
|
|
|
id
|
|
|
|
preferredUsername
|
|
|
|
name
|
2020-10-01 13:07:15 +00:00
|
|
|
domain
|
2020-07-09 15:24:28 +00:00
|
|
|
avatar {
|
2020-10-22 14:19:26 +00:00
|
|
|
id
|
2020-07-09 15:24:28 +00:00
|
|
|
url
|
|
|
|
}
|
|
|
|
}
|
|
|
|
attributedTo {
|
|
|
|
id
|
|
|
|
preferredUsername
|
|
|
|
name
|
2020-10-01 13:07:15 +00:00
|
|
|
domain
|
2020-07-09 15:24:28 +00:00
|
|
|
avatar {
|
2020-10-22 14:19:26 +00:00
|
|
|
id
|
2020-07-09 15:24:28 +00:00
|
|
|
url
|
|
|
|
}
|
|
|
|
}
|
|
|
|
insertedAt
|
|
|
|
updatedAt
|
|
|
|
publishAt
|
|
|
|
draft
|
2020-10-01 13:07:15 +00:00
|
|
|
visibility
|
|
|
|
picture {
|
|
|
|
id
|
|
|
|
url
|
|
|
|
name
|
|
|
|
}
|
2020-07-09 15:24:28 +00: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 10:41:13 +00:00
|
|
|
$picture: MediaInput
|
2020-07-09 15:24:28 +00:00
|
|
|
) {
|
|
|
|
createPost(
|
|
|
|
title: $title
|
|
|
|
body: $body
|
|
|
|
attributedToId: $attributedToId
|
|
|
|
visibility: $visibility
|
|
|
|
draft: $draft
|
|
|
|
tags: $tags
|
2020-10-01 13:07:15 +00:00
|
|
|
picture: $picture
|
2020-07-09 15:24:28 +00: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 10:41:13 +00:00
|
|
|
$picture: MediaInput
|
2020-07-09 15:24:28 +00:00
|
|
|
) {
|
|
|
|
updatePost(
|
|
|
|
id: $id
|
|
|
|
title: $title
|
|
|
|
body: $body
|
|
|
|
attributedToId: $attributedToId
|
|
|
|
visibility: $visibility
|
|
|
|
draft: $draft
|
|
|
|
tags: $tags
|
2020-10-01 13:07:15 +00:00
|
|
|
picture: $picture
|
2020-07-09 15:24:28 +00:00
|
|
|
) {
|
|
|
|
...PostFragment
|
|
|
|
}
|
|
|
|
}
|
|
|
|
${POST_FRAGMENT}
|
|
|
|
`;
|
|
|
|
|
|
|
|
export const DELETE_POST = gql`
|
|
|
|
mutation DeletePost($id: ID!) {
|
|
|
|
deletePost(id: $id) {
|
|
|
|
id
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|