Querying content

How to extract published content out of Pokko

API Keys

To query content you will need to set up an API key. This can be done from the project settings screen.

Click the "New token" button under the "API Tokens" section.

Click the "GraphQL Playground" button to open a website where you can start querying content.

In this UI you will need to specify the token that was generated.

Click "HTTP Headers" down the bottom and enter the following

{
  "X-Token": "<< API TOKEN >>"
}

With this in place, you can start querying your content.

Queries

There are two ways of querying your content.

  1. Querying individual pieces of content - entry()

  2. Querying a list of content of a specific type - entries { }

The GraphQL root query has two queries to access your content - entry and entries

More information about what queries are available can be found in the GraphQL Playground.

Individual entries

With entry you can query individual entries by ID or by Path.

query GetBlogPost {
  entry(id: "...") {
    ... on IBlogPost {
      id
      # additional fields here
    }
  }
}

Multiple entries

With entries you can query multiple entries of a type.

query ListBlogPosts {
  entries {
    allBlogPost(skip: 0, take: 10, filter: { ... }) {
      nodes {
        id
        # additional fields here
      }
      totalCount
    }
  }
}

Caching

A layer of caching is in place for the content querying endpoints. Content will be cached indefinitely until a change to your content is made. When a Publish occurs on an entry the cache will be cleared.

The more complex a GraphQL query is, the longer the initial request will take. Subsequent cached queries will be drastically faster.

GraphQL endpoint

POST https://<region>.pokko.io/:project/:environment/graphql

This endpoint allows you to get free cakes.

Path Parameters

NameTypeDescription

environment

string

project

string

Headers

NameTypeDescription

X-Token

string

Last updated