Querying a schema returns an empty array after breaking website into multiple pages.
This is almost certainly caused by the recent API version 2025-02-19 breaking change where the default perspective switched from raw to published.
When you query Sanity, you're now getting only published documents by default, but the two items you see in Studio are likely still in draft state (unpublished). In Studio, you see both drafts and published documents, which is why they appear there but not in your query results.
Here's how to fix it:
Option 1: Set perspective to previewDrafts (recommended for development)
If you're using a Sanity client, add the perspective parameter:
import { createClient } from '@sanity/client'
const client = createClient({
projectId: 'your-project-id',
dataset: 'your-dataset',
useCdn: false, // set to false when using previewDrafts
apiVersion: '2025-02-19',
perspective: 'previewDrafts' // This will return published docs or drafts if no published version exists
})Option 2: Set perspective to raw
If you want the old behavior (all documents including both drafts and published):
const client = createClient({
// ... other config
perspective: 'raw'
})Option 3: Publish your documents
In Sanity Studio, click the "Publish" button on your two documents. Once published, they'll appear in queries using the default published perspective.
The API version 2025-02-19 introduced this breaking change because Sanity added Content Releases, and most production sites should only query published content by default.
For development/preview environments, use perspective: 'previewDrafts'. For production, use the default published perspective and make sure your content is published in Studio.
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.