1. GraphQL APIs

Differences between the Preview and the Delivery GraphQL APIs

Although the Preview GraphQL API and the Delivery GraphQL API use the same authorization methods and share the same query and response shape, some differences exist between the two APIs. This topic describes the differences between the two APIs.

Query complexity

Query complexity is calculated differently between the APIs. In practice, a query that runs on the Preview GraphQL API endpoint should also run on the Delivery endpoint, but you should test both endpoints if the query is large or deeply nested.

Schema and field differences

Due to differences in the fields available between unpublished and published content, we recommend you use the fields described in the Experience Edge schema documentation when querying published content available in Experience Edge. In addition, for any fields you might have added, make the fields from the standard template publishable.

Note the following schema differences:

  • Field availability can differ:
    • Preview - can expose fields not available in published content.
    • Delivery - only exposes fields documented in the Experience Edge schema plus any standard-template fields you explicitly publish.
  • The _latestversion search field behaves differently:
    • Preview - the field returns the latest available version and allows false to return all versions.
    • Delivery - the field returns the latest publishable version and only accepts true.

Schema extension

The Preview GraphQL API schema mirrors the schema of the Delivery GraphQL API. The Preview GraphQL API schema is not extensible because it must remain compatible with Experience Edge.

Caching and rate limiting

  • Preview - the content served via the Preview GraphQL API is not cached, so it is not expected to be fast under repeated load. Avoid heavy load because it can affect overall SitecoreAI instance performance.
  • Delivery - the content served via the Delivery GraphQL API is cached, so identical queries should perform faster. The API is rate limited to 80 requests per second.

Links can differ because Preview resolves links in the authoring context (including site virtual folders and preview hostnames), while Delivery resolves links in the published context (canonical public routes).

  • Preview - use the Private Link field of the XMC Hybrid Media item.

    XM Cloud is now SitecoreAI

    Some code examples, images, and UI labels may still use XM Cloud while engineering assets are being updated.

  • Delivery - use the Public Link field.

Consider a GraphQL query that reads a specific LinkField from an item and returns the resolved link URL:

graphql
query GetLinkItemField($path: String, $language: String!, $name: String!) {
  item(path: $path, language: $language) {
    field(name: $name) {
      ... on LinkField {
        id
        value
        url
      }
    }
  }
}

Compare how the link URL is resolved in Preview and in Delivery:

  • Preview - the link can include a virtual folder segment:

    json
    "url": "/da/<VIRTUAL_FOLDER>/ItemWithLinkFields/TestLinkFolder/TestItem?TestQueryStringDa#AnchorDa"
  • Delivery - the link uses the published route path without the virtual folder segment:

    json
    "url": "/da/ItemWithLinkFields/TestLinkFolder/TestItem?TestQueryStringDa#AnchorDa"

Item URLs

Consider a GraphQL query that reads the Item.url object for an item:

graphql
query GetItemUrl($path: String, $language: String!) {
  item(path: $path, language: $language) {
    id
    url {
      url
      path
    }
  }
}

Compare how url and path are resolved in Preview and in Delivery:

  • Preview - the URL and path reflect the authoring host and virtual folder:

    json
    "url": "https://<ENVIRONMENT_HOST_NAME>/da/<VIRTUAL_FOLDER>/ItemWithLinkFields/TestLinkFolder/TestItem",
    "path": "/da/<VIRTUAL_FOLDER>/ItemWithLinkFields/TestLinkFolder/TestItem"
  • Delivery - the URL and path reflect the published site host and route:

    json
    "url": "https://<PUBLISHED_HOST>/da/ItemWithLinkFields/TestLinkFolder/TestItem",
    "path": "/da/ItemWithLinkFields/TestLinkFolder/TestItem"
If you have suggestions for improving this article, let us know!