article
Get a single article by ID.
Query Structure
query {
article(id: ID!) {
seoDescription
seoTitle
seoKeywords
handle
headerImage
author {
# Author fields (see Related Types)
}
id
title
content
summary
comments {
# Comment fields (see Related Types)
}
commentsCount
blog {
# Blog fields (see Related Types)
}
isPublished
commentsAreEnabled
commentsRequireAccount
commentsRequireApproval
accountOwner
createdAt
updatedAt
}
}
Arguments
Argument | Type | Description | Required | Default Value |
---|---|---|---|---|
id | ID! | The ID of the article to retrieve | Yes | None |
Return Type
Article
Represents an article object with content, author, and comment information.
Field | Type | Description |
---|---|---|
seoDescription | String | Returns description for search engines. |
seoTitle | String | Returns title for search engines. |
seoKeywords | String | Returns keywords for search engines. |
handle | String | Retrieve a handle for this article. |
headerImage | String | Retrieve the associated header image URL for this article. |
author | Author | Returns information about the article’s author as an AuthorDrop. |
id | Int | Get the identifier for this article. |
title | String | Returns the title. |
content | String | Get the content of this article. |
summary | String | Returns the summary (max. 140 characters) for this article. |
comments | [Comment] | List of published comments for this article. Empty if comments are disabled. |
commentsCount | Int | Number of published comments for this article. |
blog | Blog | The blog object this article belongs to. |
isPublished | Boolean | Whether this article is published (unpublished articles are visible in design mode). |
commentsAreEnabled | Boolean | Whether commenting is enabled for this article. |
commentsRequireAccount | Boolean | Whether commenting requires a customer account. |
commentsRequireApproval | Boolean | Whether comments require approval for this article. |
accountOwner | Boolean | Returns true if the author is the owner of the store. |
createdAt | String | Returns the timestamp when the article was published. |
updatedAt | String | Returns the timestamp when the article was updated or modified. |
Examples
Basic Query
query {
article(id: 12345) {
id
title
summary
createdAt
}
}
Advanced Query
query {
article(id: 12345) {
id
title
seoTitle
seoDescription
seoKeywords
handle
headerImage
author {
id
name
email
}
content
summary
commentsCount
comments {
id
authorName
content
createdAt
}
blog {
id
title
handle
}
isPublished
commentsAreEnabled
commentsRequireAccount
commentsRequireApproval
accountOwner
createdAt
updatedAt
}
}
Field Selection
query {
article(id: 12345) {
title
summary
author {
name
}
comments {
authorName
content
}
}
}
cURL Example
curl -X POST https://www.mystoreurl.com/graphql/0.8.0/ \
-H "Content-Type: application/json" \
-d '{"query":"query { article(id: 12345) { id title summary createdAt } }"}'
JavaScript Example
async function fetchArticle(articleId) {
const query = `
query {
article(id: ${articleId}) {
id
title
summary
createdAt
}
}
`;
try {
const response = await fetch('https://www.mystoreurl.com/graphql/0.8.0/', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ query }),
});
const { data, errors } = await response.json();
if (errors) {
console.error('GraphQL errors:', errors);
return null;
}
return data.article;
} catch (error) {
console.error('Network error:', error);
return null;
}
}
// Usage example
fetchArticle(12345).then(article => {
if (article) {
console.log('Article title:', article.title);
}
});
Response Format
The response returns an article
object containing the requested fields. For example:
{
"data": {
"article": {
"id": 12345,
"title": "How to Optimize Your Store",
"summary": "Learn the best practices to optimize your e-commerce store...",
"createdAt": "2023-11-15T10:20:30Z"
}
}
}
If the article is not found, article
will be null
.
Error Handling
Error Code | Description | Resolution |
---|---|---|
BAD_USER_INPUT | The provided id argument is invalid or missing. | Verify that the id is a valid integer and provided. |
NOT_FOUND | No article exists with the provided id . | Confirm the article ID exists in the system. |
INTERNAL_SERVER_ERROR | An unexpected error occurred on the server. | Retry the request later or contact support. |
RATE_LIMIT_EXCEEDED | Too many requests in a short period. | Implement retry with exponential backoff. |
Errors will be returned in the errors
array of the GraphQL response.
Performance Considerations
- Request only the fields you need to minimize response size and improve performance.
- Avoid fetching large nested fields like
comments
unless necessary. - Use pagination on related fields (e.g., comments) if supported in future API versions.
- The API enforces rate limiting; excessive requests may result in
RATE_LIMIT_EXCEEDED
errors. - Responses may be cached by intermediate proxies; consider cache headers if applicable.
Authentication
This API currently does not require authentication. However, authentication requirements may be introduced in future versions. Monitor API updates for any changes to authentication requirements.
Related Types
Author
Represents the author of an article.
Field | Type | Description |
---|---|---|
id | Int | Identifier of the author. |
name | String | Name of the author. |
String | Email address of the author. |
Comment
Represents a comment on an article.
Field | Type | Description |
---|---|---|
id | Int | Identifier of the comment. |
authorName | String | Name of the comment’s author. |
content | String | Content of the comment. |
createdAt | String | Timestamp when comment was made. |
Blog
Represents the blog to which the article belongs.
Field | Type | Description |
---|---|---|
id | Int | Identifier of the blog. |
title | String | Title of the blog. |
handle | String | Handle (slug) of the blog. |
Notes
- The
comments
field returns only published comments. If comments are disabled for the article, this list will be empty. - The
commentsCount
field reflects the number of published comments. - Fields like
seoDescription
,seoTitle
, andseoKeywords
are optional and may be null if not set. - The
accountOwner
field indicates if the article’s author is the store owner. - Timestamps are returned as ISO 8601 strings.
- Unpublished articles are visible in design mode only (
isPublished
field indicates publication status).
Last updated on