JSON:API Response Contains Duplicated Values

Created on 8 January 2024, 9 months ago
Updated 15 January 2024, 9 months ago

Problem/Motivation

After the 1.0.5 release from this code update https://www.drupal.org/project/entity_field_fetch/issues/3300098 πŸ› Entity Field Fetch should return a value via JSON:API Active , I see duplicated values in the JSON:API response for a node.

Here are two fields that should return different values...I have code locally that modifies this module to get this effect..what? I thought it would be easier to add images via "Insert Images" button. No matter, I will forge ahead.

I suspect that the TypedData field property classes are getting cached somehow or only returning the first value in a list.

Steps to reproduce

1. Create a node with one Paragraph field that contains multiple paragraphs.
2. Create two EFF fields on a content type that point to the paragraph field but different paragraph IDs.
2. Load the response via JSON:API to see only one paragraph being repeated.

Proposed resolution

I can get the correct field values by:

1. Reverting to 1.0.4 code.
2. Set the "value" property to "any" and "setInternal(FALSE)" in property definitions for EntityFieldFetchItem.
3. Add "$values['value'] = [];" and include the other values in "setValue()".

I know this might not be an ideal solution, but I want to upload it just in case an alternative method isn't found quickly.

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States afinnarn

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024