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

You can't create a variant with required boolean value #15319

Open
KarolJagodzinski opened this issue Jan 26, 2024 · 3 comments
Open

You can't create a variant with required boolean value #15319

KarolJagodzinski opened this issue Jan 26, 2024 · 3 comments
Labels
bug merchant Merchant Experience team topics triage

Comments

@KarolJagodzinski
Copy link

What are you trying to achieve?

Trying to add a variant that has required boolean attribute.

Steps to reproduce the problem

  1. Create product type with two attributes, one of them is boolean and it's required. Assign them as variant attributes.
  2. Create a new variant with populating only the attribute which is not boolean
  3. Click save and you will see the error.
{
    "data": {
        "productVariantBulkCreate": {
            "errors": [
                {
                    "field": "attributes",
                    "code": "REQUIRED",
                    "index": null,
                    "channels": null,
                    "message": "All attributes flagged as having a value required must be supplied.",
                    "__typename": "BulkProductError"
                }
            ],
            "productVariants": [],
            "__typename": "ProductVariantBulkCreate"
        }
    },
    "extensions": {
        "cost": {
            "requestedQueryCost": 0,
            "maximumAvailable": 50000
        }
    }
}

What did you expect to happen?

I should have a possibility to provide a boolean value or I should be able to set default boolean value.

Logs

No response

Environment

Saleor version: dashboard v3.18.2, core v3.18.12

@KarolJagodzinski KarolJagodzinski changed the title Bug: You can't create a variant name with required boolean value Bug: You can't create a variant with required boolean value Jan 26, 2024
@maarcingebala maarcingebala added the merchant Merchant Experience team topics label Feb 12, 2024
@slawekmarszalek slawekmarszalek changed the title Bug: You can't create a variant with required boolean value You can't create a variant with required boolean value Feb 13, 2024
@IKarbowiak
Copy link
Member

Hi @KarolJagodzinski,

Thank you for reporting the issue. Could you send the mutation query with the variables that are causing an error?

@KarolJagodzinski
Copy link
Author

KarolJagodzinski commented Feb 22, 2024

Hi @IKarbowiak

Mutation (taken from devtools when used dashboard)

mutation ProductVariantBulkCreate($id: ID!, $inputs: [ProductVariantBulkCreateInput!]!) {
  productVariantBulkCreate(product: $id, variants: $inputs) {
    errors {
      ...BulkProductError
      __typename
    }
    productVariants {
      id
      __typename
    }
    __typename
  }
}

fragment BulkProductError on BulkProductError {
  field
  code
  index
  channels
  message
  __typename
}

Variables:

{
  "id": "UHJvZHVjdDoyMjc=",
  "inputs": [
    {
      "attributes": [
        {
          "id": "QXR0cmlidXRlOjUw",
          "plainText": "not required attr"
        }
      ],
      "sku": "test",
      "name": "test",
      "channelListings": [
        {
          "channelId": "Q2hhbm5lbDoz",
          "price": 1
        }
      ],
      "stocks": []
    }
  ]
}

AttributeList response (both set as variant attributes)

{
  "data": {
    "attributes": {
      "edges": [
        {
          "node": {
            "id": "QXR0cmlidXRlOjUw",
            "name": "not required attribute",
            "slug": "not-required-attribute",
            "type": "PRODUCT_TYPE",
            "visibleInStorefront": true,
            "filterableInDashboard": false,
            "filterableInStorefront": false,
            "unit": null,
            "inputType": "PLAIN_TEXT",
            "__typename": "Attribute"
          },
          "__typename": "AttributeCountableEdge"
        },
        {
          "node": {
            "id": "QXR0cmlidXRlOjUx",
            "name": "required boolean",
            "slug": "required-boolean",
            "type": "PRODUCT_TYPE",
            "visibleInStorefront": true,
            "filterableInDashboard": false,
            "filterableInStorefront": false,
            "unit": null,
            "inputType": "BOOLEAN",
            "__typename": "Attribute"
          },
          "__typename": "AttributeCountableEdge"
        }
      ],
      "pageInfo": {
        "endCursor": "WyJyZXF1aXJlZCBib29sZWFuIiwgInJlcXVpcmVkLWJvb2xlYW4iXQ==",
        "hasNextPage": false,
        "hasPreviousPage": false,
        "startCursor": "WyJub3QgcmVxdWlyZWQgYXR0cmlidXRlIiwgIm5vdC1yZXF1aXJlZC1hdHRyaWJ1dGUiXQ==",
        "__typename": "PageInfo"
      },
      "__typename": "AttributeCountableConnection"
    }
  }
}

Response:

{
  "data": {
    "productVariantBulkCreate": {
      "errors": [
        {
          "field": "attributes",
          "code": "REQUIRED",
          "index": null,
          "channels": null,
          "message": "All attributes flagged as having a value required must be supplied.",
          "__typename": "BulkProductError"
        }
      ],
      "productVariants": [],
      "__typename": "ProductVariantBulkCreate"
    }
  }
}

Edit:
So basically I'm not able to set required values when using dashboard

@IKarbowiak
Copy link
Member

Thank you @KarolJagodzinski, so seems like a dashboard bug. We'll fix that as soon as possible

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug merchant Merchant Experience team topics triage
Projects
None yet
Development

No branches or pull requests

3 participants