
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeThis is indeed a known issue with Gatsby and gatsby-source-sanity when working with Portable Text! The problem occurs because of a field name conflict between Gatsby's internal GraphQL schema and Sanity's Portable Text structure.
Portable Text blocks in Sanity have a children field that contains the actual text content (spans, marks, etc.). However, Gatsby reserves the children field name for its own internal node relationships in GraphQL. When gatsby-source-sanity tries to map Sanity's Portable Text structure to Gatsby's GraphQL layer, this conflict causes the children field to appear empty in Gatsby's GraphQL (GraphiQL), even though the data exists perfectly fine in Sanity's Vision/Playground.
_rawFieldsThe gatsby-source-sanity plugin generates special _raw prefixed fields specifically to handle this and other similar issues. These fields provide the raw JSON data from Sanity without Gatsby's GraphQL transformations interfering.
Instead of querying your Portable Text like this:
query {
sanityPost {
body {
children {
text
}
}
}
}Query it using the _raw version:
query {
sanityPost {
_rawBody
}
}The _rawBody field (or _rawYourFieldName for whatever your Portable Text field is called) will contain the complete, unmodified Portable Text structure with all the children arrays intact.
Once you have the raw data, you'll need to use a Portable Text renderer like @portabletext/react to display it:
import {PortableText} from '@portabletext/react'
function MyComponent({data}) {
return <PortableText value={data.sanityPost._rawBody} />
}You can also configure reference resolution depth in your GraphQL query if your Portable Text contains references:
query {
sanityPost {
_rawBody(resolveReferences: {maxDepth: 5})
}
}This is a documented feature of gatsby-source-sanity - the _raw fields are specifically designed to bypass Gatsby's GraphQL transformations and give you direct access to Sanity's data structure, which is essential for Portable Text and other complex nested content.
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store