I'm trying to filter a resultset by "IS NULL" operator. this works normally with attributes, but doesn't work if the filter is done by a path to one relationship.
This url works perfectly
/* WORKS */
https://site.url/api/node/myContentType?filter[my-filter][condition][path]=myAttributeField&filter[my-filter][condition][operator]=IS NULLbut this url always get 0 count in return, regardless of real relationship status
/* DOESN'T WORK */
https://site.url/api/node/myContentType?filter[my-filter][condition][path]=myRelationshipField.id&filter[my-filter][condition][operator]=IS NULLFunny thing is that instead, the "IS NOT NULL" operator works with relations:
/* WORKS */
https://site.url/api/node/myContentType?filter[my-filter][condition][path]=myRelationshipField.id&filter[my-filter][condition][operator]=IS NOT NULL
Comments
Comment #2
gabesulliceMoving to the Drupal core issue queue. The 2.x branch of JSON:API is no longer maintained.
Comment #3
gabesulliceUnder the hood, this filter is saying "give me all instances of
myContentTypethat reference an entity with an emptyUUID". An empty result set is "correct" in that case, since you don't have any content that references other content without an ID. All content has an ID, if it exists.What you really need to be able to do is filter for an empty relationship. I'm pretty sure that this is a duplicate of #3025372: [regression] Impossible to filter for resources with an empty relationship object in JSON:API 2.x. Therefore, I'm going to close this issue as such. If you think otherwise, feel free to reopen.
The linked issue needs someone to reroll the patch for the 8.9.x branch of Drupal core and return it to RTBC status.