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.

Command icon 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

Leon Kessler created an issue. See original summary.

simonbaese’s picture

This module does not replace the JSON:API include, but rather enhances it. The documentation describes pretty much what it does:

... merge include and relationship data of JSON API [responses].

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.

leon kessler’s picture

Therein, it merges the content of the referenced entities into the respective field entries of the original entity in the output.

Think 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 in included.

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 related output content type.

Show all data makes me think that without this module, I don't get all the data.

- Use directly data of relationships to import content with Migrate.

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.

anybody’s picture

I 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...

ptmkenny made their first commit to this issue’s fork.

ptmkenny’s picture

Hi, 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.)

ptmkenny’s picture

Status: Active » Needs review
ptmkenny’s picture

Title: Document the difference between using core jsonapi includes » Document what this module actually does and what the settings mean

  • ptmkenny committed b520d4c0 on 8.x-1.x
    Issue #3271379 by ptmkenny, Leon Kessler, simonbaese, anybody: Document...
ptmkenny’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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