React Dashboard: GraphQL Error with ProductVariantPriceCustomFields
Describe the bug
Having setup [email protected] with the React dashboard and custom field on ProductVariantPrice leads to the following error on any Product Variant page:
To Reproduce Steps to reproduce the behavior:
- Add these custom fields to vendure.config
config.customFields = {
...config.customFields,
ProductVariantPrice: [
...config.customFields.ProductVariantPrice,
{
name: 'saleOriginalPrice',
label: [{ languageCode: LanguageCode.en, value: 'Sale Original Price' }],
description: [{ languageCode: LanguageCode.en, value: 'Original price before sale promotion was applied' }],
type: 'int',
ui: { tab: 'On Sale', component: 'currency-form-input' },
readonly: true,
},
{
name: 'salePercentage',
label: [{ languageCode: LanguageCode.en, value: 'Sale Discount Percentage' }],
description: [{ languageCode: LanguageCode.en, value: 'Discount percentage by active sale promotion' }],
type: 'float',
ui: { tab: 'On Sale', component: 'number-form-input', prefix: '%'},
readonly: true
},
],
- open a product variant page in the React dashboard
Expected behavior The Product variant with custom fields is shown.
Actual behavior The Error is shown.
Screenshots/Videos
Error logs If applicable, paste any relevant error messages or stack traces:
GraphQL Request Error: Field "customFields" of type "ProductVariantPriceCustomFields" must have a selection of subfields. Did you mean "customFields { ... }"?
Environment (please complete the following information):
- @vendure/core version: v3.5.0
- Nodejs version: v22
- Database (mysql/postgres etc): MySQL
- Operating System (Windows/macOS/Linux): Linux
- Browser (if applicable): Chromium
- Package manager (npm/yarn/pnpm): npm
I’m also running into this issue on my setup. It would be great to have this resolved soon. Happy to provide any additional info if needed.
@dlhck @michaelbromley Would you be open to considering adding this GitHub issue to your roadmap?
Good morning :) We've been adding this to the 3.5.2 release - I'll be talking a look at it soon.
Hey @mehringer68, Are you working on this, or should I pick it up? What I found is that this error happens because adding custom field config turns customFields into an object type, and GraphQL then requires selecting its subfields. That means whenever we add or change custom fields, the queries need to be updated too.
Is this expected, or is there a better approach to avoid updating queries every time?
I used the same custom field config as above and updated the query to:
prices {
currencyCode
price
customFields {
saleOriginalPrice
}
}
in productVariantDetailDocument. After that, everything started working correctly.
@PavanendraBaahubali I'm onto it
In v3.5.2 the error will be fixed, so that the page will at least load. The next patch should then introduce the ability to actual view/edit the custom field values.