HomeDev guideAPI ReferenceGraphQL
Dev guideUser GuideGitHubNuGetDev CommunitySubmit a ticketLog In
GitHubNuGetDev CommunitySubmit a ticket

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. The schema 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.

2549

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 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. 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 are field names starting with an underscore prefix that permits special functionality:
    • _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.
    • _rankingOrders 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.
  • Root-level fields are fields 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 values of a field, including matching hit count. These values can then be used for filtering.
    • 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 as RELEVANCE and DOC.
    • An exception is the locale argument, which has different language codes like en, sv, fr, and so on.
  • 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: