Sanity Library Reference Docs
    Preparing search index...

    What a GROQ expression reads off its root document: the candidate a start.filter binds, not an item inside a rebound scope (filters, map).

    interface RootDocumentReads {
        paths: string[];
        readsOtherDocuments: boolean;
        readsWholeDocument: boolean;
    }
    Index

    Properties

    paths: string[]

    The attribute paths read, dot-joined, deduped and ascending. Element and array access end a path, so tags[0] reads tags and authors[].year reads authors, and a dereference ends it at the reference, so author->name reads author.

    Every segment of a path is a bare GROQ attribute name, so the path can be written back as GROQ and read the same attributes. A read through an attribute name that needs quoting has no path: @["a.b"] reads the whole document rather than a then b, and tags["a.b"] reads tags.

    readsOtherDocuments: boolean

    Whether the expression resolves against a document other than the one in scope: a dataset scan (*[…]) or a dereference (->), at any depth. Its value can then change with no write to the root document at all.

    readsWholeDocument: boolean

    true when the expression reads the root document in a way no RootDocumentReads.paths entry describes. Any write to the document may then change what it evaluates to. The cases are:

    • the whole document, through @ or a ^ that escapes past the outermost scope;
    • an attribute of the document itself named by an expression, or whose name needs quoting: @["a.b"]. Below a bare prefix it is a path instead, so tags["a.b"] reads tags;
    • a function handed the scope implicitly: references(), sanity::versionOf(), sanity::partOfRelease().