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
Return Type
Article
Represents an article object with content, author, and comment information.
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.9.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.9.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
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
commentsunless 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_EXCEEDEDerrors. - 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.
Comment
Represents a comment on an article.
Blog
Represents the blog to which the article belongs.
Notes
- The
commentsfield returns only published comments. If comments are disabled for the article, this list will be empty. - The
commentsCountfield reflects the number of published comments. - Fields like
seoDescription,seoTitle, andseoKeywordsare optional and may be null if not set. - The
accountOwnerfield 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 (
isPublishedfield indicates publication status).