_json field
The _json field in Optimizely Graph provides the complete raw content payload for a content item, including nested structures, in a single GraphQL query.
The _json field returns the complete raw content payload for a content item in a single Optimizely Graph GraphQL query, so clients can render any content type without listing every field by hand. Use this field for dynamic presentation layers, content-as-a-service integrations, and previews where the full object matters more than a specific schema.
Prerequisites
The _json field is locked behind a feature flag and requires an API key with read access to the target content. Confirm the following before running the example queries:
- The
_jsonfield displays in your GraphQL schema. If it does not, contact your system administrator to enable the feature flag. - The API key used for the query has read permission on the affected content types and properties.
What the _json field provides
_json field providesThe _json field returns the full serialized content item, which is the highest-fidelity response Optimizely Graph offers in a single field. Use it when the calling layer cannot enumerate fields ahead of time.
When you request _json, Optimizely Graph returns the entire serialized content item as a JSON object.
The _json output includes the following:
- All content properties and values.
- Nested data (content areas, blocks, media, and references).
- Standard metadata fields such as
Name,Key,Language, andContentLink.
Retrieve a complete content item
query GetStartPage {
StartPage {
item {
Name
_json
}
}
}Response (simplified):
{
"data": {
"StartPage": {
"item": {
"Name": "Home Page",
"_json": {
"Name": "Home Page",
"Heading": "Welcome",
"MainBody": "Welcome to our website",
"Created": "2023-01-01T00:00:00Z",
"Status": "Published",
"Language": {
"DisplayName": "English",
"Name": "en"
},
"ContentLink": {
"Id": 1,
"GuidValue": "11111111-1111-1111-1111-111111111111",
"Url": "/home"
},
"__typename": "StartPage"
}
}
}
}
}Combine _json with specific fields when you need both structured values and the full object.
Supported use cases
The following sections describe the placements where _json returns a useful payload. Pick the placement that matches the query shape you already use.
Use _json in the following locations.
Use _json on the item field
_json on the item fieldThe item placement is the most common pattern and returns the full payload for a single content item. Use _json inside an item query to return the full content item.
query GetStartPage {
StartPage {
item {
Name
_json # Returns the complete content item
}
}
}Use _json inside expanded references
_json inside expanded referencesThe Expanded placement returns fully resolved block or nested content data, which is useful for content areas that mix multiple block types. Use _json inside Expanded to return fully resolved block or nested content data.
query GetPageWithBlocks {
StartPage {
item {
Name
MainContentArea {
Tag
ContentLink {
Expanded {
Name
_json # Full nested block data
}
}
}
}
}
}Use _json with filters, sorting, or search
_json with filters, sorting, or searchThe _json field works inside item selections that also use the standard query primitives, which avoids the need to choose between filtering and full payloads. Use _json inside item even when the query includes filters, sorting, or facets.
query FilteredContent {
Content(
where: { Name: { contains: "product" } }
orderBy: { _score: DESC }
limit: 5
) {
items {
item {
Name
_json # Full item data
}
}
}
}Unsupported use cases
The _json field has one placement restriction that prevents oversized collection responses. Knowing this restriction up front avoids a class of schema errors during query design.
Optimizely Graph does not support the _json field directly under items in collection queries because returning the full payload for every list entry produces oversized responses and can degrade query performance.
# Not supported
query Invalid {
Content {
items {
_json # This causes an error
}
}
}To retrieve full data for each item, use item { _json }:
# Supported alternative
query GetAllContent {
Content {
items {
item {
_json
}
}
}
}Advanced use cases of _json
_jsonThe advanced patterns extend the supported placements with two common product scenarios: a dynamic renderer that handles any content type, and a nested-block query that returns full block data alongside the parent page.
Dynamic content rendering
A dynamic renderer reads the content type from the payload and selects a component at runtime, which removes the need to redeploy when editors add a new type. Use _json to build presentation layers that adapt to any content structure.
query GetContent {
Content {
item {
Name
ContentType
_json # Retrieve all fields for dynamic rendering
}
}
}Retrieve nested content
The nested-content pattern combines an _json selection on the parent page with another _json inside Expanded to return both the page payload and every block payload in one query. Use _json inside expanded references to return complete block content.
query GetPageWithBlocks {
StartPage {
item {
Name
MainContentArea {
Tag
ContentLink {
Expanded {
Name
_json # Full details for each block in the content area
}
}
}
_json
}
}
}Performance considerations
The performance profile of _json differs from field-by-field queries because the response can be significantly larger. Apply the following guidelines to keep request latency and payload size predictable.
The _json field returns more data than typical field-based queries. To optimize performance, follow these guidelines:
- Use
_jsononly when you need most or all fields for a content item. - Avoid using
_jsonin large list queries (not supported on items). - Combine
item { specificField _json }if you need both explicit fields and the full payload.
Security and data protection
The security model for _json follows the standard API key permissions and excludes sensitive system metadata, so callers cannot escalate privileges through full-payload queries.
The _json field only returns data your API key has permission to access. Optimizely Graph excludes the following sensitive system metadata from every _json response:
- User permissions.
- Role assignments.
- Internal security attributes.
Updated about 23 hours ago
