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
Comment #2
awset commentedComment #3
awset commentedComment #4
gerzenstl commentedOn 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.
Comment #5
gerzenstl commentedComment #6
ipumpkinuse $entity_type->getProvider() == 'eck'
Comment #8
ipumpkinComment #9
romixuaComment #10
romixuaCreated new patch based on @ipumpkin patch (#8)
Comment #11
johnnydarkko commentedI tried the patch in #10, but I'm getting a fatal error:
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!
Comment #12
legolasboLooks good to me. Will commit this. Thanks!
Comment #14
legolasbo