It seems like after some changes were done in more recent version of JSON API, this module no longer works. I've managed to trace it down to the refactoring of QueryBuilder in JSON API (commit) where \Drupal\jsonapi\Context\CurrentContext::getJsonApiParameter() is no longer used.

Comments

vtcore created an issue. See original summary.

mkolar’s picture

hello @vtcore thanks for the report but it looks like its bug of latest jsonapi, still investigating.. plase try to disable module and use ?include= manually without using this module.. i've disabled service overrides JsonapiDefaultsServiceProvider here and tried my list of nodes without any argument (like api/content) and it works, when i try to get list of nodes with include to taxonomy term (like api/content?include=keywords) it fails on "Error: Call to a member function isInternal() on null in /var/www/html/docroot/modules/contrib/jsonapi/src/Normalizer/Value/RelationshipNormalizerValue.php on line 120"...when you try to use different include (to different entity) it works (like api/content?include=uid). Can you please confirm?

mkolar’s picture

Status: Active » Closed (works as designed)

This is an issue of JSONAPI Extras

vtcore’s picture

Hey, thanks for the response.

Unfortunately I cannot reproduce the error you posted and I was more interested in using default filters. My point for getJsonApiParameter() that is overriden in \Drupal\jsonapi_defaults\JsonApiDefaultsCurrentContext is that it's not called anywhere in jsonapi except in tests. Previously it was used in \Drupal\jsonapi\Query\QueryBuilder which was deleted in the commit that I mentioned. This is the reason that default filters are currently broken.

I think \Drupal\jsonapi\Routing\JsonApiParamEnhancer::enhance() can be overriden to inject default params in the request.

FYI, these are the module versions that I'm currently using:

  • jsonapi-8.x-1.10
  • jsonapi_extras-8.x-1.x-dev (26e1962)
  • jsonapi_defaults-8.x-1.x-dev (2ffc48e)
mkolar’s picture

EDIT: OK I get it.. i was too focused to includes, looks like filters are not applied any more. I'll look into it, thanks

Can you explain what exactly is broken? what error do you get? because for me its working
I have

drupal/jsonapi 8.x-1.10
drupal/jsonapi_extras 26e1962d91c4730e8a68b78ac15e0184a004ae8b
drupal/jsonapi_defaults 2ffc48e90aa7fdc0f70811b84b2300510af958c1

drupal/jsonapi_extras patched with
https://www.drupal.org/files/issues/2946969--isInternal-on-null--8.patch

mkolar’s picture

Status: Closed (works as designed) » Needs work
mkolar’s picture

Assigned: Unassigned » mkolar
mkolar’s picture

StatusFileSize
new5.29 KB

Hello @vtcore can you check if this helps?

mkolar’s picture

StatusFileSize
new4.34 KB
mkolar’s picture

Status: Needs work » Needs review
vtcore’s picture

Works great, although I had to remove the version requirement in order to enable the module:
jsonapi:jsonapi (>=8.x-1.10)
I got the following error
Module jsonapi_defaults cannot be enabled because it depends on jsonapi (>=8.x-1.10) but is available
but then found out that's because jsonapi doesn't have a version in their jsonapi.info.yml (???)

Thanks for the support!

  • mkolar authored 8d300ce on 8.x-1.x
    Issue #2946892 by mkolar, vtcore: Not compatible with JSON API 8.x-1.4+
    
mkolar’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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