-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
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:
- 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.
- 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:
- Register any plugin that adds a list: true, type: 'relation' custom field to Product (e.g. frequentlyBoughtWith)
- Open the admin dashboard
- Navigate to any product detail page
- Change any field (e.g. add a facet value) and click "Update"
- 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