Article
Represents an article object with content, author, and comment information.
Type Definition
type Article {
seoDescription: String
seoTitle: String
seoKeywords: String
handle: String
headerImage: String
author: Author
id: Int
title: String
content: String
summary: String
comments: [Comment]
commentsCount: Int
blog: Blog
isPublished: Boolean
commentsAreEnabled: Boolean
commentsRequireAccount: Boolean
commentsRequireApproval: Boolean
accountOwner: Boolean
createdAt: String
updatedAt: String
}
Fields
Field | Type | Nullable | Description | Related Type |
---|---|---|---|---|
seoDescription | String | Yes | Returns description for search engines. | |
seoTitle | String | Yes | Returns title for search engines. | |
seoKeywords | String | Yes | Returns keywords for search engines. | |
handle | String | Yes | Retrieve a handle for this article. | |
headerImage | String | Yes | Retrieve the associated header image URL for this article. | |
author | Author | Yes | Returns information about the article’s author as an Author object. | Author |
id | Int | Yes | Get the identifier for this article. | |
title | String | Yes | Returns the title. | |
content | String | Yes | Get the content of this article. | |
summary | String | Yes | Returns the summary (max. 140 characters) for this article. | |
comments | [Comment] | Yes | List of published comments for this article. Empty if comments are disabled. | Comment |
commentsCount | Int | Yes | Number of published comments for this article. | |
blog | Blog | Yes | The blog object this article belongs to. | Blog |
isPublished | Boolean | Yes | Whether this article is published (unpublished articles are visible in design mode). | |
commentsAreEnabled | Boolean | Yes | Whether commenting is enabled for this article. | |
commentsRequireAccount | Boolean | Yes | Whether commenting requires a customer account. | |
commentsRequireApproval | Boolean | Yes | Whether comments require approval for this article. | |
accountOwner | Boolean | Yes | Returns true if the author is the owner of the store. | |
createdAt | String | Yes | Returns the timestamp when the article was published. | |
updatedAt | String | Yes | Returns the timestamp when the article was updated or modified. |
Relationships
- author: Links to the
Author
object representing the article’s author details. - comments: Connects to a list of
Comment
objects representing published comments on the article. - blog: References the
Blog
object to which this article belongs.
These relationships allow you to traverse from an article to its author, comments, and parent blog, enabling rich nested queries.
Usage Examples
Basic Query
Fetch basic SEO and article metadata:
{
article(id: 12345) {
id
title
seoTitle
seoDescription
seoKeywords
handle
isPublished
}
}
Field Selection
Retrieve detailed article content along with author and comment count:
{
article(id: 12345) {
title
summary
content
author {
id
name
bio
}
commentsCount
commentsAreEnabled
}
}
Nested Queries
Access nested related objects including blog details and published comments:
{
article(id: 12345) {
title
blog {
id
title
handle
}
comments {
id
authorName
content
createdAt
}
}
}
Filtering and Sorting
Filter articles by published status and sort by creation date descending:
{
articles(filter: { isPublished: true }, sort: { field: "createdAt", direction: DESC }) {
edges {
node {
id
title
createdAt
}
}
}
}
Note: The above example assumes a root
articles
query with filtering and sorting capabilities, which may vary depending on your API schema.
Implements
The Article
type does not explicitly implement any interfaces in the current schema.
Connections
comments
field returns a list ofComment
objects representing published comments.author
field connects to anAuthor
object.blog
field connects to aBlog
object.
These connections enable nested data retrieval and relationship traversal.
Related Types
- Author: Provides author details such as name and bio.
- Comment: Represents individual comments published on the article.
- Blog: Represents the blog container to which the article belongs.
Best Practices
- When querying articles with comments, consider requesting only the necessary comment fields to optimize response size.
- Use filtering and sorting on articles to efficiently retrieve published content based on date or status.
- Leverage the
summary
field for preview displays limited to 140 characters. - Use the
handle
field for SEO-friendly URLs or routing. - Check
commentsAreEnabled
before displaying comment submission UI. - Use
createdAt
andupdatedAt
timestamps for content freshness indicators.
Notes
- All fields on
Article
are optional and may be null if data is unavailable. - The
comments
list will be empty if comments are disabled for the article. - The API currently requires no authentication; however, this may change in future versions.
- Use pagination and filtering where applicable to avoid large payloads when querying lists of articles or comments.
- The
accountOwner
boolean indicates if the author is the store owner, useful for distinguishing official posts. - Timestamps are returned as ISO 8601 strings.
- No computed or derived fields are defined beyond the provided fields.
- No field arguments are defined on
Article
fields.
For any queries, use the endpoint:
https://www.mystoreurl.com/graphql/0.8.0
Example with error handling in JavaScript (using fetch
):
async function fetchArticle(articleId) {
const query = `
query GetArticle($id: Int!) {
article(id: $id) {
id
title
content
author {
name
}
}
}
`;
const variables = { id: articleId };
try {
const response = await fetch('https://www.mystoreurl.com/graphql/0.8.0', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ query, variables }),
});
const result = await response.json();
if (result.errors) {
console.error('GraphQL errors:', result.errors);
return null;
}
return result.data.article;
} catch (error) {
console.error('Network error:', error);
return null;
}
}
This example demonstrates how to query an article by ID and handle possible errors gracefully.