Back to Content Management API

templateHistory

Returns an array of all revisions for the template by ID paginated by a cursor.

Arguments

  • Name
    id
    Type
    ID!
    Description

    The ID of the template.

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

Returns

  • Name
    TemplateVersionConnection.edges
    Type
    [TemplateEdge]!
    Description

    A list of edges.

  • Name
    TemplateVersionConnection.nodes
    Type
    [Template!]!
    Description

    A list of the nodes contained in TemplateEdge.

  • Name
    TemplateVersionConnection.pageInfo
    Type
    PageInfo!
    Description

    Information to aid in pagination.

  • Name
    TemplateVersionConnection.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 templateHistory($id: ID!, $after: String, $before: String, $first: Int, $last: Int) {
  templateVersion(id: $id) {
    edges(after: $after, before: $before, first: $first, last: $last) {
      nodes {
        id
        title
        status
      }
      totalCount
    }
  }
}
`
const variables = {
  id: 'template-id',
  after: 'cursor',
  first: 10
}
const response = await packClient.fetch(query, { variables: variables });
console.log(response.data);

Response

{
    "data": {
        "templateVersion": {
            "edges": [
                {
                    "cursor": "cursor",
                    "node": {
                        "id": "template-id",
                        "title": "Template Title",
                        "status": "DRAFT"
                    }
                }
            ],
            "totalCount": 1
        }
    }
}

Was this page helpful?