
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeTo query all documents of a specific type in GROQ, you can use a simple filter pattern. Here's the basic syntax:
*[_type == "yourTypeName"]The * returns all documents, and the filter [_type == "yourTypeName"] keeps only documents where the _type field matches your specified type.
For example, to get all blog posts:
*[_type == "post"]To get all authors:
*[_type == "author"]You can also add projections to shape the returned data:
*[_type == "post"]{
_id,
title,
publishedAt,
author->
}This follows the fundamental GROQ query pattern of *[<filter>]{<projection>}, where:
* fetches all documents you have permission to read[] keeps only matching documents{} shapes what fields are returnedIf you want to retrieve all documents regardless of type, you can simply use:
*Or with a projection to see their types:
*{_type, _id, title}You can test these queries using the Vision plugin in your Sanity Studio, which provides a visual interface for experimenting with GROQ queries and seeing results in real-time.
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