Score:0

JSONAPI - limit list of included referenced entities via filter

ke flag

I'm using JSON API and JSON API Include modules, in Drupal 9.5

I've got a node type, "article" with a entity reference revisions field referencing a paragraphs, field name, field_variant. So this call works great, gives me all information: https://mysite.com/jsonapi/node/article?include=field_variant&jsonapi_include=1

What I'd like to do is have a filter, which returns all nodes of the type, that have a particular value for a field on one of the paragraph entities, BUT, only include the paragraph entities with that value.

So imagine the paragraph type has field_hide, boolean.

Node has two paragraph items.

I set field_hide = 1 for one item, and field_hide = 0 for the other item.

Now I want to do something like this: https://mysite.com/jsonapi/node/article?include=field_variant&jsonapi_include=1&filter[field_variant.field_hide]=0

I want this to return the node and all its fields, but in the include for the paragraph field, field_variant, only return the paragraph item where field_hide = 0.

Currently if even 1 paragraph item has the filter value, then the node and ALL its referenced paragraph items are returned in the response.

How to limit the list of referenced paragraph items so that only those items that match the paragraph field's filter are included in the result?

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.