Back to Content Management API

collectionPages

Returns array of all your collection pages 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 page you want to retrieve.

    • To get the latest content use CURRENT.
    • To get the latest published content use PUBLISHED

Returns

  • Name
    CollectionPageConnection.edges
    Type
    [CollectionPageEdge!]!
    Description

    A list of edges.

  • Name
    CollectionPageConnection.nodes
    Type
    [CollectionPage!]!
    Description

    A list of the nodes contained in collectionPageEdge.

  • Name
    CollectionPageConnection.pageInfo
    Type
    CollectionPageInfo!
    Description

    Information to aid in pagination.

  • Name
    collectionPageConnection.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 GetCollections($version: Version) {
  collectionPages(version: $version) {
    totalCount
    edges {
      node {
        ... on PageResource {
          title
          handle
          description
        }
      }
    }
  }
}
`
const response = await packClient.fetch(query);
console.log(response.data);

Response

{
    "data": {
        "collectionPages": {
            "totalCount": 2,
            "edges": [
                {
                    "node": {
                        "title": "Collection Title",
                        "handle": "collection-handle",
                        "description": "Collection Description"
                    }
                },
                {
                    "node": {
                        "title": "Collection Title",
                        "handle": "collection-handle",
                        "description": "Collection Description"
                    }
                }
            ]
        }
    }
}

Was this page helpful?