Skip to Content

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

FieldTypeNullableDescriptionRelated Type
seoDescriptionStringYesReturns description for search engines.
seoTitleStringYesReturns title for search engines.
seoKeywordsStringYesReturns keywords for search engines.
handleStringYesRetrieve a handle for this article.
headerImageStringYesRetrieve the associated header image URL for this article.
authorAuthorYesReturns information about the article’s author as an Author object.Author
idIntYesGet the identifier for this article.
titleStringYesReturns the title.
contentStringYesGet the content of this article.
summaryStringYesReturns the summary (max. 140 characters) for this article.
comments[Comment]YesList of published comments for this article. Empty if comments are disabled.Comment
commentsCountIntYesNumber of published comments for this article.
blogBlogYesThe blog object this article belongs to.Blog
isPublishedBooleanYesWhether this article is published (unpublished articles are visible in design mode).
commentsAreEnabledBooleanYesWhether commenting is enabled for this article.
commentsRequireAccountBooleanYesWhether commenting requires a customer account.
commentsRequireApprovalBooleanYesWhether comments require approval for this article.
accountOwnerBooleanYesReturns true if the author is the owner of the store.
createdAtStringYesReturns the timestamp when the article was published.
updatedAtStringYesReturns 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 of Comment objects representing published comments.
  • author field connects to an Author object.
  • blog field connects to a Blog object.

These connections enable nested data retrieval and relationship traversal.

  • 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 and updatedAt 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.

Last updated on