Problem/Motivation
Impossible to include the paragraphs for the preview.
Steps to reproduce
Install the paragraph module.
Configure a node with paragraphs.
Create a content with paragraphs, then click on "preview".
Access the preview endpoint on the JSON API.
Comments
Comment #2
elendev commentedI've found the issue: it's an access check linked to the fact that the permission `view all revisions` is only applied to node and media.
Line 198 - 199 of EntityAccessChecker.php: https://api.drupal.org/api/drupal/core%21modules%21jsonapi%21src%21Acces...
Bypassing this permission fixes this issue.
To bypass this permission, one can create a custom module and extend the EntityAccessChecker of JSONAPI:
And register it as a decorator service in my_module.services.yml:
Comment #3
albertosilvaHi @elendev:
I think you are trying to get a node preview from a non-default revision, passing also an
includeparameter to get that Paragraph. Using a non-default revision makes JSON:API callcheckRevisionViewAccess()with that Paragraph entity as an argument, making JSON:API throw an error.Using a node's default revision works as expected.
From my point of view, this is a problem/bug with JSON:API, where using a non-default revision for an entity enforces having to use that revision for all other included entities, even though they are not revisionable.
Thanks for sharing a solution for this problem, but there is nothing I can do as a module maintainer to fix it, since it is outside of the scope of JSON:API Node Preview.
Thanks!
Comment #4
albertosilva