2020-07-09 17:24:28 +02:00
|
|
|
import gql from "graphql-tag";
|
|
|
|
|
|
|
|
export const DISCUSSION_BASIC_FIELDS_FRAGMENT = gql`
|
|
|
|
fragment DiscussionBasicFields on Discussion {
|
|
|
|
id
|
|
|
|
title
|
|
|
|
slug
|
2020-08-27 11:53:24 +02:00
|
|
|
insertedAt
|
2020-08-14 11:32:23 +02:00
|
|
|
updatedAt
|
2020-07-09 17:24:28 +02:00
|
|
|
lastComment {
|
|
|
|
id
|
|
|
|
text
|
|
|
|
actor {
|
|
|
|
id
|
|
|
|
preferredUsername
|
2020-10-21 12:14:53 +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
|
|
|
|
}
|
|
|
|
}
|
2020-08-27 11:53:24 +02:00
|
|
|
publishedAt
|
2020-08-14 11:32:23 +02:00
|
|
|
deletedAt
|
2020-07-09 17:24:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
export const DISCUSSION_FIELDS_FOR_REPLY_FRAGMENT = gql`
|
|
|
|
fragment DiscussionFieldsReply on Discussion {
|
|
|
|
id
|
|
|
|
title
|
|
|
|
slug
|
|
|
|
lastComment {
|
|
|
|
id
|
|
|
|
text
|
|
|
|
updatedAt
|
|
|
|
actor {
|
|
|
|
id
|
|
|
|
preferredUsername
|
2020-10-21 12:14:53 +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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
actor {
|
|
|
|
id
|
|
|
|
preferredUsername
|
2020-10-21 12:14:53 +02:00
|
|
|
domain
|
2020-07-09 17:24:28 +02:00
|
|
|
}
|
|
|
|
creator {
|
|
|
|
id
|
|
|
|
preferredUsername
|
2020-10-21 12:14:53 +02:00
|
|
|
domain
|
2020-07-09 17:24:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
export const DISCUSSION_FIELDS_FRAGMENT = gql`
|
|
|
|
fragment DiscussionFields on Discussion {
|
|
|
|
id
|
|
|
|
title
|
|
|
|
slug
|
|
|
|
lastComment {
|
|
|
|
id
|
|
|
|
text
|
2020-08-19 09:01:34 +02:00
|
|
|
insertedAt
|
2020-07-09 17:24:28 +02:00
|
|
|
updatedAt
|
|
|
|
}
|
|
|
|
actor {
|
|
|
|
id
|
|
|
|
domain
|
|
|
|
name
|
|
|
|
preferredUsername
|
|
|
|
}
|
|
|
|
creator {
|
|
|
|
id
|
|
|
|
domain
|
|
|
|
name
|
|
|
|
preferredUsername
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
export const CREATE_DISCUSSION = gql`
|
2020-11-19 17:06:28 +01:00
|
|
|
mutation createDiscussion($title: String!, $actorId: ID!, $text: String!) {
|
|
|
|
createDiscussion(title: $title, text: $text, actorId: $actorId) {
|
2020-07-09 17:24:28 +02:00
|
|
|
...DiscussionFields
|
|
|
|
}
|
|
|
|
}
|
|
|
|
${DISCUSSION_FIELDS_FRAGMENT}
|
|
|
|
`;
|
|
|
|
|
|
|
|
export const REPLY_TO_DISCUSSION = gql`
|
|
|
|
mutation replyToDiscussion($discussionId: ID!, $text: String!) {
|
|
|
|
replyToDiscussion(discussionId: $discussionId, text: $text) {
|
|
|
|
...DiscussionFields
|
|
|
|
}
|
|
|
|
}
|
|
|
|
${DISCUSSION_FIELDS_FRAGMENT}
|
|
|
|
`;
|
|
|
|
|
|
|
|
export const GET_DISCUSSION = gql`
|
|
|
|
query getDiscussion($slug: String!, $page: Int, $limit: Int) {
|
|
|
|
discussion(slug: $slug) {
|
|
|
|
comments(page: $page, limit: $limit)
|
2020-09-21 12:15:37 +02:00
|
|
|
@connection(key: "discussion-comments", filter: ["slug"]) {
|
2020-07-09 17:24:28 +02:00
|
|
|
total
|
|
|
|
elements {
|
|
|
|
id
|
|
|
|
text
|
|
|
|
actor {
|
|
|
|
id
|
|
|
|
avatar {
|
2020-10-22 16:19:26 +02:00
|
|
|
id
|
2020-07-09 17:24:28 +02:00
|
|
|
url
|
|
|
|
}
|
|
|
|
name
|
|
|
|
domain
|
|
|
|
preferredUsername
|
|
|
|
}
|
|
|
|
insertedAt
|
|
|
|
updatedAt
|
2020-08-14 11:32:23 +02:00
|
|
|
deletedAt
|
2020-08-27 11:53:24 +02:00
|
|
|
publishedAt
|
2020-07-09 17:24:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
...DiscussionFields
|
|
|
|
}
|
|
|
|
}
|
|
|
|
${DISCUSSION_FIELDS_FRAGMENT}
|
|
|
|
`;
|
|
|
|
|
|
|
|
export const UPDATE_DISCUSSION = gql`
|
|
|
|
mutation updateDiscussion($discussionId: ID!, $title: String!) {
|
|
|
|
updateDiscussion(discussionId: $discussionId, title: $title) {
|
|
|
|
...DiscussionFields
|
|
|
|
}
|
|
|
|
}
|
|
|
|
${DISCUSSION_FIELDS_FRAGMENT}
|
|
|
|
`;
|
|
|
|
|
|
|
|
export const DELETE_DISCUSSION = gql`
|
|
|
|
mutation deleteDiscussion($discussionId: ID!) {
|
|
|
|
deleteDiscussion(discussionId: $discussionId) {
|
|
|
|
id
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
export const DISCUSSION_COMMENT_CHANGED = gql`
|
|
|
|
subscription($slug: String!) {
|
|
|
|
discussionCommentChanged(slug: $slug) {
|
|
|
|
id
|
|
|
|
lastComment {
|
|
|
|
id
|
|
|
|
text
|
|
|
|
updatedAt
|
|
|
|
insertedAt
|
|
|
|
actor {
|
|
|
|
id
|
|
|
|
preferredUsername
|
2020-10-22 09:37:30 +02:00
|
|
|
name
|
2020-07-09 17:24:28 +02:00
|
|
|
domain
|
|
|
|
avatar {
|
2020-10-22 16:19:26 +02:00
|
|
|
id
|
2020-07-09 17:24:28 +02:00
|
|
|
url
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|