This project is not covered by Drupal’s security advisory policy.
Out-of-the-box, the JSON:API module works with the Comment module to provide HTTP resources for retrieving, updating and deleting comments in a very generic way. This module adds additional JSON:API compliant routes that enhance the developer experience of creating progressively decoupled or fully decoupled comment functionality.
Some (or all) of this module's features and enhancements may be merged into Drupal core. At that point, this module will become obsolete and deprecated.
Set up
Installation
Download it and enable it! Done.
Requirements
Drupal core 8.8.0 or above
JSON:API Hypermedia
Usage
This module provides two new route patterns. You can find and use these links via a JSON:API response's links objects. They will appear and disappear to indicate whether the user has access to view and add comments. More below.
Viewing and adding new comments
Any resource object with a comment field will now have a new link in its links
object with the link relation type https://www.drupal.org/project/jsonapi_comment/link-relations/#comments
(plural).[1] This link will not appear when comments have been hidden or when the user accessing the resource does not have permission to view comments. The resource object may also have a link with the link relation type https://www.drupal.org/project/jsonapi_comment/link-relations/#comment
(singular) to indicate that the user has permission to add a new comment. When the user does not have the permission to add a comment or comments have been closed, this link relation type will not appear.
Sorting and filtering this resource is not supported. However, sparse fieldsets and includes are supported as usual.
Unlike the REST or JSON:API modules, the entity_type
, entity_id
, field_name
fields are not required when POST
ing new comments to this route.
Editing and deleting comments
All comment resource objects will now have a link with an update
or remove
link relation type in their links
object if the user has permission to edit or delete that comment.
Replies
Any comment resource object to which a user is able to reply will now have a https://www.drupal.org/project/jsonapi_comment/link-relations/#comment
link relation type in a links
object. Sending a POST
request to the URL indicated by the link's href
will create a new comment and automatically associate it with its parent.
Unlike the REST or JSON:API modules, the pid
field is not required when POST
ing new comments to this route.[2]
Comment moderation
All comment resource objects will now have a publish
or unpublish
link in their links
object if the user has permission to administer comments. The link will have a data
member in it with the exact object that should be send as the primary data of a POST
request document to perform the publish or unpublish operation.
[1] When a resource object has more than one comment field, the link key will be something like comments--jHXy89w
where jHXy89w
is a random, meaningless hash used to differentiate multiple links with the same key.
[2] As with adding a new comment, the entity_type
, entity_id
, field_name
fields are not required for replies either.
Project information
- Seeking new maintainer
The current maintainers are looking for new people to take ownership. - Module categories: Decoupled
- Ecosystem: JSON:API
- 19 sites report using this module
- Created by gabesullice on , updated
- This project is not covered by the security advisory policy.
Use at your own risk! It may have publicly disclosed vulnerabilities.