GraphQL Query and Gatsby - Populating Author Bio Raw Text
Based on your error and the context, the issue is that bio is a Portable Text field (type [SanityBlock]), which requires you to query its subfields in GraphQL. However, what you actually want is the _rawBio field that's specific to gatsby-source-sanity.
The _raw fields (like _rawBio, _rawBody, _rawExcerpt) are special fields generated by gatsby-source-sanity that aren't available in Sanity's standard GraphQL playground. This is why you're having trouble finding documentation about them in the regular Sanity docs - they're Gatsby-specific!
Here's how to fix your query:
query BlogPostTemplateQuery($id: String!) {
post: sanityPost(id: { eq: $id }) {
id
publishedAt
categories {
_id
title
}
mainImage {
...SanityImage
alt
}
title
slug {
current
}
_rawExcerpt(resolveReferences: { maxDepth: 5 })
_rawBody(resolveReferences: { maxDepth: 5 })
authors {
_key
author {
image {
crop {
_key
_type
top
bottom
left
right
}
hotspot {
_key
_type
x
y
height
width
}
asset {
_id
}
}
name
_rawBio(resolveReferences: { maxDepth: 5 })
}
}
}
}The key change is replacing bio with _rawBio(resolveReferences: { maxDepth: 5 }). This will give you the raw Portable Text content as an array of block objects, just like your _rawExcerpt and _rawBody fields.
The resolveReferences parameter is important if your bio content contains references to other documents - it tells Gatsby how deeply to resolve those nested references. This matches the pattern you're already using successfully for _rawExcerpt and _rawBody.
Sanity – Build the way you think, not the way your CMS thinks
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.