I was initially quite confused about the purpose of this module. Why would you use it rather than using core JSON:API includes?
The main benefit I can see using this module is simpler/shorter urls, as you don't need to specify the relationship you want to include.
Are there any other benefits?
It would be great to have a summary on the module homepage. As I think it can be confusing to users, they would assume that this module is providing functionality that isn't already part of Drupal core, when this isn't really the case.
I also see disadvantages to using this module. You are deviating away from Drupal core JSON:API functionality, and possibly away from the JSON:API spec. Also there could be performance issues with bringing in lots of relationship data. Would be useful to let new users know about these also.
Issue fork jsonapi_include-3271379
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
simonbaeseThis module does not replace the JSON:API include, but rather enhances it. The documentation describes pretty much what it does:
Describing the functionality roughly:
If you request an entity with included relationships through the JSON:API, the output will be an json array with entries of the entity and the contents of the referenced entities. This module adds an additional step before the response is delivered (see
JsonapiParse
). Therein, it merges the content of the referenced entities into the respective field entries of the original entity in the output.Comment #3
leon kessler CreditAttribution: leon kessler commentedThink this is the key bit for me. So the benefit is that your data is put into one place, meaning the consumer doesn't need to connect field names from
attributes
to data inincluded
.Btw, this is what the https://github.com/olosegres/jsona library also does, although this is a JS implementation.
I think it would still be useful to say that this module is for simplifying the output, rather than adding adding anything additional to it.
These two lines are particuarly confusing:
Show all data makes me think that without this module, I don't get all the data.
I can see how this can help with migrate, but this suggests it's more directly related to the migrate module than it actually is.
Comment #4
anybodyI agree this should be explained better. Also see #3437883: Document that the ?include parameter is needed for this to work additionally.
Currently the onboarding using the JSON:API Extras and this module is really hard and a lot of try & error...
Comment #7
ptmkenny CreditAttribution: ptmkenny commentedHi, I'm now co-maintaining this module. Although what the module does is pretty simple, it is quite confusing for a lot of people, so I rewrote the README. Please let me know what you think (I may commit this soon, but I'm happy to update it even after the commit.)
Comment #8
ptmkenny CreditAttribution: ptmkenny commentedComment #9
ptmkenny CreditAttribution: ptmkenny commentedComment #11
ptmkenny CreditAttribution: ptmkenny commented