GraphQL API

GraphQL API

GraphQL is a modern API language allowing you to efficiently query data from your Fontdue CMS.

A single GraphQL query can fetch anything we've defined the schema, which provides you total flexibility in how you structure your site templates. Learn about writing GraphQL queries here.

Explore with the GraphQL Playground

image

Your site comes with a GraphQL playground to explore the API and make sample queries. When logged in to the Fontdue admin, find the link in the Tools menu.

Click on the green Schema button in the upper right to explore fields available to query.

Write queries and execute them in the left panel. Try this for example:

query {
  viewer {
    fontCollections(first: 10) {
      edges {
        node {
          name
          fontStyles {
            name
            sku {
              price {
                amount
                currency
              }
            }
          }
        }
      }
    }
  }
}

As you can see, GraphQL is a powerful way to query your data. We are driving deep into the data and fetching only the fields we want.

💡

Connections You'll notice some of the fields like fontCollections resolve to a Connection type. This is primarily used for implementing Pagination, which becomes necessary when your collection grows. Many lists resolve to an array rather than a Connection (e.g. Viewer.licenses as well as FontCollection.fontStyles). In those cases we do not expect the size of the list to ever require pagination.