For AI agents: append .md to this page's URL for a markdown version. The complete documentation index is available at https://www.sanity.io/docs/llms.txt.

Sanity logo

Documentation

          • Next.js
          • Astro
          • APIs and SDKs
          • HTTP API
          • CLI
          • Libraries
          • Specifications
          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
          • 2
          • 19
          • 5
          • 15
          • 6
          • 9
          • 15
          • 33
          • 1
          • 10
          • 363
          • 5
          Integrations & Libraries
          • 1
          • 6
          • 2
          • 4
          • 2
          • 2
          • 10
          • 61
          • 1
          • 1
          • 10
          • 7
          • 27
          • 3
          • 1
          • 2
          • 4
          Studio Plugins
          • 1
          • 7
          • 1
          • 1
          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(@) }
          Partially Degraded Service

          Related documentation

          • GROQ functions reference

          Previous Changelog

          Stabilization of the array::intersects() function for GROQ

          November 11, 2024

          GROQ

          Next Changelog

          New GROQ functions to interact with Global Document References (GDR)

          October 30, 2025

          GROQ