Also if you are using revisions for your LB and blocks also have revisions you will probably have problems with jsonapi and UUIDs. Seems to me this is the problem
https://www.drupal.org/project/drupal/issues/3043321 →
which leads to this
https://www.drupal.org/project/drupal/issues/3031271
✨
Support version negotiation for any entity type (currently only Node & Media are supported)
Fixed
For me block uuids in LB json object dont match what I can fetch, when exposing them they return nothing, but I can manually find proper versions that JA can expose.
I am using patch #78 as this is last one that works with 8.8.6 but I don't see this worked on on later patches and mentioned in comments and interfdiffs. If someone can verify this has been worked on later and where, would gladly check it.
Other problem we have is that JSON:API output is not really DX friendly, simplest example would be that we get this export for simple custom block
"uuid": "365dd4c2-41ad-469a-94b3-dc426e8587d0",
"region": "content",
"configuration": {
"id": "inline_block:hero_block",
which you then need to substring to get proper endpoint which would be jsonapi/block_content/hero_block/365dd4c2-41ad-469a-94b3-dc426e8587d0. This looks more like hardcoding stuff then dynamically getting proper endpoints.
And this is simple example. I have much more complex, like having ID from commerce block
"uuid": "60bf2ad0-4fcc-4633-ba40-80b1a6829979",
"region": "second",
"configuration": {
"id": "field_block:commerce_product:toys:variations",
How to get proper url for this one :) is it even obtainable in current setup. There is some UUID but which endpoint to use here, JSON output doesnt help much?
@adam3145 sorry I didn't make it clear enough. So currently only "reusable" blocks can be fetched with JSON:API, those that dont have that option enabled have access restriction. There is this message "The current user is not allowed to GET the selected resource. Non-reusable blocks must set an access dependency for access control." that comes from getAccessCheckedResourceObject which gets access info from
web/core/modules/block_content/src/BlockContentAccessControlHandler.php and checkAccess which has this
if ($entity->isReusable() === FALSE) {
if (!$entity instanceof DependentAccessInterface) {
throw new \LogicException("Non-reusable block entities must implement \Drupal\block_content\Access\DependentAccessInterface for access control.");
}
meaning you won't be able to fetch with JSON API non-reusable blocks with current access checker in getAccessCheckedResourceObject.
As #64 wrote there are important questions this patch doesn't address. Layout builder will and should be used mostly for one time blocks and custom landing pages. So far we get config of the layout but content is non fetchable.
Works great, I can import config on new site without a problem.