Skip to content

Dashboard: list relation custom fields not transformed to Ids suffix in update mutations #4210

@JariRengeling97

Description

@JariRengeling97

Describe the bug
The transformRelationFields() function in packages/dashboard/src/lib/framework/form-engine/utils.ts does not properly handle list-type relation custom fields. It has two issues:

  1. The original property key is never deleted for list relations (e.g. frequentlyBoughtWith), while for single relations it correctly calls delete. This causes the untransformed entity-name key to be sent in the mutation input, which GraphQL rejects.
  2. Empty arrays are not set on the Ids field — the relationIdValue.length > 0 guard prevents setting the field when the array is empty, AND the original key is not deleted. So frequentlyBoughtWith: [] is sent verbatim.

This means any product update mutation fails when list-type relation custom fields exist, even if the user is only changing an unrelated field like facet values.

To Reproduce
Steps to reproduce the behavior:

  1. Register any plugin that adds a list: true, type: 'relation' custom field to Product (e.g. frequentlyBoughtWith)
  2. Open the admin dashboard
  3. Navigate to any product detail page
  4. Change any field (e.g. add a facet value) and click "Update"
  5. See GraphQL error

Expected behavior
The product update should succeed. The transformRelationFields function should transform frequentlyBoughtWith: [{ id: "1" }, { id: "2" }] into frequentlyBoughtWithIds: ["1", "2"] and delete the original frequentlyBoughtWith key — matching the behavior already implemented for single (non-list) relations.

Actual behavior
The mutation fails with:

Field "frequentlyBoughtWith" is not defined by type "UpdateProductCustomFieldsInput".
Did you mean "frequentlyBoughtWithIds"?

The original key (frequentlyBoughtWith) is sent alongside the entity objects instead of the Ids-suffixed key with extracted IDs.

Error logs
If applicable, paste any relevant error messages or stack traces:

Field "frequentlyBoughtWith" is not defined by type "UpdateProductCustomFieldsInput".
Did you mean "frequentlyBoughtWithIds"?

Environment (please complete the following information):

  • @vendure/core version: 3.5.3
  • Nodejs version: 22.x
  • Database: MySQL
  • Operating System: macOS
  • Browser: Chrome
  • Package manager: npm

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions