Fluent Commerce Logo
Docs

Get Comment by Id

Essential knowledge

Intended Audience:

Technical User

Author:

Kirill Gaiduk

Changed on:

20 Feb 2025

Overview

The `commentById` Query retrieves a Comment based on a provided Id.
Prerequisites
  • `COMMENT_VIEW` Permission is required for retrieving a Comment

Key points

  • Use the `commentById` Query to retrieve an existing Comment
  • Manage the Comment Permissions at the Account or Retailer level
  • Apply the "Retailer-specific Comment Permission Check" validation logic with the `fc.graphql.comment.access` Setting (`retailer` value)

Inputs

The Input arguments for retrieving a single Comment:
ArgumentTypeDescription
`id`ID!Id of the Comment

Validation

Comment Permissions could be managed at the Account or Retailer level, which is controlled via the `fc.graphql.comment.access` SettingThe `retailer` Setting value enables the Retailer-specific access management, so the validation logic is applied to verify that your User has the correct rights to execute the `commentById` Query - "Retailer-specific Comment Permission Check":
  • A target Comment is found by its Id (input)
  • A Comment Entity `retailerId` field stores a Retailer of the associated Entity
  • The Comment `retailerId` is compared to the querying User `retailerId` (defined with the User Role Context Id)
  • The Comment is retrieved upon the mentioned (User and Comment) `retailerId`'s match

Response

The response consists of the details of the Comment:
FieldTypeDescriptionNotes
`id`ID!Id of the Comment
`entityType`String!Type of the EntityFor example:
  • `ORDER`
  • `FULFILMENT`
  • `ORDER_ITEM`
  • `PRODUCT_CATALOGUE`
`entityId`IDId of the Entity
`entityRef`StringReference of the Entity
`text`String! Comment textMax character limit: 200
`createdOn`DateTimeTime of the Comment creation
`updatedOn`DateTimeTime of the Comment last update
`user`UserThe author of the Comment
  • Filled in upon the Comment creation
  • Updated upon the Comment update
  • `USER_VIEW` Permission is required

Sample Payload

1query commentById ($id: ID!) {
2    commentById (id: $id) {
3        id
4        entityType
5        entityId
6        entityRef
7        text
8        createdOn
9        updatedOn
10        user {
11           username
12           id
13           ref
14           primaryEmail
15           firstName
16           lastName
17           timezone
18        }
19    }
20}
1{
2  "id": 123
3}