Back to Content Management API
blogs
Returns array of all your blogs in a draft or published state paginated by a cursor.
Arguments
- Name
after
- Type
- String
- Description
Returns the elements that come after the specified cursor.
- Name
before
- Type
- String
- Description
Returns the elements that come before the specified cursor.
- Name
first
- Type
- Int
- Description
Returns up to the first
n
elements from the list.
- Name
last
- Type
- Int
- Description
Returns up to the last
n
elements from the list.
- Name
version
- Type
- Version
- Description
The state of the blog you want to retrieve.
- To get the latest content use
CURRENT
. - To get the latest published content use
PUBLISHED
- To get the latest content use
Returns
- Name
BlogConnection.edges
- Type
- [BlogEdge!]!
- Description
A list of edges.
- Name
BlogConnection.nodes
- Type
- [Blog!]!
- Description
A list of the nodes contained in BlogEdge.
- Name
BlogConnection.blogInfo
- Type
- BlogInfo!
- Description
Information to aid in pagination.
- Name
BlogConnection.totalCount
- Type
- Int
- Description
The total count of items.
Request
import { PackClient } from '@pack/client'
const packClient = new PackClient({
token: 'YOUR-PACK-TOKEN'
});
const query = `
query Blogs($version: Version) {
blogs (version: $version) {
totalCount
edges {
node {
... on PageResource {
title
handle
description
}
}
}
}
}
`
const variables = {
version: 'PUBLISHED',
}
const response = await packClient.fetch(query, { variables: variables });
console.log(response.data);
Response
{
"data": {
"blogs": {
"totalCount": 2,
"edges": [
{
"node": {
"title": "Blog Title",
"handle": "blog-handle",
"description": "Blog description."
}
},
{
"node": {
"title": "Blog Title",
"handle": "blog-handle",
"description": "Blog description."
}
}
]
}
}
}