Sanity logo

Documentation

    • Overview
    • Platform introduction
    • Next.js quickstart
    • Nuxt.js quickstart
    • Astro quickstart
    • React Router quickstart
    • Studio quickstart
    • Build with AI
    • Content Lake
    • Functions
    • APIs and SDKs
    • Agent Actions
    • Visual Editing
    • Blueprints
    • Platform management
    • Dashboard
    • Studio
    • Canvas
    • Media Library
    • App SDK
    • Content Agent
    • HTTP API
    • CLI
    • Libraries
    • Specifications
    • Changelog
    • User guides
    • Developer guides
    • Courses and certifications
    • Join the community
    • Templates
  1. Changelog
  2. Integrations & Libraries
  3. GROQ

Custom GROQ functions

Published: May 23, 2025

v2021-03-25

All GROQ APIs above v1 now support custom defined GROQ functions.

// Query
fn ex::info($person) = $person{name, age}; 
*[_type == "person"] { "info": ex::info(@) }

This allows you to create modular, reusable parts of queries.

  • Get started with custom functions.
  • View the reference documentation.
  • See the updated GROQ language spec.

Related documentation

  • GROQ Functions Reference

Loading...
Sanity logosanity.io
© Sanity 2026
Change Site Theme
Filter by product

Filter by product

Apps & Platform
  • 1
  • 18
  • 1
  • 15
  • 6
  • 7
  • 6
  • 15
  • 1
  • 4
  • 312
  • 4
Integrations & Libraries
  • 6
  • 2
  • 4
  • 2
  • 2
  • 9
  • 1
  • 1
  • 6
  • 9
  • 2
  • 1
  • 1
  • 3
Studio Plugins
  • 6
Subscribe to the changelog
  • RSS (Latest)
  • RSS (Full)
  • JSON Feed (Latest)
  • JSON Feed (Full)
// Query
fn ex::info($person) = $person{name, age}; 
*[_type == "person"] { "info": ex::info(@) }
All Systems Operational

Related documentation

  • GROQ Functions Reference

Previous Changelog

Change status field name on previews and projections.

May 23, 2025

Sanity React App SDK

Next Changelog

Saved queries for Vision, better warnings for HTTP/1, and other improvements

May 27, 2025

Sanity Studio