Skip to Content

articles

Search and paginate through blog articles.

Query Structure

query { articles( first: Int, after: String, last: Int, before: String, query: String, author: String, language: String, status: String, tags: [String] ) { edges { cursor node { id title content author language status tags publishedAt } } nodes { id title content author language status tags publishedAt } pageInfo { hasNextPage hasPreviousPage startCursor endCursor } totalCount } }

Arguments

ArgumentTypeDescriptionRequiredDefault Value
firstIntReturns the first n elements.NoNone
afterStringReturns elements after the specified cursor.NoNone
lastIntReturns the last n elements.NoNone
beforeStringReturns elements before the specified cursor.NoNone
queryStringSearch query string to filter articles by content.NoNone
authorStringFilter articles by author.NoNone
languageStringFilter articles by language.NoNone
statusStringFilter articles by status (e.g., published, draft).NoNone
tags[String]Filter articles by tags.NoNone

Return Type

ArticleConnection

A connection to a list of Article items.

FieldTypeDescriptionRequired
edges[ArticleEdge]A list of edges containing cursors and nodes.No
nodes[Article]A list of article nodes.No
pageInfoPageInfoPagination information.Yes
totalCountIntTotal number of articles available.No

ArticleEdge

FieldTypeDescriptionRequired
cursorStringCursor for pagination.Yes
nodeArticleThe article node.Yes

Article

FieldTypeDescriptionRequired
idIDUnique identifier of the article.Yes
titleStringTitle of the article.Yes
contentStringContent/body of the article.Yes
authorStringAuthor of the article.Yes
languageStringLanguage of the article.Yes
statusStringStatus of the article (published, draft, etc.).Yes
tags[String]Tags associated with the article.Yes
publishedAtStringPublication date/time in ISO 8601 format.Yes

PageInfo

FieldTypeDescriptionRequired
hasNextPageBooleanIndicates if there is a next page.Yes
hasPreviousPageBooleanIndicates if there is a previous page.Yes
startCursorStringCursor pointing to the first item in the page.Yes
endCursorStringCursor pointing to the last item in the page.Yes

Examples

Basic Query

Fetch the first 5 published articles.

query { articles(first: 5, status: "published") { nodes { id title author publishedAt } totalCount pageInfo { hasNextPage endCursor } } }

Advanced Query

Fetch the next 5 articles after a given cursor, filtering by author and tags, including full content.

query { articles( first: 5, after: "cursor123", author: "Jane Doe", tags: ["graphql", "api"], status: "published" ) { edges { cursor node { id title content author tags publishedAt } } pageInfo { hasNextPage endCursor } totalCount } }

Field Selection

Fetch articles filtering by language and search query, retrieving only id, title, and status.

query { articles( first: 3, query: "performance", language: "en" ) { nodes { id title status } pageInfo { hasNextPage endCursor } } }

cURL Example

curl -X POST https://www.mystoreurl.com/graphql/0.8.0/ \ -H "Content-Type: application/json" \ -d '{"query":"query { articles(first: 3, status: \"published\") { nodes { id title author publishedAt } totalCount pageInfo { hasNextPage endCursor } } }"}'

JavaScript Example

async function fetchPublishedArticles() { const query = ` query { articles(first: 3, status: "published") { nodes { id title author publishedAt } totalCount pageInfo { hasNextPage endCursor } } } `; 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 result = await response.json(); if (result.errors) { console.error('GraphQL errors:', result.errors); return; } console.log('Articles:', result.data.articles.nodes); console.log('Total articles:', result.data.articles.totalCount); } catch (error) { console.error('Network or fetch error:', error); } } fetchPublishedArticles();

Response Format

The response contains an articles field of type ArticleConnection. It includes:

  • edges: An optional list of edges, each with a cursor and an Article node.
  • nodes: An optional list of Article nodes.
  • pageInfo: Pagination details including cursors and page availability.
  • totalCount: The total number of articles matching the query.

Example response snippet:

{ "data": { "articles": { "nodes": [ { "id": "12345", "title": "GraphQL API Best Practices", "author": "Jane Doe", "publishedAt": "2024-04-01T12:00:00Z" } ], "totalCount": 42, "pageInfo": { "hasNextPage": true, "hasPreviousPage": false, "startCursor": "cursor123", "endCursor": "cursor456" } } } }

Error Handling

The API may return errors in the following scenarios:

Error CodeDescriptionHandling Recommendation
BAD_USER_INPUTInvalid argument types or values (e.g., negative first value).Validate inputs before querying.
QUERY_PARSE_ERRORMalformed GraphQL query syntax.Check query syntax and structure.
INTERNAL_SERVER_ERRORServer-side error.Retry after some delay; contact support if persistent.
RATE_LIMIT_EXCEEDEDToo many requests in a short period.Implement exponential backoff and retry.

Errors are returned in the errors array in the GraphQL response. Example:

{ "errors": [ { "message": "Argument 'first' must be a positive integer.", "extensions": { "code": "BAD_USER_INPUT" } } ] }

Performance Considerations

  • Use pagination arguments (first, last, after, before) to limit the number of articles returned per request and avoid large payloads.
  • Leverage filtering arguments (query, author, language, status, tags) to narrow down results and reduce server load.
  • Avoid requesting unnecessary fields to improve response times.
  • Cache responses where possible, especially for queries with stable data such as published articles.
  • Monitor rate limits and implement retry logic with backoff to handle RATE_LIMIT_EXCEEDED errors gracefully.

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.

  • ArticleConnection: Connection type for paginated articles.
  • ArticleEdge: Edge type containing cursor and article node.
  • Article: Article object with fields such as id, title, content, author, language, status, tags, and publishedAt.
  • PageInfo: Pagination metadata with cursors and page availability flags.

Notes

  • Pagination cursors (after, before) are opaque strings returned in the cursor field of edges.
  • The query argument supports full-text search within article content.
  • The status argument accepts values like "published" or "draft" to filter articles by publication state.
  • The tags argument filters articles containing any of the specified tags.
  • The API supports both forward and backward pagination using first/after and last/before respectively.
  • Always check pageInfo.hasNextPage and pageInfo.hasPreviousPage to determine if more pages are available.
Last updated on