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
          • 60
          • 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(@) }
          All Systems Operational

          Related documentation

          • Previous page

            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