Data Queries That are Available with GraphCMS

A giant pro for using GraphCMS as your primary content management system, is the simplicity of GraphQL queries. Our developers have made sure that all necessary and useful queries are made available for your workflows.

Architecture of a Query

What is a Query API?

A Query API is an application interface strictly concerning the read layer. In the instance of GraphCMS, you will "query" one or more pieces of data that you want. This is done by specifying the content model you want data from and a corresponding sub-selection of fields.

Single Queries

Single Queries are just that! Query one object or content node. Query for an author by defining the id field.

{
  query {
    author(id: "001") {
      name
    }
  }
}

Querying Multiple Items

Ask, and you shall receive. Query multiple objects or content nodes. In this instance, ask for all titles and authors.

{
  query {
    posts {
      id
      title
      author {
        name
      }
    }
  }
}

Querying Across Relations

Asking for all information across relations can be extremely useful. Querying any blog posts written by a specific author is as simple as asking for it.

{
  query {
    author(where: {id: "001"}) {
      id
      name
      posts {
        id
        title
      }
    }
  }
}

Query Arguments

Within the query API, arguments can be combined in a number of ways to specify the responses. Here are a few argument combinations for you to try:

Ordering by Field

When querying all nodes of a type you can supply the orderBy argument for every scalar field by either Ascending or Descending order.

Filtering by Fields

Single: supply exactly one parameter
Combining: Filter combinators OR and AND create arbitrary logical combinations
Relational filters: To-one relations, define conditions by nesting the argument

Pagination

When querying all nodes of a type you can supply the orderBy argument for every scalar field of with the type Ascending or Descending.

Interested in Learning More About Features of GraphCMS?

GraphCMS has all of the most important features of a robust content management system, while also pioneering proprietary features for the era of application content. Learn more in these landing pages all about GraphCMS' features.