d34dman / drupal-jsonapi-params

A package to manage json-api params
ISC License
59 stars 8 forks source link

Accessing non-entityreference nested fields breaks JSON:API #30

Closed laurencefass closed 2 years ago

laurencefass commented 2 years ago

I attached this to another post but seperate issue, so here goes....

I am trying to access a nested field which isnt an entityreference and Im getting breakage. I dont yet know if its an issue with this API or the Drupal interface.

As per my previous post this works...

apiParams
.addFilter('title', 'cat', 'CONTAINS')
.addFields('node--article', ['body', 'title'])

...but this breaks Drupal JSON:API (accessing nodes withpath alias defined)

".addFilter('path.alias', 'cat', 'CONTAINS')
.addFields('node--article', ['body', 'title'])"

as in the query

filter[path.alias][condition][path]=path.alias&filter[path.alias][condition][value]=cat&filter[path.alias][condition][operator]=CONTAINS&fields[node--article]=body,title

this looks like it should work, but results in

The website encountered an unexpected error. Please try again later.

Looks like something is broken but I dont yet know enough about your API function or JSON:API to know what. Any advice greatly appreciated.

d34dman commented 2 years ago

@laurencefass thanks for separating the issue. The problem space is out of scope for this module. Here are few places which you can check out to get more understanding about the problem,

TLDR; path.alias is a computed field, and hence doesn't play well with JSON:API query.

d34dman commented 2 years ago

Am sorry I couldn't be more helpful here. This is not a limitation of the library and there is nothing more we can do here.