Fix forbidden null sending as attribute value (#1201)

* Fix forbidden null value sending

* Update changelog

* Update schema and unset attribute values check

* Update test snapshots
This commit is contained in:
Dawid Tarasiuk 2021-07-01 13:20:01 +02:00 committed by GitHub
parent 909e08f2af
commit 88e5e75563
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 64 additions and 61 deletions

View file

@ -58,6 +58,7 @@ All notable, unreleased changes to this project will be documented in this file.
- Create channel filters in product, sales and voucher lists - #1187 by @jwm0 - Create channel filters in product, sales and voucher lists - #1187 by @jwm0
- Add generic filter validation - #1187 by @jwm0 - Add generic filter validation - #1187 by @jwm0
- Fix duplicated labels in column picker - #1197 by @orzechdev - Fix duplicated labels in column picker - #1197 by @orzechdev
- Fix forbidden null sending as attribute value - #1201 by @orzechdev
# 2.11.1 # 2.11.1

View file

@ -558,7 +558,7 @@ type AttributeTranslatableContent implements Node {
id: ID! id: ID!
name: String! name: String!
translation(languageCode: LanguageCodeEnum!): AttributeTranslation translation(languageCode: LanguageCodeEnum!): AttributeTranslation
attribute: Attribute attribute: Attribute @deprecated(reason: "Will be removed in Saleor 4.0. Get model fields from the root level.")
} }
type AttributeTranslate { type AttributeTranslate {
@ -655,7 +655,7 @@ input AttributeValueFilterInput {
input AttributeValueInput { input AttributeValueInput {
id: ID id: ID
values: [String] values: [String!]
file: String file: String
contentType: String contentType: String
references: [ID!] references: [ID!]
@ -667,7 +667,7 @@ type AttributeValueTranslatableContent implements Node {
id: ID! id: ID!
name: String! name: String!
translation(languageCode: LanguageCodeEnum!): AttributeValueTranslation translation(languageCode: LanguageCodeEnum!): AttributeValueTranslation
attributeValue: AttributeValue attributeValue: AttributeValue @deprecated(reason: "Will be removed in Saleor 4.0. Get model fields from the root level.")
} }
type AttributeValueTranslate { type AttributeValueTranslate {
@ -697,7 +697,7 @@ type AttributeValueUpdate {
input BulkAttributeValueInput { input BulkAttributeValueInput {
id: ID id: ID
values: [String]! values: [String!]!
} }
type BulkProductError { type BulkProductError {
@ -808,7 +808,7 @@ type CategoryTranslatableContent implements Node {
description: JSONString description: JSONString
descriptionJson: JSONString @deprecated(reason: "Will be removed in Saleor 4.0. Use the `description` field instead.") descriptionJson: JSONString @deprecated(reason: "Will be removed in Saleor 4.0. Use the `description` field instead.")
translation(languageCode: LanguageCodeEnum!): CategoryTranslation translation(languageCode: LanguageCodeEnum!): CategoryTranslation
category: Category category: Category @deprecated(reason: "Will be removed in Saleor 4.0. Get model fields from the root level.")
} }
type CategoryTranslate { type CategoryTranslate {
@ -1280,7 +1280,7 @@ type CollectionTranslatableContent implements Node {
description: JSONString description: JSONString
descriptionJson: JSONString @deprecated(reason: "Will be removed in Saleor 4.0. Use the `description` field instead.") descriptionJson: JSONString @deprecated(reason: "Will be removed in Saleor 4.0. Use the `description` field instead.")
translation(languageCode: LanguageCodeEnum!): CollectionTranslation translation(languageCode: LanguageCodeEnum!): CollectionTranslation
collection: Collection collection: Collection @deprecated(reason: "Will be removed in Saleor 4.0. Get model fields from the root level.")
} }
type CollectionTranslate { type CollectionTranslate {
@ -2616,7 +2616,7 @@ type MenuItemTranslatableContent implements Node {
id: ID! id: ID!
name: String! name: String!
translation(languageCode: LanguageCodeEnum!): MenuItemTranslation translation(languageCode: LanguageCodeEnum!): MenuItemTranslation
menuItem: MenuItem menuItem: MenuItem @deprecated(reason: "Will be removed in Saleor 4.0. Get model fields from the root level.")
} }
type MenuItemTranslate { type MenuItemTranslate {
@ -2873,21 +2873,21 @@ type Mutation {
voucherChannelListingUpdate(id: ID!, input: VoucherChannelListingInput!): VoucherChannelListingUpdate voucherChannelListingUpdate(id: ID!, input: VoucherChannelListingInput!): VoucherChannelListingUpdate
exportProducts(input: ExportProductsInput!): ExportProducts exportProducts(input: ExportProductsInput!): ExportProducts
fileUpload(file: Upload!): FileUpload fileUpload(file: Upload!): FileUpload
checkoutAddPromoCode(checkoutId: ID!, promoCode: String!): CheckoutAddPromoCode checkoutAddPromoCode(checkoutId: ID, promoCode: String!, token: UUID): CheckoutAddPromoCode
checkoutBillingAddressUpdate(billingAddress: AddressInput!, checkoutId: ID!): CheckoutBillingAddressUpdate checkoutBillingAddressUpdate(billingAddress: AddressInput!, checkoutId: ID, token: UUID): CheckoutBillingAddressUpdate
checkoutComplete(checkoutId: ID!, paymentData: JSONString, redirectUrl: String, storeSource: Boolean = false): CheckoutComplete checkoutComplete(checkoutId: ID, paymentData: JSONString, redirectUrl: String, storeSource: Boolean = false, token: UUID): CheckoutComplete
checkoutCreate(input: CheckoutCreateInput!): CheckoutCreate checkoutCreate(input: CheckoutCreateInput!): CheckoutCreate
checkoutCustomerAttach(checkoutId: ID!): CheckoutCustomerAttach checkoutCustomerAttach(checkoutId: ID, token: UUID): CheckoutCustomerAttach
checkoutCustomerDetach(checkoutId: ID!): CheckoutCustomerDetach checkoutCustomerDetach(checkoutId: ID, token: UUID): CheckoutCustomerDetach
checkoutEmailUpdate(checkoutId: ID, email: String!): CheckoutEmailUpdate checkoutEmailUpdate(checkoutId: ID, email: String!, token: UUID): CheckoutEmailUpdate
checkoutLineDelete(checkoutId: ID!, lineId: ID): CheckoutLineDelete checkoutLineDelete(checkoutId: ID, lineId: ID, token: UUID): CheckoutLineDelete
checkoutLinesAdd(checkoutId: ID!, lines: [CheckoutLineInput]!): CheckoutLinesAdd checkoutLinesAdd(checkoutId: ID, lines: [CheckoutLineInput]!, token: UUID): CheckoutLinesAdd
checkoutLinesUpdate(checkoutId: ID!, lines: [CheckoutLineInput]!): CheckoutLinesUpdate checkoutLinesUpdate(checkoutId: ID, lines: [CheckoutLineInput]!, token: UUID): CheckoutLinesUpdate
checkoutRemovePromoCode(checkoutId: ID!, promoCode: String!): CheckoutRemovePromoCode checkoutRemovePromoCode(checkoutId: ID, promoCode: String!, token: UUID): CheckoutRemovePromoCode
checkoutPaymentCreate(checkoutId: ID!, input: PaymentInput!): CheckoutPaymentCreate checkoutPaymentCreate(checkoutId: ID, input: PaymentInput!, token: UUID): CheckoutPaymentCreate
checkoutShippingAddressUpdate(checkoutId: ID!, shippingAddress: AddressInput!): CheckoutShippingAddressUpdate checkoutShippingAddressUpdate(checkoutId: ID, shippingAddress: AddressInput!, token: UUID): CheckoutShippingAddressUpdate
checkoutShippingMethodUpdate(checkoutId: ID, shippingMethodId: ID!): CheckoutShippingMethodUpdate checkoutShippingMethodUpdate(checkoutId: ID, shippingMethodId: ID!, token: UUID): CheckoutShippingMethodUpdate
checkoutLanguageCodeUpdate(checkoutId: ID!, languageCode: LanguageCodeEnum!): CheckoutLanguageCodeUpdate checkoutLanguageCodeUpdate(checkoutId: ID, languageCode: LanguageCodeEnum!, token: UUID): CheckoutLanguageCodeUpdate
channelCreate(input: ChannelCreateInput!): ChannelCreate channelCreate(input: ChannelCreateInput!): ChannelCreate
channelUpdate(id: ID!, input: ChannelUpdateInput!): ChannelUpdate channelUpdate(id: ID!, input: ChannelUpdateInput!): ChannelUpdate
channelDelete(id: ID!, input: ChannelDeleteInput): ChannelDelete channelDelete(id: ID!, input: ChannelDeleteInput): ChannelDelete
@ -3674,7 +3674,7 @@ type PageTranslatableContent implements Node {
content: JSONString content: JSONString
contentJson: JSONString @deprecated(reason: "Will be removed in Saleor 4.0. Use the `content` field instead.") contentJson: JSONString @deprecated(reason: "Will be removed in Saleor 4.0. Use the `content` field instead.")
translation(languageCode: LanguageCodeEnum!): PageTranslation translation(languageCode: LanguageCodeEnum!): PageTranslation
page: Page page: Page @deprecated(reason: "Will be removed in Saleor 4.0. Get model fields from the root level.")
} }
type PageTranslate { type PageTranslate {
@ -4419,7 +4419,7 @@ type ProductTranslatableContent implements Node {
description: JSONString description: JSONString
descriptionJson: JSONString @deprecated(reason: "Will be removed in Saleor 4.0. Use the `description` field instead.") descriptionJson: JSONString @deprecated(reason: "Will be removed in Saleor 4.0. Use the `description` field instead.")
translation(languageCode: LanguageCodeEnum!): ProductTranslation translation(languageCode: LanguageCodeEnum!): ProductTranslation
product: Product product: Product @deprecated(reason: "Will be removed in Saleor 4.0. Get model fields from the root level.")
} }
type ProductTranslate { type ProductTranslate {
@ -4574,7 +4574,7 @@ type ProductVariantBulkCreate {
} }
input ProductVariantBulkCreateInput { input ProductVariantBulkCreateInput {
attributes: [BulkAttributeValueInput]! attributes: [BulkAttributeValueInput!]!
sku: String! sku: String!
trackInventory: Boolean trackInventory: Boolean
weight: WeightScalar weight: WeightScalar
@ -4626,7 +4626,7 @@ type ProductVariantCreate {
} }
input ProductVariantCreateInput { input ProductVariantCreateInput {
attributes: [AttributeValueInput]! attributes: [AttributeValueInput!]!
sku: String sku: String
trackInventory: Boolean trackInventory: Boolean
weight: WeightScalar weight: WeightScalar
@ -4647,7 +4647,7 @@ input ProductVariantFilterInput {
} }
input ProductVariantInput { input ProductVariantInput {
attributes: [AttributeValueInput] attributes: [AttributeValueInput!]
sku: String sku: String
trackInventory: Boolean trackInventory: Boolean
weight: WeightScalar weight: WeightScalar
@ -4693,7 +4693,7 @@ type ProductVariantTranslatableContent implements Node {
id: ID! id: ID!
name: String! name: String!
translation(languageCode: LanguageCodeEnum!): ProductVariantTranslation translation(languageCode: LanguageCodeEnum!): ProductVariantTranslation
productVariant: ProductVariant productVariant: ProductVariant @deprecated(reason: "Will be removed in Saleor 4.0. Get model fields from the root level.")
} }
type ProductVariantTranslate { type ProductVariantTranslate {
@ -4944,7 +4944,7 @@ type SaleTranslatableContent implements Node {
id: ID! id: ID!
name: String! name: String!
translation(languageCode: LanguageCodeEnum!): SaleTranslation translation(languageCode: LanguageCodeEnum!): SaleTranslation
sale: Sale sale: Sale @deprecated(reason: "Will be removed in Saleor 4.0. Get model fields from the root level.")
} }
type SaleTranslate { type SaleTranslate {
@ -5066,7 +5066,7 @@ type ShippingMethodTranslatableContent implements Node {
name: String! name: String!
description: JSONString description: JSONString
translation(languageCode: LanguageCodeEnum!): ShippingMethodTranslation translation(languageCode: LanguageCodeEnum!): ShippingMethodTranslation
shippingMethod: ShippingMethod shippingMethod: ShippingMethod @deprecated(reason: "Will be removed in Saleor 4.0. Get model fields from the root level.")
} }
type ShippingMethodTranslation implements Node { type ShippingMethodTranslation implements Node {
@ -5890,7 +5890,7 @@ type VoucherTranslatableContent implements Node {
id: ID! id: ID!
name: String name: String
translation(languageCode: LanguageCodeEnum!): VoucherTranslation translation(languageCode: LanguageCodeEnum!): VoucherTranslation
voucher: Voucher voucher: Voucher @deprecated(reason: "Will be removed in Saleor 4.0. Get model fields from the root level.")
} }
type VoucherTranslate { type VoucherTranslate {

View file

@ -221,7 +221,9 @@ function getBooleanInput(attribute: AttributeInput) {
function getDefaultInput(attribute: AttributeInput) { function getDefaultInput(attribute: AttributeInput) {
return { return {
id: attribute.id, id: attribute.id,
values: attribute.value[0] === "" ? [] : attribute.value values: ["", undefined, null].includes(attribute.value[0])
? []
: attribute.value
}; };
} }

View file

@ -330,7 +330,7 @@ export const variantUpdateMutation = gql`
$addStocks: [StockInput!]! $addStocks: [StockInput!]!
$removeStocks: [ID!]! $removeStocks: [ID!]!
$id: ID! $id: ID!
$attributes: [AttributeValueInput] $attributes: [AttributeValueInput!]
$sku: String $sku: String
$trackInventory: Boolean! $trackInventory: Boolean!
$stocks: [StockInput!]! $stocks: [StockInput!]!

View file

@ -755,7 +755,7 @@ export interface VariantUpdateVariables {
addStocks: StockInput[]; addStocks: StockInput[];
removeStocks: string[]; removeStocks: string[];
id: string; id: string;
attributes?: (AttributeValueInput | null)[] | null; attributes?: AttributeValueInput[] | null;
sku?: string | null; sku?: string | null;
trackInventory: boolean; trackInventory: boolean;
stocks: StockInput[]; stocks: StockInput[];

View file

@ -10268,31 +10268,31 @@ exports[`Storyshots Generics / Multiple select with autocomplete can load more 1
Antigua and Barbuda Antigua and Barbuda
</span> </span>
</div> </div>
<hr </div>
class="Hr-root-id MultiAutocompleteSelectFieldContent-hr-id" <hr
/> class="Hr-root-id MultiAutocompleteSelectFieldContent-hr-id"
/>
<div
class="MultiAutocompleteSelectFieldContent-progressContainer-id"
>
<div <div
class="MultiAutocompleteSelectFieldContent-progressContainer-id" class="MuiCircularProgress-root-id MultiAutocompleteSelectFieldContent-progress-id MuiCircularProgress-colorPrimary-id MuiCircularProgress-indeterminate-id"
role="progressbar"
style="width:24px;height:24px"
> >
<div <svg
class="MuiCircularProgress-root-id MultiAutocompleteSelectFieldContent-progress-id MuiCircularProgress-colorPrimary-id MuiCircularProgress-indeterminate-id" class="MuiCircularProgress-svg-id"
role="progressbar" viewBox="22 22 44 44"
style="width:24px;height:24px"
> >
<svg <circle
class="MuiCircularProgress-svg-id" class="MuiCircularProgress-circle-id MuiCircularProgress-circleIndeterminate-id"
viewBox="22 22 44 44" cx="44"
> cy="44"
<circle fill="none"
class="MuiCircularProgress-circle-id MuiCircularProgress-circleIndeterminate-id" r="20.2"
cx="44" stroke-width="3.6"
cy="44" />
fill="none" </svg>
r="20.2"
stroke-width="3.6"
/>
</svg>
</div>
</div> </div>
</div> </div>
<div <div

View file

@ -1161,7 +1161,7 @@ export interface AttributeValueCreateInput {
export interface AttributeValueInput { export interface AttributeValueInput {
id?: string | null; id?: string | null;
values?: (string | null)[] | null; values?: string[] | null;
file?: string | null; file?: string | null;
contentType?: string | null; contentType?: string | null;
references?: string[] | null; references?: string[] | null;
@ -1176,7 +1176,7 @@ export interface AttributeValueTranslationInput {
export interface BulkAttributeValueInput { export interface BulkAttributeValueInput {
id?: string | null; id?: string | null;
values: (string | null)[]; values: string[];
} }
export interface CatalogueInput { export interface CatalogueInput {
@ -1726,7 +1726,7 @@ export interface ProductTypeSortingInput {
} }
export interface ProductVariantBulkCreateInput { export interface ProductVariantBulkCreateInput {
attributes: (BulkAttributeValueInput | null)[]; attributes: BulkAttributeValueInput[];
sku: string; sku: string;
trackInventory?: boolean | null; trackInventory?: boolean | null;
weight?: any | null; weight?: any | null;
@ -1741,7 +1741,7 @@ export interface ProductVariantChannelListingAddInput {
} }
export interface ProductVariantCreateInput { export interface ProductVariantCreateInput {
attributes: (AttributeValueInput | null)[]; attributes: AttributeValueInput[];
sku?: string | null; sku?: string | null;
trackInventory?: boolean | null; trackInventory?: boolean | null;
weight?: any | null; weight?: any | null;
@ -1750,7 +1750,7 @@ export interface ProductVariantCreateInput {
} }
export interface ProductVariantInput { export interface ProductVariantInput {
attributes?: (AttributeValueInput | null)[] | null; attributes?: AttributeValueInput[] | null;
sku?: string | null; sku?: string | null;
trackInventory?: boolean | null; trackInventory?: boolean | null;
weight?: any | null; weight?: any | null;