Skip to content

resolveResponse with removeUnresolved option removes contentType object inside nested data #440

@rfearing

Description

@rfearing

Context

We are using the resolveResponse function in our project, and have recently added the removeUnresolved option to filter out draft or otherwise unresolvable content. After enabling this option, a number of our tests began failing due to contentType being undefined for certain entries. Upon investigating the Contentful JS SDK's implementation, we discovered the itemEntryPoints option, which resolved some failures when set as follows:

resolveResponse(response, { removeUnresolved: true, itemEntryPoints: ['fields'] })

However, we are still experiencing an issue where the removeUnresolved option removes the contentType from Embedded Entries fields. Here's a screenshot demonstrating the error within a failed test:

Screenshot of Typescript error

Expected Behavior

  • When using removeUnresolved: true, we expect only truly unresolvable or draft entries to be removed.
  • Embedded Entries should retain their contentType property as long as they are resolvable.
  • The response shape should remain compatible with downstream consumers that expect contentType to be present.

Observed Behavior

  • With removeUnresolved: true, Embedded Entries lose their contentType property.
  • This results in TypeScript errors and downstream issues in our application, as we rely on the presence of contentType for type-checking and rendering logic.
  • Setting itemEntryPoints: ['fields'] helps with some cases but does not resolve the issue for Embedded Entries.

Steps to Reproduce

  1. Use resolveResponse with a response containing RichText fields that embed other entries.
  2. Enable removeUnresolved: true and optionally set itemEntryPoints: ['fields'].
  3. Observe that Embedded Entries lose their contentType property.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions