Sanity Library Reference Docs
    Preparing search index...

    Interface ObservableCollaborationCommentsClientAlpha

    Comments on the configured organization resource.

    Requires collaboration.organizationId, plus either resource or projectId and dataset.

    interface ObservableCollaborationCommentsClient {
        addReaction(
            id: string,
            shortName: CollaborationCommentReactionShortName,
            options?: CollaborationCommentsWriteOptions,
        ): Observable<CollaborationCommentDocument>;
        create(
            body: CollaborationCommentCreate,
            options?: CollaborationCommentsWriteOptions,
        ): Observable<CollaborationCommentDocument>;
        delete(
            id: string,
            options?: CollaborationCommentsWriteOptions,
        ): Observable<MultipleMutationResult>;
        fetch<R = unknown>(
            query: string,
            params?: QueryParams,
            options?: CollaborationCommentsRequestOptions,
        ): Observable<R>;
        getTargetDocumentRef(documentId: string): `${string}:${string}:${string}`;
        listen(
            query: string,
            params?: QueryParams,
        ): Observable<MutationEvent<CollaborationCommentDocument>>;
        listen<Opts extends CollaborationCommentsListenOptions>(
            query: string,
            params: QueryParams | undefined,
            options: Opts,
        ): Observable<ListenEventFromOptions<CollaborationCommentDocument, Opts>>;
        removeReaction(
            id: string,
            shortName: CollaborationCommentReactionShortName,
            options?: CollaborationCommentsWriteOptions,
        ): Observable<CollaborationCommentDocument>;
        update(
            id: string,
            body: CollaborationCommentUpdate,
            options?: CollaborationCommentsWriteOptions,
        ): Observable<CollaborationCommentDocument>;
    }
    Index

    Methods

    • Alpha

      Fetch comments on the configured resource.

      Takes the same query and params as client.fetch, and switches from a GET to a POST for queries too large for the request URL in the same way, but queries the comments endpoint, which accepts none of the query options client.fetch does (perspective, useCdn, filterResponse, resultSourceMap, stega).

      The query runs against the organization store, which is not scoped to comments, so filter on _type == "sanity.comment".

      Type Parameters

      • R = unknown

      Parameters

      Returns Observable<R>

    • Alpha

      Build the global document reference used by target.document._ref, for use in queries and listeners.

      The reference is built from the configured resource and the published ID of the given document ID, since comment references always use published IDs.

      Parameters

      • documentId: string

        Document ID, in published, draft or version form

      Returns `${string}:${string}:${string}`

      Global document reference, of the form resourceType:resourceId:documentId

      client.collaboration.comments.listen(
      '*[_type == "sanity.comment" && target.document._ref == $ref]',
      {ref: client.collaboration.comments.getTargetDocumentRef('doc-1')},
      )