Query Comments
Author:
Kirill Gaiduk
Changed on:
6 Dec 2024
Overview
The `comments`
Prerequisites
- Permission is required for retrieving Comments
`COMMENT_VIEW`
Key points
- Use the Query to retrieve existing Comments
`comments`
- Manage the Comment Permissions at the Account or Retailer level
- Apply the "Retailer-specific Comment Permission Check" validation logic with the Setting (
`fc.graphql.comment.access`
value)`retailer`
Inputs
The Input arguments for retrieving Comments:
Argument | Type | Description | Notes |
| [String!] | Type of the Entity | For example:
|
| [ID] | Id of the Entity | |
| [String] | Reference of the Entity | |
| [String!] | Comment text | |
| DateRange | Date range for Comments creation | |
| DateRange | Date range for Comments last update | |
| Int | Returns the first n elements from the list | |
| Int | Returns the last n elements from the list | |
| String | Returns the elements in the list that come before the specified global Id | This is a cursor (the value is used for pagination) |
| String | Returns the elements in the list that come after the specified global Id | This is a cursor (the value is used for pagination) |
Validation
Comment Permissions could be managed at the Account or Retailer level, which is controlled via the `fc.graphql.comment.access`
The
`retailer`
`comments`
- Comments are searched by the given Input Arguments
- A Comment Entity field stores a Retailer of the associated Entity
`retailerId`
- For all the found Comments, the Comment is compared to the querying User
`retailerId`
(defined with the User Role Context Id)`retailerId`
- The list of the retrieved Comments contains:
- The Comments for which the mentioned (User and Comment) -s matches
`retailerId`
- The Comments with empty
`retailerId`
- The Comments for which the mentioned (User and Comment)
Response
The response consists of Edges and Nodes representing the Comments:
Field | Type | Description | Notes |
| ID! | Id of the Comment | |
| String! | Type of the Entity | For example:
|
| ID | Id of the Entity | |
| String | Reference of the Entity | |
| String! | Comment text | |
| DateTime | Time of the Comment creation | |
| DateTime | Time of the Comment last update | |
| User | The author of the Comment |
|
Sample Payload
1query comments($createdOn: DateRange) {
2 comments(createdOn: $createdOn) {
3 edges {
4 node {
5 id
6 entityId
7 entityRef
8 entityType
9 text
10 createdOn
11 updatedOn
12 }
13 cursor
14 }
15 }
16}
Language: graphqlschema
Name: Sample comments Query
Description:
Getting the Comments created within the specified date range.
API Endpoint:
`POST: {{fluentApiHost}}/graphql`
1{
2 "createdOn": {
3 "from": "2024-11-16T00:32:28.935Z",
4 "to": "2024-11-16T23:40:28.935Z"
5 }
6}
Language: graphqlschema
Name: Sample GraphQL Variables for the comments Query
Description:
Getting the Comments created within the specified date range.