Sanity Library Reference Docs
    Preparing search index...
    type QueryHelpers = {
        query: <T = unknown>(
            groq: string,
            params?: Record<string, unknown>,
        ) => Promise<T>;
        queryInScope: <T = unknown>(
            { instanceId, groq, params, }: {
                groq: string;
                instanceId: string;
                params?: Record<string, unknown>;
            },
        ) => Promise<T>;
    }
    Index

    Properties

    Properties

    query: <T = unknown>(
        groq: string,
        params?: Record<string, unknown>,
    ) => Promise<T>

    Run an arbitrary GROQ query through workflow.query. The query MUST filter on the auto-injected $tag param (e.g. *[... && tag == $tag]) or it throws — the engine refuses to run a query that could read across partitions. Caller is responsible for narrowing the result.

    queryInScope: <T = unknown>(
        { instanceId, groq, params, }: {
            groq: string;
            instanceId: string;
            params?: Record<string, unknown>;
        },
    ) => Promise<T>

    Snapshot-aware GROQ for instanceId — runs against the same in-memory view the engine's filters see, with the caller-free rendered scope auto-bound: every always-bound condition var, $fields with the open stage's overlay merged, $assigned at its caller-free false, and the author's pre-evaluated $<predicate> booleans, ids in GDR URI form. Use to ask "what does the engine see for this workflow?" — useful for filter debugging, UIs that mirror engine state, etc.