Here is an example:
We have a few entities connected by entity reference fields as follows:
Page config > Layout > Framework
We're developing an "aggregate" of the Page config entity using JSON API includes, and one of the things we want is the Framework resource. The entity reference field on the Layout entity connecting it to Framework is called "field_framework," and we have overridden it via JSON API Extras to be simply "framework."
I was able to achieve this goal with the following GET request:
http://localhost.dev/jsonapi/config/page_config?include=layout,layout.fi...
However, this does not work (using the JSON API Extras override for the framework field):
http://localhost.dev/jsonapi/config/page_config?include=layout,layout.fr...
My guess is we need to do an additional substitution at the point where included field names are being resolved.
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | 2879860--overridden-nested-includes--12.patch | 5.81 KB | e0ipso |
| #4 | json_api_extras-2879860-4.patch | 2.25 KB | vpeltot |
Comments
Comment #2
shadcn commentedI can confirm this bug. Steps to reproduce:
user--userresource and add an aliaspicturefor theuser_picture./jsonapi/node/article?include=uid,uid.user_pictureworks./jsonapi/node/article?include=uid,uid.picturedoes not work.Thanks for the report @dpolant.
Comment #3
e0ipsoAt this point this is blocking an alpha release.
Comment #4
vpeltot commentedHere a patch to fix this issue.
I added a new normalizer
RelationshipItemNormalizerto override the one provided by jsonapi module.Comment #5
e0ipsoThanks @vpeltot! I think this should be fixed in the JSON API module, but this patch may be a good solution for the mean time.
Comment #6
e0ipsoIt took me a minute to remember that this was fixed in #2873820: Allow customizations. @vpeltot Can you confirm that includes work as expected?
Comment #7
vpeltot commentedEven with this issue #2873820: Allow customizations closed, it does not work without this patch (#4).
I tried to search why, but I got lost in the labyrinth of normalizer (Inception! ;-) ), and I'm sorry, unfortunately I don't have much time at the moment
Comment #8
mkolar commentedHello, I can confirm that this bug is still here. I have paragraphs in my node type and i had to rename include from "paragraphs.image" (expected, because i overwrite field_image into image) into "paragraphs.field_image" to get it work..
Comment #9
mkolar commentedPatch #4 works partially, looks like it works only on first level, for example i have: "paragraphs.image.file" it doesnt work... "file" is not recognized... "paragraphs.image" works.
Comment #10
mkolar commentedComment #11
e0ipsoComment #12
e0ipsoUse the field resolver for nested stuff.
Comment #14
mkolar commentedHello @e0ipso, what do you mean by field resolver? Can you tell me little bit more please? Did you mean field enhancer in JSON API extras? Thanks
Comment #15
e0ipso@mkolar, please see the patch for more details on how this was solved.
Comment #17
wim leers