Back to Content Management API
sections
Returns array of all your sections 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 section 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
SectionConnection.edges
- Type
- [SectionEdge!]!
- Description
A list of edges.
- Name
SectionConnection.nodes
- Type
- [Section!]!
- Description
A list of the nodes contained in SectionEdge.
- Name
SectionConnection.sectionInfo
- Type
- SectionInfo!
- Description
Information to aid in pagination.
- Name
SectionConnection.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 {
sections {
edges {
cursor
node {
title
handle
description
}
}
totalCount
}
}
`
const response = await packClient.fetch(query);
console.log(response.data);
Response
{
"data": {
"sections": {
"edges": [
{
"cursor": "cursor",
"node": {
"title": "Section Title",
"handle": "section-title",
"description": "Section Description"
}
},
{
"cursor": "cursor",
"node": {
"title": "Section Title",
"handle": "section-title",
"description": "Section Description"
}
}
],
"totalCount": 2
}
}
}