Include parameter doesn't work with different type of entities

Created on 28 June 2024, 5 months ago
Updated 4 July 2024, 4 months ago

Problem/Motivation

When returning a list of entities that are not the same, or a list of nodes with different content-types, if the "include" parameters is used, it checks for the first entity if this field can be included and if not possible, it raises an error with message:

title: "Bad Request",
status: "400",
detail: "`field_brighcove_video` is not a valid relationship field name. Possible values: node_type, uid, field_author, field_content, field_entity, field_main_publication_channel, field_other_publication_channel, field_section, field_series, field_source, field_team, field_teaser, field_topics, field_topic_entity.",

An example of module that uses JSON:API Resources is JSON:API Search API โ†’ , which makes a lot of sense to return node within different content types.

Steps to reproduce

Try getting multiple type of data in a single JSON API with include parameters having fields that are not common between different entity types you are trying to fetch.

Proposed resolution

My suggestion is to receive the resource identifier as part of include path and check that before include it, something like ?include=node--video.field_brighcove_video.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

๐Ÿ› Bug report
Status

Active

Version

11.0 ๐Ÿ”ฅ

Component
JSON APIย  โ†’

Last updated about 9 hours ago

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia Anul Delhi

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024