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.

Comments

dpolant created an issue. See original summary.

shadcn’s picture

I can confirm this bug. Steps to reproduce:

  1. Overwrite the user--user resource and add an alias picture for the user_picture.
  2. Try including the user picture:

/jsonapi/node/article?include=uid,uid.user_picture works.
/jsonapi/node/article?include=uid,uid.picture does not work.

Thanks for the report @dpolant.

e0ipso’s picture

Issue tags: +alpha blocker

At this point this is blocking an alpha release.

vpeltot’s picture

StatusFileSize
new2.25 KB

Here a patch to fix this issue.

I added a new normalizer RelationshipItemNormalizer to override the one provided by jsonapi module.

e0ipso’s picture

Thanks @vpeltot! I think this should be fixed in the JSON API module, but this patch may be a good solution for the mean time.

e0ipso’s picture

Status: Active » Fixed

It took me a minute to remember that this was fixed in #2873820: Allow customizations. @vpeltot Can you confirm that includes work as expected?

vpeltot’s picture

Even 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

mkolar’s picture

Status: Fixed » Needs review

Hello, 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..

mkolar’s picture

Patch #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.

mkolar’s picture

Status: Needs review » Needs work
e0ipso’s picture

Project: JSON:API Extras » JSON:API
e0ipso’s picture

Status: Needs work » Needs review
StatusFileSize
new5.81 KB

Use the field resolver for nested stuff.

  • e0ipso committed eb00d4d on 8.x-1.x
    fix(Extras): Suppoert overrides for nested include properties (#2879860...
mkolar’s picture

Hello @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

e0ipso’s picture

Status: Needs review » Fixed

@mkolar, please see the patch for more details on how this was solved.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

wim leers’s picture