Optimizely Graph schema
How to access the GraphQL schema for the Optimizely querying service when retrieving content in Optimizely solutions.
Optimizely 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 from the back-end data store and specifies which queries and mutations are available against the data graph.
Optimizely Graph generates a unique schema for every site that syncs its data to the service. The shape of the data depends on how the content types are defined in that site's configuration. Exploring your site's uniquely generated schema is essential to build query-driven applications with Optimizely Graph.
Access the schema
Access the API Gateway with your public key to find the generated GraphQL schema. See Get started with the GraphQL API. You can also use the GraphQL UI to access the GraphQL schema.
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 of the content type. This lets you 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.
Important
Optimizely Graph's reserved fields start with underscore
_
and are used by the system. Do not use fields prefixed with underscores in your domain models. The system cannot guarantee all the query and search capabilities to work correctly for any field starting with an underscore.
The naming convention for these parts of a schema is as follows:
- Field names (regular) follow the site's content delivery model conventions. For example, if the model is serialized as Pascal case, the fields also display as Pascal case in the GraphQL schema. These fields are displayed in the Input and Output types.
The schema type or name of the schema is in Pascal case (PascalCase).
- Reserved field names start with an underscore prefix that permits special functionality. For example:
- _fulltext – A concatenation of the values of searchable fields to support full-text search.
- _link – A special field that embeds items of a content type within another item using a common value. See joins with linking.
- _score – The relevance ranking score, which is a number that shows how similar content is given the query, resulting in a ranked list of results.
- _id – The unique internal ID used by Graph for a content item.
- _metadata – All descendants within
_metadata
are special fields used by the Optimizely CMS. - _ranking – Orders results by a relevance score, internal document ID, or other special metrics.
- _modified – A date field that indicates when the content was ingested.
- _or, _and and _not – Used for expressing Boolean logic in queries.
- Irregular reserved field names are fields that are tightly coupled with PaaS CMS (or CMS 12.0 or earlier):
- ContentType
- Status
- StartPublish
- StopPublish
- Language.Name
- RolesWithReadAccess
- UsersWithReadAccess
- _rbac
Root-level fields are in camel case (camelCase):
- items – The root level for projecting the actual results.
- total – Shows the hit count or number of matching results the query gives.
- facets – Projects the aggregated field values, including matching hit count. These values can then be used for filtering.
- autocomplete – Shows auto-complete, word completion, type-ahead, or search-as-you-type suggestions in which an application predicts the rest of a word a user is typing.
- cursor – Shows the value that can be used for pagination with a cursor.
Input arguments are names of arguments in a method that follow snake case (snake_case) convention.
- Enumerated values are fixed values in uppercase (UPPERCASE) and snake case belonging to input arguments or reserved fields:
- The reserved field
_ranking
has the values such asRELEVANCE
,DOC
,BOOST_ONLY
,SEMANTIC
. - An exception is the
locale
argument, which has different language codes likeen
,sv
,fr
, and so on.
- The reserved field
- Reserved characters are part of the GraphQL syntax and must be escaped with a single backslash for querying. These characters are double quotes (
\"
) and backslash (\\
).
The following illustration summarizes these conventions hierarchically:
Updated 3 months ago