verbb / comments

A Craft CMS plugin for managing comments directly within the CMS.
Other
137 stars 33 forks source link

GraphQL - get comments that user is subscribed to #279

Open bzin opened 1 year ago

bzin commented 1 year ago

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

engram-design commented 1 year ago

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) }}
bzin commented 1 year ago

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.