Repository navigation
Expand file tree
/
Copy pathcommentTypeDef.js
More file actions
99 lines (85 loc) · 2.77 KB
/
Copy pathcommentTypeDef.js
File metadata and controls
99 lines (85 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//language=GraphQL Schema
export const commentTypeDef = `
enum CommentSortingField {
createdAt
ratingScore
}
# Used to define what to sort by
input CommentSortingInput {
# Field to sort by
field: CommentSortingField!
# 1 or -1
direction: Int
}
# Anonymous user data structure
input CommentAnonData {
id: String!
salt: String!
}
# Represents **comment media**
# such as a youtube video, image link, video link etc.
type CommentMedia {
type: String!
content: String!
}
# Represents a **user** that left a comment.
# Can be anonymous if configured by comments pkg
type CommentUser {
id: String!
displayName: String!
isAnonymous: Boolean!
comments: [Comment]
}
# Represents a **comment** with nested replies and user metadata.
# Can also represent a **reply**, which is distinguishable by the isReply field.
type Comment {
id: String!
# Identifier of root comment if reply
rootId: String
# Status: approved, pending
status: String!
# Comment Topic Identifier.
# Provided to differentiate between topics.
# For example the blog post id that's discussed
referenceId: String!
content: String!
user: CommentUser!
likesCount: Int!
dislikesCount: Int!
# Rating score.
# * if likes and dislikes => likes substracted by dislikes
# * if star rating => avg of stars given
ratingScore: Float!
createdAt: String!
lastUpdatedAt: String
media: CommentMedia
isReply: Boolean!
replies: [Comment]
}
extend type Query {
getComment(id: String!): Comment
listComments(
referenceId: String!
limit: Int!
skip: Int
sorting: CommentSortingInput
): [Comment]
countComments(referenceId: String!): Int!
}
extend type Mutation {
# Add a comment to a topic identified by the referenceId
addComment(referenceId: String! content: String! anonData: CommentAnonData): Comment
editComment(id: String! content: String! anonData: CommentAnonData): Comment
removeComment(id: String! anonData: CommentAnonData): Comment
likeComment(id: String! anonData: CommentAnonData): Comment
dislikeComment(id: String! anonData: CommentAnonData): Comment
starComment(id: String! starsCount: Int anonData: CommentAnonData): Comment
# Add a reply to a comment or reply (if to a reply replyId has to be additionally provided)
addReply(rootId: String! replyId: String content: String! anonData: CommentAnonData): Comment
editReply(rootId: String! replyId: String content: String! anonData: CommentAnonData): Comment
removeReply(rootId: String! replyId: String anonData: CommentAnonData): Comment
likeReply(rootId: String! replyId: String anonData: CommentAnonData): Comment
dislikeReply(rootId: String! replyId: String anonData: CommentAnonData): Comment
starReply(rootId: String! replyId: String starsCount: Int anonData: CommentAnonData): Comment
}
`