This repository was archived by the owner on Feb 27, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +45
-18
lines changed Expand file tree Collapse file tree 1 file changed +45
-18
lines changed Original file line number Diff line number Diff line change 1
- /*
2
- query MyQuery {
3
- comments(where: {contentId: "1148"}) {
4
- pageInfo {
5
- endCursor
6
- hasNextPage
7
- hasPreviousPage
8
- startCursor
9
- }
10
- edges {
11
- node {
12
- databaseId
13
- content(format: RENDERED)
14
- parentDatabaseId
15
- approved
16
- id
1
+ import { gql } from '@apollo/client'
2
+ import archivePageInfo from '../_partials/archivePageInfo'
3
+
4
+ // Fragment: retrieve comment fields.
5
+ const commentFragment = gql `
6
+ fragment CommentFields on Comment {
7
+ databaseId
8
+ content(format: RENDERED)
9
+ parentDatabaseId
10
+ approved
11
+ id
12
+ date
13
+ parentId
14
+ commentId
15
+ type
16
+ }
17
+ `
18
+
19
+ // Query: retrieve comments by post databaseId.
20
+ const queryCommentsByPostId = gql `
21
+ query GET_COMMENTS_BY_POST_ID(
22
+ $id: ID!
23
+ $first: Int
24
+ $last: Int
25
+ $after: String
26
+ $before: String
27
+ $order: OrderEnum = ASC
28
+ $orderby: CommentsConnectionOrderbyEnum = COMMENT_DATE
29
+ ) {
30
+ comments(
31
+ first: $first
32
+ last: $last
33
+ after: $after
34
+ before: $before
35
+ where: {contentId: $id, order: $order, orderby: $orderby}
36
+ ) {
37
+ ${ archivePageInfo }
38
+ edges {
39
+ node {
40
+ ...CommentFields
41
+ }
17
42
}
18
43
}
19
44
}
20
- }
21
- */
45
+ ${ commentFragment }
46
+ `
47
+
48
+ export default queryCommentsByPostId
You can’t perform that action at this time.
0 commit comments