Create Comment
Author:
Kirill Gaiduk
Changed on:
9 Dec 2024
Overview
The `createComment`
Prerequisites
Specific Permissions are required for creating Comments:
`COMMENT_CREATE`
`COMMENT_VIEW`
Key points
- Use the Mutation to create a Comment against a known Entity
`createComment`
- 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`
- Created Comments inherit the of the associated Entity
`retailerId`
Inputs
The Input fields for creating a Comment are defined with the `createCommentInput`
Field | Type | Description | Notes |
| String! | Type of the Entity | For example:
Max character limit: 255 |
| ID | Id of the Entity | While the type of this field is ID, it currently only supports Integer values |
| String | Reference of the Entity | Max character limit: 255 |
| String! | Comment text | Max character limit: 200 |
Validation
Comment Permissions could be managed at the Account or Retailer level, which is controlled via the `fc.graphql.comment.access`
The
`retailer`
`createComment`
1. Determine the `retailerId`
of the Entity (associated with the Comment)
`retailerId`
Entity Type Validation
- The given (Input) is compared with the existing Types (from the GraphQL Schema):
`entityType`
- Case is ignored (e.g., matches
`ORDER`
)`Order`
- Underscore is ignored (e.g., matches
`CREDIT_MEMO`
)`CreditMemo`
- Known exception: will be recognized as
`FULFILMENT_OPTIONS`
Type`FulfilmentOption`
- Case is ignored (e.g.,
- The corresponding Database Entity Class is determined for the found GraphQL Type (e.g., Type corresponds to the
`ORDER`
Class)`CustomerOrderEntity`
Entity Id or Reference Validation
- The Create Comment Payload could contain:
- only
`entityId`
- only
`entityRef`
- Both and
`entityId`
`entityRef`
- is always considered first (to define the corresponding Entity for Comment creation)
`entityId`
- is considered when
`entityRef`
was not provided`entityId`
Entity Retailer Id Validation
- The value of the Entity found with the provided
`retailerId`
,`entityType`
/`entityId`
is automatically retrieved:`entityRef`
- For Entity Types with the direct Retailer association, e.g., is taken from the
`retailerId`
field value for Orders`order.retailer`
- For Entity Types without the direct Retailer association, the is attempted to be taken from a "Parent" Entity. For example, find the Fulfillment (with the provided
`retailerId`
,`entityType`
/`entityId`
) --> find its "Parent" Order --> get the`entityRef`
from the Order`retailerId`
- For Entity Types with the direct Retailer association, e.g.,
- Comment field is filled in with the associated Entity Retailer value found.
`retailerId`
- Comment field remains empty when:
`retailerId`
- The associated Entity was not found
`retailerId`
- The associated Entity is a cross-Retailer one (e.g., Inventory Domain Entities, like Inventory Position, Virtual Catalog, etc.)
- The Setting value is set to
`fc.graphql.comment.access`
`account`
- The associated Entity
2. Compare the querying User `retailerId`
to the associated Entity `retailerId`
`retailerId`
`retailerId`
The User
`retailerId`
A Comment is created upon the mentioned (User and Entity)
`retailerId`
Response
The response consists of the details of the Comment:
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
1mutation createComment ($input: CreateCommentInput) {
2 createComment (input: $input) {
3 id
4 entityType
5 entityRef
6 entityId
7 text
8 createdOn
9 updatedOn
10 }
11}
Language: graphqlschema
Name: Sample createComment Mutation
Description:
Creating a Comment.
API Endpoint:
`POST: {{fluentApiHost}}/graphql`
1{
2 "input": {
3 "entityType": "ORDER",
4 "entityId": "123",
5 "text": "Sample Comment for the Order"
6 }
7}
Language: graphqlschema
Name: Sample GraphQL Variables for the createComment Mutation
Description:
Creating a Comment for the Order with a specified Id.
1{
2 "data": {
3 "createComment": {
4 "id": "26963",
5 "entityType": "ORDER",
6 "entityRef": null,
7 "entityId": "123",
8 "text": "Sample Comment for the Order",
9 "createdOn": "2024-12-09T09:15:57.396Z",
10 "updatedOn": "2024-12-09T09:15:57.396Z"
11 }
12 }
13}
Language: graphqlschema
Name: createComment Mutation Response Example
Description:
Creating a Comment for the Order with a specified Id.