/jsonapi/user/user?include=roles&filter[roles.uuid][value]=e9b1de3f-9517-4c27-bef0-0301229de792
Drupal8.5.x & Drupal8.6.x
Jsonapi:1.x-dev
error:
"errors": [
{
"title": "Internal Server Error",
"status": 500,
"detail": "Getting the base fields is not supported for entity type Role.",
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | 2959445-11.patch | 2.54 KB | wim leers |
Comments
Comment #2
lawxen commentedComment #3
lawxen commentedI have find dozens of jsonapi endpoint has this problem, so set it as critical
Comment #4
lawxen commentedAbove img show the key part debug information.
Maybe we shouldn't make fieldResolver return roles.entity.uuid, go to sleep :)
Comment #5
wim leersThis does not meet the definition of critical. I agree it's a very very important bug though!
Comment #6
lawxen commentedI simplify this issue by using the following code:
The jsonapi endpoint equal to executing above code, and the same error occurs.
I'm wondering whether it's a core bug?
@Wim Leers Do you have any idea?
Comment #7
wim leersQuoting
\Drupal\Core\Entity\Query\QueryInterface::condition()'s docs:… it doesn't say this, but AFAIK the
%field.entity.%field_on_that_referenced_enittyonly works for entities that have the same storage back-end. Content entities are stored in the database by default, config entities are not. So this could never work.Comment #8
wim leersIOW: core's configuration entity system does not support this, so neither can JSON API. The entity query system in core should do better checking around this and provide a more informative exception though!
Comment #9
wim leersI was going to suggest something like
is_subclass_of($this->resourceType->getDeserializationTargetClass(), ConfigEntityInterface::class);… but that only works if you're querying a config entity type directly!Anyway, let's not wait for core to get its act together, we can improve DX today.
Comment #10
wim leersFailing test.
Comment #11
wim leersAnd fix.
Comment #12
wim leersComment #14
gabesulliceNice improvement. LGTM.
Comment #16
wim leersComment #17
e0ipso👏🏽
Comment #19
rpayanmMoving to Drupal core's issue queue.
I'm working on https://www.drupal.org/project/drupal/issues/3122113