GraphQL schema

A schema describes how data is organized and structured. It defines a hierarchy of types with fields that are populated from the content. The schema also specifies exactly which queries are available for clients to execute against the data graph.

Important

The Preview API and Delivery API do not support mutations.

You can use GraphQL to verify the data types available by querying the __schema field. This field is always available on the root type of a query.

To display all the types that are present in the schema, run the following command:

RequestResponse
{
 __schema {
  types {
   name
  }
 }
}

You can also access the schema from the SCHEMA tab on the right-hand side of the GraphQL IDE. You can download the schema by clicking the DOWNLOAD button on the SCHEMA tab.

Note

Most GraphQL IDEs perform an introspection query over the schema to provide additional tools to the developer (such as autocomplete) and to show information about the schema.

Types

The GraphQL types show how entity definitions are mapped in GraphQL. The types available depend on the schema.

Scalar types

Scalar types are basic data types that always resolve to concrete data. Sitecore Content Hub includes the following default scalar types.

Scalar type

Description

Int

A signed 32‐bit integer.

Float

A signed, double-precision, floating-point value.

String

A UTF‐8 character sequence.

Boolean

A true or false value.

ID (serialized as a string)

A unique identifier either used to fetch an object, or used as a key for a cache. Although it is serialized as a string, an ID is not intended to be human‐readable.

Content Hub also includes the following custom scalar data types.

Scalar type

Description

MultiplierPath

A valid GraphQL multiplier path string.

DateTime

A date time in 2021-01-19T17:33:00.000Z format.

Long

An extended-capacity variable for storing exceptionally large numbers.

Decimal

Decimal variables are stored as 96-bit (12-byte) unsigned integers, together with a scaling factor and a value indicating whether the decimal number is positive or negative.

Object types

Most of the types you define in a GraphQL schema are object types. An object type contains fields, each of which can be either a scalar type or another object type. For Content Hub, there are several types in the GraphQL schema for each publishable entity definition. You can list the types generated: a singular query type, an all query type, a predicate type for writing where clauses, or a single return type. The fields of these types are generated based on the field of the entity definition. The DOCS tab in the IDE contains more information about object types.

Do you have some feedback for us?

If you have suggestions for improving this article,