Hi guys,

The filter is not working on the latest jsonapi (https://www.drupal.org/project/jsonapi/releases/8.x-2.0).

I run couple test as below.

Drupal Test 1
- drupal 8.6.5
- eck 1.0-alpha5
- jsonapi 2.0
- jsonextra 3.2

Drupal Test 2
- drupal 8.6.5
- eck 1.0-alpha5
- jsonapi rc-3
- jsonextra 3.2

and I create, below entity for all of them.
ECK entity type:
- test_entity

bundle of test_entity,
- bundle_test_entity

field
- field_name => text (plain)

and I added couple contents.
- test 1
- test 2

and run this url from postman,
/jsonapi/test_entity/bundle_test_entity?filter[field_name]=test 2

The Drupal Test 1 is failed to show the result.
But using Drupal Test 2, it works fine.

I am not sure if I should add this issue to jsonapi or here,
BUT since all version of json api is working for drupal node entity,
so it maybe ECK is having an issue defining its entity.

EDIT: after another research, I think this is related to this update.
https://www.drupal.org/sa-contrib-2018-081
I can confirm adding hook_jsonapi_ENTITY_TYPE_filter_access() fix the issue.

so what would be the best approach to implement this to ECK?
should we create a new custom module on our own to implement the new hooks?
or it will be available in ECK module?

Cheers,
Awang

Comments

awangsetyawan created an issue. See original summary.

awset’s picture

Issue summary: View changes
awset’s picture

Issue summary: View changes
gerzenstl’s picture

On my case, I have same issue but with jsonapi 8.x-1.*

@awangsetyawan you're right, I was able to reproduce the issue and seems to be related to https://www.drupal.org/sa-contrib-2018-081.

I'm using:
Drupal: 8.6.9
eck: 1.0-alpha5
jsonapi: 1.24
jsonapi_extras: 2.15

I prepared a patch that should support any entity created through eck module. I tested the patch with eck 1.0-alpha5 and dev branch of the module and fixed the issue.

gerzenstl’s picture

Status: Active » Needs review
ipumpkin’s picture

StatusFileSize
new1.11 KB

use $entity_type->getProvider() == 'eck'

Status: Needs review » Needs work

The last submitted patch, 6: eck_jsonapi_access_fix-3025975-6.patch, failed testing. View results

ipumpkin’s picture

StatusFileSize
new1.08 KB
romixua’s picture

Assigned: Unassigned » romixua
Issue tags: +epam-contrib-2019.03
romixua’s picture

Assigned: romixua » Unassigned
Status: Needs work » Needs review
StatusFileSize
new1.37 KB

Created new patch based on @ipumpkin patch (#8)

johnnydarkko’s picture

Version: 8.x-1.0-alpha5 » 8.x-1.x-dev
StatusFileSize
new1.37 KB
new646 bytes

I tried the patch in #10, but I'm getting a fatal error:

The website encountered an unexpected error. Please try again later.<br /><em class="placeholder">TypeError</em>:
Argument 1 passed to eck_jsonapi_entity_filter_access() must be an instance of EntityTypeInterface, instance of
Drupal\Core\Entity\ContentEntityType given in <em class="placeholder">eck_jsonapi_entity_filter_access()</em> (line
<em class="placeholder">328</em> of <em class="placeholder">modules/contrib/eck/eck.module</em>).

I found that if I change
function eck_jsonapi_entity_filter_access(EntityTypeInterface $entity_type, AccountInterface $account) {
to
function eck_jsonapi_entity_filter_access(ContentEntityType $entity_type, AccountInterface $account) {
jsonapi eck filtering works now!

legolasbo’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me. Will commit this. Thanks!

  • legolasbo committed 9b00c26 on 8.x-1.x authored by johnnydarkko
    Issue #3025975 by ipumpkin, johnnydarkko, Romixua, gerzenstl, legolasbo...
legolasbo’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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