Content Graph schema
This topic describes how to access the GraphQL schema for the Optimizely querying service, when retrieving content in Optimizely solutions.
Optimizely Content Graph Schema
Optimizely Content Graph uses a GraphQL schema to describe the shape of the data available to client applications that call the service. The schema defines a hierarchy of types and fields that are populated from the back-end data store. The schema also specifies which queries and mutations are available for clients to execute against the data graph.
Content Graph generates a unique schema for every site that syncs its data to the service. The shape of the data will depend upon how the content types have been defined in that site's configuration. Exploring your sites uniquely generated schema is an essential part of build query-driven applications with Content Graph.
Accessing the schema
The generated GraphQL schema can be found by accessing the API Gateway with your public key. For instructions on how to do this, see Getting started with the GraphQL API. The GraphQL schema can also be accessed from the GraphQL UI.
Methods and parameters
GraphQL schemas contain one method per content type, and each method contains several Parameters. Each method has a return type that matches the properties for the content type. This makes it possible to select which content type properties to return in the result.
Field names, reserved fields and characters
GraphQL schemas contain regular field names of content, reserved field names, input arguments, enumerated values and reserved characters. The (naming) convention for these parts of a schema is as follows:
- Field names (regular) follows the conventions of the site's content delivery model. For example, if the model is serialized as Pascal case, the fields will also appear as Pascal case in the GraphQL schema. These fields appear in the Input and Output types.
- The schema type or name of the schema is in Pascal case.
- Reserved field names are field names starting with an underscore prefix that allow special functionality:
_fulltextis a concatenation of the values of all searchable fields
_childrenis a special field that allows embedding a method for a content type within a parent content type.
_rankingallows ordering the results by a relevance score, internal document ID or other special metrics.
_modifiedis a date field that indicates when the content was ingested.
_notare used for expressing Boolean logic in queries.
- Root level fields are fields which are in camel case:
itemsis the root level for projecting the actual results.
totalshows the hit count or number of matching results given by the query.
facetsprojects the aggregated values of a field, including matching hit count. These values can then be used for filtering.
cursorshows the value that can be used to do pagination with a cursor.
- Input argument are names of arguments in a method which follow snake case convention.
- Enumerated values are fixed values in uppercase and snake case belonging to input arguments or reserved fields:
- the reserved
field _rankinghas the values
localeargument has different language codes like
FR, and so on..
- the reserved
- Reserved characters are part of the GraphQL syntax and need to be escaped with a single backslash for querying. These characters are double quote (
\") and backslash (
The following illustration summarizes these conventions hierarchically:
Updated about 2 months ago