Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot create products with nullable customFields in admin UI #2343

Closed
alexisvigoureux opened this issue Aug 11, 2023 · 1 comment
Closed
Assignees
Labels

Comments

@alexisvigoureux
Copy link
Contributor

Describe the bug

We can not create products with nullable customFields. Some of our customFields are optional in version 1.9 but do not work on 2.x.

Capture d’écran 2023-08-11 à 15 49 10

To Reproduce
Steps to reproduce the behavior:

  1. Add customFields
export const ProductCustomFields: CustomFieldConfig[] = [
{
    name: 'start_date',
    label: [
      {
        languageCode: LanguageCode.en,
        value: 'Start date',
      },
    ],
    type: 'datetime',
  },
{
    name: 'useType',
    type: 'string',
    nullable: true,
    label: [
      {
        languageCode: LanguageCode.fr,
        value: "Type d'utilisation du produit",
      },
      {
        languageCode: LanguageCode.en,
        value: 'Use type',
      },
    ],
    options: [
      {
        value: ProductUseType.EVERYWHERE,
        label: [
          {
            languageCode: LanguageCode.en,
            value: 'Usable everywhere',
          },
        ],
      },
      {
        value: ProductUseType.STORE,
        label: [
          {
            languageCode: LanguageCode.en,
            value: 'Usable in store',
          },
        ],
      },
      {
        value: ProductUseType.ONLINE,
        label: [
          {
            languageCode: LanguageCode.en,
            value: 'Usable online',
          },
        ],
      },
    ],
  },
]
  1. Launch the server and go to "Inventory" in admin UI, click on "New product"
  2. Fills in the product name and variants but leaves customFields empty
  3. Click on the "Create" button
  4. See error
  • For start_date
Variable "$input" got invalid value {} at "input.customFields.start_date"; DateTime cannot represent non string or Date type {}

Even if we set nullable: true in the customFields, there's always an error because the graphql query sends "start_date": {}

  • For useType
The custom field "useType" value [""] is invalid. Valid options are ['everywhere', 'offline', 'online']

The graphql query sends "useType": "" but the select is good
Capture d’écran 2023-08-11 à 16 10 04

Expected behavior

We would like to have optional customFields with empty value, so we can create products without filling in the fields

Environment (please complete the following information):

  • @vendure/core version: 2.0.6
  • Nodejs version: 18.15
  • Database (mysql/postgres etc): postgres

Additional context

@alexisvigoureux
Copy link
Contributor Author

I tested with the 2.0.7 version. It fixed the datetime problem (start_date example) but not the nullable problem (useType example)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: 🚀 Shipped
Development

No branches or pull requests

2 participants