UNPKG

groq-builder

Version:

A **schema-aware**, strongly-typed GROQ query builder. It enables you to build GROQ queries using **auto-completion**, **type-checking**, and **runtime validation**.

35 lines (34 loc) 1.21 kB
import { Override } from "../types/utils"; import { Simplify } from "type-fest"; declare module "../groq-builder" { interface GroqBuilder<TResult, TQueryConfig> { /** * Defines the names and types of parameters that * must be passed to the query. * * This method is just for defining types; * it has no runtime effects. * * The parameter types should not include the `$` prefix. * * @example * const productsBySlug = ( * q.parameters<{ slug: string }>() * .star * .filterByType('product') * // You can now reference the $slug parameter: * .filterBy('slug.current == $slug') * ); * const results = await executeQuery( * productsBySlug, * // The 'slug' parameter is required: * { parameters: { slug: "123" } } * ) */ parameters<TParameters>(): GroqBuilder<TResult, Override<TQueryConfig, { parameters: Simplify<TQueryConfig["parameters"] & TParameters>; }>>; /** @deprecated Use `parameters` to define parameters */ variables: never; } }