Anchor to comment
comment
query
Returns a Comment resource by ID.
Anchor to Possible returnsPossible returns
- Anchor to CommentComment•
A comment on an article.
- article•Article
The article associated with the comment.
- author•Commentnon-null
Author! The comment’s author.
- body•String!non-null
The content of the comment.
- body
Html• HTML!non-null The content of the comment, complete with HTML formatting.
- created
At• Datenon-nullTime! The date and time when the comment was created.
- events
• Eventnon-nullConnection! The paginated list of events associated with the host subject.
- id•ID!non-null
A globally-unique ID.
- ip•String
The IP address of the commenter.
- is
Published• Boolean!non-null Whether or not the comment is published.
- published
At• DateTime The date and time when the comment was published.
- status•Commentnon-null
Status! The status of the comment.
- updated
At• DateTime The date and time when the comment was last updated.
- user
Agent• String The user agent of the commenter.
- article•
Was this section helpful?
Retrieves a single comment by its ID
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query CommentShow($id: ID!) {
comment(id: $id) {
id
body
bodyHtml
author {
name
}
ip
publishedAt
status
userAgent
}
}`,
{
variables: {
"id": "gid://shopify/Comment/9450891"
},
},
);
const data = await response.json();
query CommentShow($id: ID!) {
comment(id: $id) {
id
body
bodyHtml
author {
name
}
ip
publishedAt
status
userAgent
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "query CommentShow($id: ID!) { comment(id: $id) { id body bodyHtml author { name } ip publishedAt status userAgent } }",
"variables": {
"id": "gid://shopify/Comment/9450891"
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query CommentShow($id: ID!) {
comment(id: $id) {
id
body
bodyHtml
author {
name
}
ip
publishedAt
status
userAgent
}
}`,
{
variables: {
"id": "gid://shopify/Comment/9450891"
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `query CommentShow($id: ID!) {
comment(id: $id) {
id
body
bodyHtml
author {
name
}
ip
publishedAt
status
userAgent
}
}`,
"variables": {
"id": "gid://shopify/Comment/9450891"
},
},
});
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
query CommentShow($id: ID!) {
comment(id: $id) {
id
body
bodyHtml
author {
name
}
ip
publishedAt
status
userAgent
}
}
QUERY
variables = {
"id": "gid://shopify/Comment/9450891"
}
response = client.query(query: query, variables: variables)
Input variables
JSON{
"id": "gid://shopify/Comment/9450891"
}
Response
JSON{
"comment": {
"id": "gid://shopify/Comment/9450891",
"body": "Check my casino at ... This will be marked as spam by akismet, because of the author name.",
"bodyHtml": "<p>Check my casino at ... This will be marked as spam by akismet, because of the author name.</p>",
"author": {
"name": "viagra-test-123"
},
"ip": "127.0.0.1",
"publishedAt": null,
"status": "SPAM",
"userAgent": "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_4; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1"
}
}