vendure icon indicating copy to clipboard operation
vendure copied to clipboard

React Dashboard: GraphQL Error with ProductVariantPriceCustomFields

Open derXear opened this issue 2 months ago • 7 comments

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:

  1. 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
        },
      ],
  1. 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 Image

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

derXear avatar Oct 27 '25 08:10 derXear

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.

johannabertils avatar Oct 30 '25 09:10 johannabertils

@dlhck @michaelbromley Would you be open to considering adding this GitHub issue to your roadmap?

timcv avatar Nov 14 '25 09:11 timcv

Good morning :) We've been adding this to the 3.5.2 release - I'll be talking a look at it soon.

mehringer68 avatar Nov 24 '25 08:11 mehringer68

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?

PavanendraBaahubali avatar Nov 30 '25 18:11 PavanendraBaahubali

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 avatar Nov 30 '25 18:11 PavanendraBaahubali

@PavanendraBaahubali I'm onto it

mehringer68 avatar Dec 10 '25 08:12 mehringer68

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.

michaelbromley avatar Dec 18 '25 14:12 michaelbromley