Closed (fixed)
Project:
JSON:API
Version:
8.x-1.0-alpha3
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
12 Dec 2016 at 19:02 UTC
Updated:
7 Jan 2017 at 20:24 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
e0ipsoThanks for reporting @marcus_w. It seems you have done some debugging. Do you have any patch that you can share so someone else can follow your findings?
Comment #3
marcus_w commentedI did very little debugging, but the problem seems to be that on the Drupal\jsonapi\Context\FieldResolver::resolveInternal() function, the check is only on a dot. If a dot is found, it is assumed to be an external field.
In the Entity Query API, a .entity. part is needed for this external fields, therefore, if a dot is found, it is essentially replaced with .entity.. This means that querying on internal compound fields isn't possible. I think the query syntax should be the same as the Entity API query syntax, meaning that if filtering needs to be done on external fields, the .entity. should be provided in the request.
That would mean an API change for the module, so I haven't created a patch, as I don't know if it really is the best solution.
Comment #4
marcus_w commentedIt seems we could also check if it is an entity_reference field, changing line 73-78 to
Fixes the issue, but leaves the API intact. Though I think checking if it is not external is the other way around. We should check if the field is internal, and if not, retrieve the external field.
Comment #5
e0ipsoComment #6
e0ipsoThis was a good catch. I did my functional testing with the link field type (shipped with core) while debugging. Unit automated tests were added.
Comment #7
e0ipsoAdded functional testing. Merging if green.
Comment #9
e0ipso