
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeIt sounds like you're running into a common issue with perspectives and how they handle draft vs. published content! The Vision tool and your JavaScript code might be using different perspectives, which would explain why you're seeing different results.
Here's what's likely happening: As of API version 2025-02-19, the default perspective changed to published, which only returns published documents. However, Vision might be using a different perspective (like previewDrafts or raw) that includes draft content.
When you're ordering by a release number field in descending order, if some of your documents are still in draft state (with IDs prefixed by drafts.), they won't show up in your JavaScript query if you're using the published perspective.
To fix this, explicitly set the perspective in your JavaScript client:
import {createClient} from '@sanity/client'
const client = createClient({
projectId: 'your-project-id',
dataset: 'your-dataset',
useCdn: true,
apiVersion: '2025-02-19',
perspective: 'previewDrafts' // This will prioritize drafts over published
})The perspectives you can use are:
published - Only published documents (current default)previewDrafts - Shows drafts when they exist, falls back to publishedraw - Returns everything (both drafts AND published, which might give you duplicates)For your use case with ordering by release number, previewDrafts is probably what you want, as it'll show you the latest version of each document whether it's published or not.
Also double-check that:
If you're still seeing issues, try adding a filter to explicitly exclude draft IDs if you only want published content: !(_id in path("drafts.**")) in your GROQ query.
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