Sanity Library Reference Docs
    Preparing search index...

    Variable getCommentsQueryStateConst Beta

    getCommentsQueryState: (
        instance: SanityInstance,
        options: CommentsQueryOptions,
    ) => StateSource<Comment[] | undefined> = ...

    Comments matching a GROQ filter, newest first, replies included.

    undefined until the first snapshot arrives.

    The filter runs over every comment the organization can read, not only the ones on the resource you pass. Comment queries are routed by organization and the resource is not sent with them, so it chooses the organization and the client but does not narrow the results. To keep to one dataset, add a target.document._ref prefix condition yourself: refs are dataset:{projectId}.{dataset}:{documentId}.

    Type declaration

    getCommentsQueryState(instance, {
    ...resource,
    filter: 'string::startsWith(target.document._ref, $prefix) && status == "open"',
    params: {prefix: 'dataset:abc123.production:'},
    })