From d7f0803eddd958779bec4e1fe860ce9820ed0aa5 Mon Sep 17 00:00:00 2001 From: Jannik Zinkl Date: Tue, 6 Aug 2024 01:03:07 +0200 Subject: [PATCH] feat: new stock update mutations --- package.json | 1 + pkg/saleor/src/api/generated/graphql.ts | 52 +++++++++++++++++-- .../api/mutations/productVariantStocks.gql | 11 ++++ pkg/saleor/src/api/queries/products.gql | 7 +-- pnpm-lock.yaml | 10 ++++ 5 files changed, 73 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 39bf772d2..6d7a5b16d 100644 --- a/package.json +++ b/package.json @@ -106,6 +106,7 @@ "@chronark/prefixed-id": "^0.4.1", "@elastic/ecs-winston-format": "^1.5.3", "@elastic/elasticsearch": "^8.14.0", + "@esbuild/darwin-arm64": "^0.23.0", "@geist-ui/react": "^2.2.5", "@paljs/plugins": "^6.0.7", "@prisma/client": "^5.17.0", diff --git a/pkg/saleor/src/api/generated/graphql.ts b/pkg/saleor/src/api/generated/graphql.ts index 87067d69e..2097f95ea 100644 --- a/pkg/saleor/src/api/generated/graphql.ts +++ b/pkg/saleor/src/api/generated/graphql.ts @@ -16358,6 +16358,7 @@ export type OrderFilterInput = { channels?: InputMaybe>; chargeStatus?: InputMaybe>; checkoutIds?: InputMaybe>; + checkoutTokens?: InputMaybe>; created?: InputMaybe; customer?: InputMaybe; giftCardBought?: InputMaybe; @@ -33165,6 +33166,24 @@ export type ProductVariantStockEntryUpdateMutation = { } | null; }; +export type BulkVariantStockUpdateMutationVariables = Exact<{ + stocks: Array | StockBulkUpdateInput; +}>; + +export type BulkVariantStockUpdateMutation = { + __typename?: "Mutation"; + stockBulkUpdate?: { + __typename?: "StockBulkUpdate"; + count: number; + errors: Array<{ + __typename?: "StockBulkUpdateError"; + field?: string | null; + message?: string | null; + code: StockBulkUpdateErrorCode; + }>; + } | null; +}; + export type ProductVariantBulkUpdateMutationVariables = Exact<{ variants: | Array @@ -34631,7 +34650,7 @@ export type SaleorEntitySyncProductsQuery = { }; export type SaleorProductVariantsBasicDataQueryVariables = Exact<{ - ids: Array | Scalars["ID"]; + ids?: InputMaybe | Scalars["ID"]>; first?: InputMaybe; after?: InputMaybe; }>; @@ -34653,6 +34672,7 @@ export type SaleorProductVariantsBasicDataQuery = { __typename?: "ProductVariant"; id: string; name: string; + sku?: string | null; product: { __typename?: "Product"; id: string; name: string }; metadata: Array<{ __typename?: "MetadataItem"; @@ -35511,6 +35531,18 @@ export const ProductVariantStockEntryUpdateDocument = gql` } } `; +export const BulkVariantStockUpdateDocument = gql` + mutation bulkVariantStockUpdate($stocks: [StockBulkUpdateInput!]!) { + stockBulkUpdate(stocks: $stocks) { + count + errors { + field + message + code + } + } + } +`; export const ProductVariantBulkUpdateDocument = gql` mutation productVariantBulkUpdate( $variants: [ProductVariantBulkUpdateInput!]! @@ -36198,7 +36230,7 @@ export const SaleorEntitySyncProductsDocument = gql` `; export const SaleorProductVariantsBasicDataDocument = gql` query saleorProductVariantsBasicData( - $ids: [ID!]! + $ids: [ID!] $first: Int $after: String ) { @@ -36213,6 +36245,7 @@ export const SaleorProductVariantsBasicDataDocument = gql` node { id name + sku product { id name @@ -36725,6 +36758,19 @@ export function getSdk(requester: Requester) { options, ) as Promise; }, + bulkVariantStockUpdate( + variables: BulkVariantStockUpdateMutationVariables, + options?: C, + ): Promise { + return requester< + BulkVariantStockUpdateMutation, + BulkVariantStockUpdateMutationVariables + >( + BulkVariantStockUpdateDocument, + variables, + options, + ) as Promise; + }, productVariantBulkUpdate( variables: ProductVariantBulkUpdateMutationVariables, options?: C, @@ -37017,7 +37063,7 @@ export function getSdk(requester: Requester) { ) as Promise; }, saleorProductVariantsBasicData( - variables: SaleorProductVariantsBasicDataQueryVariables, + variables?: SaleorProductVariantsBasicDataQueryVariables, options?: C, ): Promise { return requester< diff --git a/pkg/saleor/src/api/mutations/productVariantStocks.gql b/pkg/saleor/src/api/mutations/productVariantStocks.gql index e266db843..d31da0f8b 100644 --- a/pkg/saleor/src/api/mutations/productVariantStocks.gql +++ b/pkg/saleor/src/api/mutations/productVariantStocks.gql @@ -21,3 +21,14 @@ mutation productVariantStockEntryUpdate( } } } + +mutation bulkVariantStockUpdate($stocks: [StockBulkUpdateInput!]!) { + stockBulkUpdate(stocks: $stocks) { + count + errors { + field + message + code + } + } +} diff --git a/pkg/saleor/src/api/queries/products.gql b/pkg/saleor/src/api/queries/products.gql index f8cdd3dc4..3991d6a63 100644 --- a/pkg/saleor/src/api/queries/products.gql +++ b/pkg/saleor/src/api/queries/products.gql @@ -167,11 +167,7 @@ query saleorEntitySyncProducts( } } -query saleorProductVariantsBasicData( - $ids: [ID!]! - $first: Int - $after: String -) { +query saleorProductVariantsBasicData($ids: [ID!], $first: Int, $after: String) { productVariants(ids: $ids, first: $first, after: $after) { pageInfo { hasNextPage @@ -183,6 +179,7 @@ query saleorProductVariantsBasicData( node { id name + sku product { id name diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c896aadfc..7504824e9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -35,6 +35,9 @@ dependencies: '@elastic/elasticsearch': specifier: ^8.14.0 version: 8.14.0 + '@esbuild/darwin-arm64': + specifier: ^0.23.0 + version: 0.23.0 '@geist-ui/react': specifier: ^2.2.5 version: 2.2.5(react-dom@18.3.1)(react@18.3.1) @@ -2212,6 +2215,13 @@ packages: dev: false optional: true + /@esbuild/darwin-arm64@0.23.0: + resolution: {integrity: sha512-YLntie/IdS31H54Ogdn+v50NuoWF5BDkEUFpiOChVa9UnKpftgwzZRrI4J132ETIi+D8n6xh9IviFV3eXdxfow==} + engines: {node: '>=18'} + cpu: [arm64] + os: [darwin] + dev: false + /@esbuild/darwin-x64@0.21.5: resolution: {integrity: sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw==} engines: {node: '>=12'}