comments icon indicating copy to clipboard operation
comments copied to clipboard

GraphQL - get comments that user is subscribed to

Open bzin opened this issue 2 years ago • 2 comments

Question

I was trying to fetch if the user was already subscribed to a comment or an element that contains comments, although this does not seems possible with the below query:

{
    comments(
        ownerId: XXX
        relatedToUsers: [{id: XXX}]
    ) {
        id
        title
    }
}

Would you know if this is possible or do we need to get into a custom module route?

Additional context

No response

bzin avatar Feb 27 '23 16:02 bzin

At the moment, there's no way to query this through GraphQL, sorry. This only exists in service methods like:

\verbb\comments\Comments::$plugin->getSubscribe()->hasSubscribed($elementId, $elementSiteId, $userId, $commentId);

Or via Twig

{{ craft.comments.isSubscribed(element, comment) }}

engram-design avatar Feb 28 '23 02:02 engram-design

Thanks for the suggestions and thinking along @engram-design .

Indeed I was already aware that some custom logic would need to be made for this, but wanted to check here if there would be a way within the Comments GraphQL queries.

Any future idea to put this in the GraphQL? Asking because you do already have the service and functionality in twig.

bzin avatar Feb 28 '23 08:02 bzin