2020-07-07 10:14:12 +00:00
|
|
|
import {
|
|
|
|
bulkProductErrorFragment,
|
|
|
|
bulkStockErrorFragment,
|
2020-07-30 09:54:16 +00:00
|
|
|
exportErrorFragment,
|
2020-07-07 10:14:12 +00:00
|
|
|
productErrorFragment,
|
|
|
|
stockErrorFragment
|
|
|
|
} from "@saleor/fragments/errors";
|
|
|
|
import {
|
2020-07-30 09:54:16 +00:00
|
|
|
exportFileFragment,
|
2020-07-07 10:14:12 +00:00
|
|
|
fragmentVariant,
|
|
|
|
productFragmentDetails
|
|
|
|
} from "@saleor/fragments/products";
|
2020-03-23 12:23:29 +00:00
|
|
|
import makeMutation from "@saleor/hooks/makeMutation";
|
2020-05-14 09:30:32 +00:00
|
|
|
import gql from "graphql-tag";
|
|
|
|
|
|
|
|
import {
|
|
|
|
productBulkDelete,
|
|
|
|
productBulkDeleteVariables
|
|
|
|
} from "./types/productBulkDelete";
|
|
|
|
import {
|
|
|
|
productBulkPublish,
|
|
|
|
productBulkPublishVariables
|
|
|
|
} from "./types/productBulkPublish";
|
2019-06-19 14:40:52 +00:00
|
|
|
import { ProductCreate, ProductCreateVariables } from "./types/ProductCreate";
|
|
|
|
import { ProductDelete, ProductDeleteVariables } from "./types/ProductDelete";
|
2020-07-30 09:54:16 +00:00
|
|
|
import { ProductExport, ProductExportVariables } from "./types/ProductExport";
|
2019-06-19 14:40:52 +00:00
|
|
|
import {
|
|
|
|
ProductImageCreate,
|
|
|
|
ProductImageCreateVariables
|
|
|
|
} from "./types/ProductImageCreate";
|
|
|
|
import {
|
|
|
|
ProductImageDelete,
|
|
|
|
ProductImageDeleteVariables
|
|
|
|
} from "./types/ProductImageDelete";
|
|
|
|
import {
|
|
|
|
ProductImageReorder,
|
|
|
|
ProductImageReorderVariables
|
|
|
|
} from "./types/ProductImageReorder";
|
|
|
|
import {
|
|
|
|
ProductImageUpdate,
|
|
|
|
ProductImageUpdateVariables
|
|
|
|
} from "./types/ProductImageUpdate";
|
2020-09-03 10:25:16 +00:00
|
|
|
import {
|
|
|
|
ProductSetAvailabilityForPurchase,
|
|
|
|
ProductSetAvailabilityForPurchaseVariables
|
|
|
|
} from "./types/ProductSetAvailabilityForPurchase";
|
2019-06-19 14:40:52 +00:00
|
|
|
import { ProductUpdate, ProductUpdateVariables } from "./types/ProductUpdate";
|
2020-05-14 09:30:32 +00:00
|
|
|
import {
|
|
|
|
ProductVariantBulkCreate,
|
|
|
|
ProductVariantBulkCreateVariables
|
|
|
|
} from "./types/ProductVariantBulkCreate";
|
|
|
|
import {
|
|
|
|
ProductVariantBulkDelete,
|
|
|
|
ProductVariantBulkDeleteVariables
|
|
|
|
} from "./types/ProductVariantBulkDelete";
|
2019-06-19 14:40:52 +00:00
|
|
|
import {
|
|
|
|
SimpleProductUpdate,
|
|
|
|
SimpleProductUpdateVariables
|
|
|
|
} from "./types/SimpleProductUpdate";
|
|
|
|
import { VariantCreate, VariantCreateVariables } from "./types/VariantCreate";
|
|
|
|
import { VariantDelete, VariantDeleteVariables } from "./types/VariantDelete";
|
|
|
|
import {
|
|
|
|
VariantImageAssign,
|
|
|
|
VariantImageAssignVariables
|
|
|
|
} from "./types/VariantImageAssign";
|
|
|
|
import {
|
|
|
|
VariantImageUnassign,
|
|
|
|
VariantImageUnassignVariables
|
|
|
|
} from "./types/VariantImageUnassign";
|
|
|
|
import { VariantUpdate, VariantUpdateVariables } from "./types/VariantUpdate";
|
|
|
|
|
|
|
|
export const productImageCreateMutation = gql`
|
2020-03-06 14:25:23 +00:00
|
|
|
${productErrorFragment}
|
2019-06-19 14:40:52 +00:00
|
|
|
${productFragmentDetails}
|
|
|
|
mutation ProductImageCreate($product: ID!, $image: Upload!, $alt: String) {
|
|
|
|
productImageCreate(input: { alt: $alt, image: $image, product: $product }) {
|
2020-03-06 14:25:23 +00:00
|
|
|
errors: productErrors {
|
|
|
|
...ProductErrorFragment
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
|
|
|
product {
|
|
|
|
...Product
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
2020-08-24 09:50:55 +00:00
|
|
|
export const useProductImageCreateMutation = makeMutation<
|
2019-06-19 14:40:52 +00:00
|
|
|
ProductImageCreate,
|
|
|
|
ProductImageCreateVariables
|
|
|
|
>(productImageCreateMutation);
|
|
|
|
|
|
|
|
export const productDeleteMutation = gql`
|
2020-03-06 14:25:23 +00:00
|
|
|
${productErrorFragment}
|
2019-06-19 14:40:52 +00:00
|
|
|
mutation ProductDelete($id: ID!) {
|
|
|
|
productDelete(id: $id) {
|
2020-03-06 14:25:23 +00:00
|
|
|
errors: productErrors {
|
|
|
|
...ProductErrorFragment
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
|
|
|
product {
|
|
|
|
id
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
2020-08-24 09:50:55 +00:00
|
|
|
export const useProductDeleteMutation = makeMutation<
|
2019-06-19 14:40:52 +00:00
|
|
|
ProductDelete,
|
|
|
|
ProductDeleteVariables
|
|
|
|
>(productDeleteMutation);
|
|
|
|
|
|
|
|
export const productImagesReorder = gql`
|
2020-03-06 14:25:23 +00:00
|
|
|
${productErrorFragment}
|
2019-06-19 14:40:52 +00:00
|
|
|
mutation ProductImageReorder($productId: ID!, $imagesIds: [ID]!) {
|
|
|
|
productImageReorder(productId: $productId, imagesIds: $imagesIds) {
|
2020-03-06 14:25:23 +00:00
|
|
|
errors: productErrors {
|
|
|
|
...ProductErrorFragment
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
|
|
|
product {
|
|
|
|
id
|
|
|
|
images {
|
|
|
|
id
|
|
|
|
alt
|
|
|
|
sortOrder
|
|
|
|
url
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
2020-08-24 09:50:55 +00:00
|
|
|
export const useProductImagesReorder = makeMutation<
|
2019-06-19 14:40:52 +00:00
|
|
|
ProductImageReorder,
|
|
|
|
ProductImageReorderVariables
|
|
|
|
>(productImagesReorder);
|
|
|
|
|
|
|
|
export const productUpdateMutation = gql`
|
2020-03-06 14:25:23 +00:00
|
|
|
${productErrorFragment}
|
2019-06-19 14:40:52 +00:00
|
|
|
${productFragmentDetails}
|
|
|
|
mutation ProductUpdate(
|
|
|
|
$id: ID!
|
|
|
|
$attributes: [AttributeValueInput]
|
|
|
|
$publicationDate: Date
|
|
|
|
$category: ID
|
|
|
|
$chargeTaxes: Boolean!
|
|
|
|
$collections: [ID]
|
|
|
|
$descriptionJson: JSONString
|
|
|
|
$isPublished: Boolean!
|
|
|
|
$name: String
|
2020-09-07 10:48:19 +00:00
|
|
|
$basePrice: PositiveDecimal
|
2019-08-09 11:14:35 +00:00
|
|
|
$seo: SeoInput
|
2020-09-03 10:25:16 +00:00
|
|
|
$visibleInListings: Boolean
|
2019-06-19 14:40:52 +00:00
|
|
|
) {
|
|
|
|
productUpdate(
|
|
|
|
id: $id
|
|
|
|
input: {
|
|
|
|
attributes: $attributes
|
|
|
|
publicationDate: $publicationDate
|
|
|
|
category: $category
|
|
|
|
chargeTaxes: $chargeTaxes
|
|
|
|
collections: $collections
|
|
|
|
descriptionJson: $descriptionJson
|
|
|
|
isPublished: $isPublished
|
|
|
|
name: $name
|
|
|
|
basePrice: $basePrice
|
2019-08-09 11:14:35 +00:00
|
|
|
seo: $seo
|
2020-09-03 10:25:16 +00:00
|
|
|
visibleInListings: $visibleInListings
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
|
|
|
) {
|
2020-03-06 14:25:23 +00:00
|
|
|
errors: productErrors {
|
|
|
|
...ProductErrorFragment
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
|
|
|
product {
|
|
|
|
...Product
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
2020-08-24 09:50:55 +00:00
|
|
|
export const useProductUpdateMutation = makeMutation<
|
2019-06-19 14:40:52 +00:00
|
|
|
ProductUpdate,
|
|
|
|
ProductUpdateVariables
|
|
|
|
>(productUpdateMutation);
|
|
|
|
|
|
|
|
export const simpleProductUpdateMutation = gql`
|
2020-03-24 21:38:26 +00:00
|
|
|
${bulkStockErrorFragment}
|
2020-03-06 14:25:23 +00:00
|
|
|
${productErrorFragment}
|
2019-06-19 14:40:52 +00:00
|
|
|
${productFragmentDetails}
|
2020-03-24 21:38:26 +00:00
|
|
|
${stockErrorFragment}
|
2019-06-19 14:40:52 +00:00
|
|
|
${fragmentVariant}
|
|
|
|
mutation SimpleProductUpdate(
|
|
|
|
$id: ID!
|
|
|
|
$attributes: [AttributeValueInput]
|
|
|
|
$publicationDate: Date
|
|
|
|
$category: ID
|
|
|
|
$chargeTaxes: Boolean!
|
|
|
|
$collections: [ID]
|
|
|
|
$descriptionJson: JSONString
|
|
|
|
$isPublished: Boolean!
|
|
|
|
$name: String
|
2020-09-07 10:48:19 +00:00
|
|
|
$basePrice: PositiveDecimal
|
2019-06-19 14:40:52 +00:00
|
|
|
$productVariantId: ID!
|
|
|
|
$productVariantInput: ProductVariantInput!
|
2019-08-09 11:14:35 +00:00
|
|
|
$seo: SeoInput
|
2020-03-24 21:38:26 +00:00
|
|
|
$addStocks: [StockInput!]!
|
|
|
|
$deleteStocks: [ID!]!
|
|
|
|
$updateStocks: [StockInput!]!
|
2020-07-13 16:51:05 +00:00
|
|
|
$weight: WeightScalar
|
2020-09-16 13:28:05 +00:00
|
|
|
$visibleInListings: Boolean
|
2019-06-19 14:40:52 +00:00
|
|
|
) {
|
|
|
|
productUpdate(
|
|
|
|
id: $id
|
|
|
|
input: {
|
|
|
|
attributes: $attributes
|
|
|
|
publicationDate: $publicationDate
|
|
|
|
category: $category
|
|
|
|
chargeTaxes: $chargeTaxes
|
|
|
|
collections: $collections
|
|
|
|
descriptionJson: $descriptionJson
|
|
|
|
isPublished: $isPublished
|
|
|
|
name: $name
|
2020-06-12 10:17:17 +00:00
|
|
|
basePrice: $basePrice
|
2019-08-09 11:14:35 +00:00
|
|
|
seo: $seo
|
2020-07-13 16:51:05 +00:00
|
|
|
weight: $weight
|
2020-09-16 13:28:05 +00:00
|
|
|
visibleInListings: $visibleInListings
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
|
|
|
) {
|
2020-03-06 14:25:23 +00:00
|
|
|
errors: productErrors {
|
|
|
|
...ProductErrorFragment
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
|
|
|
product {
|
|
|
|
...Product
|
|
|
|
}
|
|
|
|
}
|
|
|
|
productVariantUpdate(id: $productVariantId, input: $productVariantInput) {
|
2020-03-06 14:25:23 +00:00
|
|
|
errors: productErrors {
|
|
|
|
...ProductErrorFragment
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
|
|
|
productVariant {
|
|
|
|
...ProductVariant
|
|
|
|
}
|
|
|
|
}
|
2020-03-24 21:38:26 +00:00
|
|
|
productVariantStocksCreate(
|
|
|
|
stocks: $addStocks
|
|
|
|
variantId: $productVariantId
|
|
|
|
) {
|
|
|
|
errors: bulkStockErrors {
|
|
|
|
...BulkStockErrorFragment
|
|
|
|
}
|
|
|
|
productVariant {
|
|
|
|
...ProductVariant
|
|
|
|
}
|
|
|
|
}
|
|
|
|
productVariantStocksDelete(
|
|
|
|
warehouseIds: $deleteStocks
|
|
|
|
variantId: $productVariantId
|
|
|
|
) {
|
|
|
|
errors: stockErrors {
|
|
|
|
...StockErrorFragment
|
|
|
|
}
|
|
|
|
productVariant {
|
|
|
|
...ProductVariant
|
|
|
|
}
|
|
|
|
}
|
|
|
|
productVariantStocksUpdate(
|
|
|
|
stocks: $updateStocks
|
|
|
|
variantId: $productVariantId
|
|
|
|
) {
|
|
|
|
errors: bulkStockErrors {
|
|
|
|
...BulkStockErrorFragment
|
|
|
|
}
|
|
|
|
productVariant {
|
|
|
|
...ProductVariant
|
|
|
|
}
|
|
|
|
}
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
|
|
|
`;
|
2020-08-24 09:50:55 +00:00
|
|
|
export const useSimpleProductUpdateMutation = makeMutation<
|
2019-06-19 14:40:52 +00:00
|
|
|
SimpleProductUpdate,
|
|
|
|
SimpleProductUpdateVariables
|
|
|
|
>(simpleProductUpdateMutation);
|
|
|
|
|
|
|
|
export const productCreateMutation = gql`
|
2020-03-06 14:25:23 +00:00
|
|
|
${productErrorFragment}
|
2019-06-19 14:40:52 +00:00
|
|
|
${productFragmentDetails}
|
|
|
|
mutation ProductCreate(
|
|
|
|
$attributes: [AttributeValueInput]
|
|
|
|
$publicationDate: Date
|
|
|
|
$category: ID!
|
|
|
|
$chargeTaxes: Boolean!
|
|
|
|
$collections: [ID]
|
|
|
|
$descriptionJson: JSONString
|
|
|
|
$isPublished: Boolean!
|
|
|
|
$name: String!
|
2020-09-07 10:48:19 +00:00
|
|
|
$basePrice: PositiveDecimal
|
2019-06-19 14:40:52 +00:00
|
|
|
$productType: ID!
|
|
|
|
$sku: String
|
2019-08-09 11:14:35 +00:00
|
|
|
$seo: SeoInput
|
2020-03-25 13:06:14 +00:00
|
|
|
$stocks: [StockInput!]!
|
2020-03-27 11:06:11 +00:00
|
|
|
$trackInventory: Boolean!
|
2020-07-13 16:51:05 +00:00
|
|
|
$weight: WeightScalar
|
2020-09-03 10:25:16 +00:00
|
|
|
$visibleInListings: Boolean
|
2019-06-19 14:40:52 +00:00
|
|
|
) {
|
|
|
|
productCreate(
|
|
|
|
input: {
|
|
|
|
attributes: $attributes
|
|
|
|
publicationDate: $publicationDate
|
|
|
|
category: $category
|
|
|
|
chargeTaxes: $chargeTaxes
|
|
|
|
collections: $collections
|
|
|
|
descriptionJson: $descriptionJson
|
|
|
|
isPublished: $isPublished
|
|
|
|
name: $name
|
2020-06-12 10:17:17 +00:00
|
|
|
basePrice: $basePrice
|
2019-06-19 14:40:52 +00:00
|
|
|
productType: $productType
|
|
|
|
sku: $sku
|
2019-08-09 11:14:35 +00:00
|
|
|
seo: $seo
|
2020-03-25 13:06:14 +00:00
|
|
|
stocks: $stocks
|
2020-03-27 11:06:11 +00:00
|
|
|
trackInventory: $trackInventory
|
2020-07-13 16:51:05 +00:00
|
|
|
weight: $weight
|
2020-09-03 10:25:16 +00:00
|
|
|
visibleInListings: $visibleInListings
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
|
|
|
) {
|
2020-03-06 14:25:23 +00:00
|
|
|
errors: productErrors {
|
|
|
|
...ProductErrorFragment
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
|
|
|
product {
|
|
|
|
...Product
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
2020-08-24 09:50:55 +00:00
|
|
|
export const useProductCreateMutation = makeMutation<
|
2019-06-19 14:40:52 +00:00
|
|
|
ProductCreate,
|
|
|
|
ProductCreateVariables
|
|
|
|
>(productCreateMutation);
|
|
|
|
|
|
|
|
export const variantDeleteMutation = gql`
|
2020-03-06 14:25:23 +00:00
|
|
|
${productErrorFragment}
|
2019-06-19 14:40:52 +00:00
|
|
|
mutation VariantDelete($id: ID!) {
|
|
|
|
productVariantDelete(id: $id) {
|
2020-03-06 14:25:23 +00:00
|
|
|
errors: productErrors {
|
|
|
|
...ProductErrorFragment
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
|
|
|
productVariant {
|
|
|
|
id
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
2020-08-24 09:50:55 +00:00
|
|
|
export const useVariantDeleteMutation = makeMutation<
|
2019-06-19 14:40:52 +00:00
|
|
|
VariantDelete,
|
|
|
|
VariantDeleteVariables
|
|
|
|
>(variantDeleteMutation);
|
|
|
|
|
|
|
|
export const variantUpdateMutation = gql`
|
2020-03-27 10:40:34 +00:00
|
|
|
${bulkStockErrorFragment}
|
2019-06-19 14:40:52 +00:00
|
|
|
${fragmentVariant}
|
2020-03-06 14:25:23 +00:00
|
|
|
${productErrorFragment}
|
2019-06-19 14:40:52 +00:00
|
|
|
mutation VariantUpdate(
|
2020-05-04 15:29:06 +00:00
|
|
|
$addStocks: [StockInput!]!
|
|
|
|
$removeStocks: [ID!]!
|
2019-06-19 14:40:52 +00:00
|
|
|
$id: ID!
|
|
|
|
$attributes: [AttributeValueInput]
|
2020-09-07 10:48:19 +00:00
|
|
|
$costPrice: PositiveDecimal
|
|
|
|
$price: PositiveDecimal
|
2019-06-19 14:40:52 +00:00
|
|
|
$sku: String
|
|
|
|
$trackInventory: Boolean!
|
2020-03-27 10:40:34 +00:00
|
|
|
$stocks: [StockInput!]!
|
2020-07-13 16:51:05 +00:00
|
|
|
$weight: WeightScalar
|
2019-06-19 14:40:52 +00:00
|
|
|
) {
|
|
|
|
productVariantUpdate(
|
|
|
|
id: $id
|
|
|
|
input: {
|
|
|
|
attributes: $attributes
|
|
|
|
costPrice: $costPrice
|
2020-06-10 13:39:10 +00:00
|
|
|
price: $price
|
2019-06-19 14:40:52 +00:00
|
|
|
sku: $sku
|
|
|
|
trackInventory: $trackInventory
|
2020-07-13 16:51:05 +00:00
|
|
|
weight: $weight
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
|
|
|
) {
|
2020-03-06 14:25:23 +00:00
|
|
|
errors: productErrors {
|
|
|
|
...ProductErrorFragment
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
|
|
|
productVariant {
|
|
|
|
...ProductVariant
|
|
|
|
}
|
|
|
|
}
|
2020-03-27 10:40:34 +00:00
|
|
|
productVariantStocksUpdate(stocks: $stocks, variantId: $id) {
|
|
|
|
errors: bulkStockErrors {
|
|
|
|
...BulkStockErrorFragment
|
|
|
|
}
|
|
|
|
productVariant {
|
|
|
|
...ProductVariant
|
|
|
|
}
|
|
|
|
}
|
2020-05-04 15:29:06 +00:00
|
|
|
productVariantStocksCreate(stocks: $addStocks, variantId: $id) {
|
|
|
|
errors: bulkStockErrors {
|
|
|
|
...BulkStockErrorFragment
|
|
|
|
}
|
|
|
|
productVariant {
|
|
|
|
id
|
|
|
|
stocks {
|
|
|
|
...StockFragment
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
productVariantStocksDelete(warehouseIds: $removeStocks, variantId: $id) {
|
|
|
|
errors: stockErrors {
|
|
|
|
code
|
|
|
|
field
|
|
|
|
}
|
|
|
|
productVariant {
|
|
|
|
id
|
|
|
|
stocks {
|
|
|
|
...StockFragment
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
|
|
|
`;
|
2020-08-24 09:50:55 +00:00
|
|
|
export const useVariantUpdateMutation = makeMutation<
|
2019-06-19 14:40:52 +00:00
|
|
|
VariantUpdate,
|
|
|
|
VariantUpdateVariables
|
|
|
|
>(variantUpdateMutation);
|
|
|
|
|
|
|
|
export const variantCreateMutation = gql`
|
|
|
|
${fragmentVariant}
|
2020-03-06 14:25:23 +00:00
|
|
|
${productErrorFragment}
|
2019-09-19 10:13:48 +00:00
|
|
|
mutation VariantCreate($input: ProductVariantCreateInput!) {
|
|
|
|
productVariantCreate(input: $input) {
|
2020-03-06 14:25:23 +00:00
|
|
|
errors: productErrors {
|
|
|
|
...ProductErrorFragment
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
|
|
|
productVariant {
|
|
|
|
...ProductVariant
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
2020-08-24 09:50:55 +00:00
|
|
|
export const useVariantCreateMutation = makeMutation<
|
2019-06-19 14:40:52 +00:00
|
|
|
VariantCreate,
|
|
|
|
VariantCreateVariables
|
|
|
|
>(variantCreateMutation);
|
|
|
|
|
|
|
|
export const productImageDeleteMutation = gql`
|
2020-03-06 14:25:23 +00:00
|
|
|
${productErrorFragment}
|
2019-06-19 14:40:52 +00:00
|
|
|
mutation ProductImageDelete($id: ID!) {
|
|
|
|
productImageDelete(id: $id) {
|
2020-03-06 14:25:23 +00:00
|
|
|
errors: productErrors {
|
|
|
|
...ProductErrorFragment
|
|
|
|
}
|
2019-06-19 14:40:52 +00:00
|
|
|
product {
|
|
|
|
id
|
|
|
|
images {
|
|
|
|
id
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
2020-08-24 09:50:55 +00:00
|
|
|
export const useProductImageDeleteMutation = makeMutation<
|
2019-06-19 14:40:52 +00:00
|
|
|
ProductImageDelete,
|
|
|
|
ProductImageDeleteVariables
|
|
|
|
>(productImageDeleteMutation);
|
|
|
|
|
|
|
|
export const productImageUpdateMutation = gql`
|
2020-03-06 14:25:23 +00:00
|
|
|
${productErrorFragment}
|
2019-06-19 14:40:52 +00:00
|
|
|
${productFragmentDetails}
|
|
|
|
mutation ProductImageUpdate($id: ID!, $alt: String!) {
|
|
|
|
productImageUpdate(id: $id, input: { alt: $alt }) {
|
2020-03-06 14:25:23 +00:00
|
|
|
errors: productErrors {
|
|
|
|
...ProductErrorFragment
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
|
|
|
product {
|
|
|
|
...Product
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
2020-08-24 09:50:55 +00:00
|
|
|
export const useProductImageUpdateMutation = makeMutation<
|
2019-06-19 14:40:52 +00:00
|
|
|
ProductImageUpdate,
|
|
|
|
ProductImageUpdateVariables
|
|
|
|
>(productImageUpdateMutation);
|
|
|
|
|
|
|
|
export const variantImageAssignMutation = gql`
|
|
|
|
${fragmentVariant}
|
2020-03-06 14:25:23 +00:00
|
|
|
${productErrorFragment}
|
2019-06-19 14:40:52 +00:00
|
|
|
mutation VariantImageAssign($variantId: ID!, $imageId: ID!) {
|
|
|
|
variantImageAssign(variantId: $variantId, imageId: $imageId) {
|
2020-03-06 14:25:23 +00:00
|
|
|
errors: productErrors {
|
|
|
|
...ProductErrorFragment
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
|
|
|
productVariant {
|
|
|
|
...ProductVariant
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
2020-08-24 09:50:55 +00:00
|
|
|
export const useVariantImageAssignMutation = makeMutation<
|
2019-06-19 14:40:52 +00:00
|
|
|
VariantImageAssign,
|
|
|
|
VariantImageAssignVariables
|
|
|
|
>(variantImageAssignMutation);
|
|
|
|
|
|
|
|
export const variantImageUnassignMutation = gql`
|
|
|
|
${fragmentVariant}
|
2020-03-06 14:25:23 +00:00
|
|
|
${productErrorFragment}
|
2019-06-19 14:40:52 +00:00
|
|
|
mutation VariantImageUnassign($variantId: ID!, $imageId: ID!) {
|
|
|
|
variantImageUnassign(variantId: $variantId, imageId: $imageId) {
|
2020-03-06 14:25:23 +00:00
|
|
|
errors: productErrors {
|
|
|
|
...ProductErrorFragment
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
|
|
|
productVariant {
|
|
|
|
...ProductVariant
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
2020-08-24 09:50:55 +00:00
|
|
|
export const useVariantImageUnassignMutation = makeMutation<
|
2019-06-19 14:40:52 +00:00
|
|
|
VariantImageUnassign,
|
|
|
|
VariantImageUnassignVariables
|
|
|
|
>(variantImageUnassignMutation);
|
|
|
|
|
|
|
|
export const productBulkDeleteMutation = gql`
|
2020-03-06 14:25:23 +00:00
|
|
|
${productErrorFragment}
|
2019-06-19 14:40:52 +00:00
|
|
|
mutation productBulkDelete($ids: [ID!]!) {
|
|
|
|
productBulkDelete(ids: $ids) {
|
2020-03-06 14:25:23 +00:00
|
|
|
errors: productErrors {
|
|
|
|
...ProductErrorFragment
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
2020-08-24 09:50:55 +00:00
|
|
|
export const useProductBulkDeleteMutation = makeMutation<
|
2019-06-19 14:40:52 +00:00
|
|
|
productBulkDelete,
|
|
|
|
productBulkDeleteVariables
|
|
|
|
>(productBulkDeleteMutation);
|
|
|
|
|
|
|
|
export const productBulkPublishMutation = gql`
|
2020-03-06 14:25:23 +00:00
|
|
|
${productErrorFragment}
|
2019-06-19 14:40:52 +00:00
|
|
|
mutation productBulkPublish($ids: [ID!]!, $isPublished: Boolean!) {
|
|
|
|
productBulkPublish(ids: $ids, isPublished: $isPublished) {
|
2020-03-06 14:25:23 +00:00
|
|
|
errors: productErrors {
|
|
|
|
...ProductErrorFragment
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
2020-08-24 09:50:55 +00:00
|
|
|
export const useProductBulkPublishMutation = makeMutation<
|
2019-06-19 14:40:52 +00:00
|
|
|
productBulkPublish,
|
|
|
|
productBulkPublishVariables
|
|
|
|
>(productBulkPublishMutation);
|
|
|
|
|
2019-10-02 13:34:34 +00:00
|
|
|
export const ProductVariantBulkCreateMutation = gql`
|
2020-03-06 14:25:23 +00:00
|
|
|
${bulkProductErrorFragment}
|
2019-10-02 13:34:34 +00:00
|
|
|
mutation ProductVariantBulkCreate(
|
|
|
|
$id: ID!
|
|
|
|
$inputs: [ProductVariantBulkCreateInput]!
|
|
|
|
) {
|
|
|
|
productVariantBulkCreate(product: $id, variants: $inputs) {
|
2020-03-06 14:25:23 +00:00
|
|
|
errors: bulkProductErrors {
|
|
|
|
...BulkProductErrorFragment
|
2019-10-02 13:34:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
2020-04-01 16:28:47 +00:00
|
|
|
export const useProductVariantBulkCreateMutation = makeMutation<
|
2019-10-02 13:34:34 +00:00
|
|
|
ProductVariantBulkCreate,
|
|
|
|
ProductVariantBulkCreateVariables
|
|
|
|
>(ProductVariantBulkCreateMutation);
|
|
|
|
|
2019-06-19 14:40:52 +00:00
|
|
|
export const ProductVariantBulkDeleteMutation = gql`
|
2020-03-06 14:25:23 +00:00
|
|
|
${productErrorFragment}
|
2019-06-19 14:40:52 +00:00
|
|
|
mutation ProductVariantBulkDelete($ids: [ID!]!) {
|
|
|
|
productVariantBulkDelete(ids: $ids) {
|
2020-03-06 14:25:23 +00:00
|
|
|
errors: productErrors {
|
|
|
|
...ProductErrorFragment
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
2020-08-24 09:50:55 +00:00
|
|
|
export const useProductVariantBulkDeleteMutation = makeMutation<
|
2019-06-19 14:40:52 +00:00
|
|
|
ProductVariantBulkDelete,
|
|
|
|
ProductVariantBulkDeleteVariables
|
|
|
|
>(ProductVariantBulkDeleteMutation);
|
2020-07-30 09:54:16 +00:00
|
|
|
|
|
|
|
export const productExportMutation = gql`
|
|
|
|
${exportFileFragment}
|
|
|
|
${exportErrorFragment}
|
|
|
|
mutation ProductExport($input: ExportProductsInput!) {
|
|
|
|
exportProducts(input: $input) {
|
|
|
|
exportFile {
|
|
|
|
...ExportFileFragment
|
|
|
|
}
|
|
|
|
errors: exportErrors {
|
|
|
|
...ExportErrorFragment
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
export const useProductExport = makeMutation<
|
|
|
|
ProductExport,
|
|
|
|
ProductExportVariables
|
|
|
|
>(productExportMutation);
|
2020-09-03 10:25:16 +00:00
|
|
|
|
|
|
|
const productSetAvailabilityForPurchase = gql`
|
|
|
|
${productErrorFragment}
|
|
|
|
mutation ProductSetAvailabilityForPurchase(
|
|
|
|
$isAvailable: Boolean!
|
|
|
|
$productId: ID!
|
|
|
|
$startDate: Date
|
|
|
|
) {
|
|
|
|
productSetAvailabilityForPurchase(
|
|
|
|
isAvailable: $isAvailable
|
|
|
|
productId: $productId
|
|
|
|
startDate: $startDate
|
|
|
|
) {
|
2020-09-18 13:01:00 +00:00
|
|
|
product {
|
|
|
|
id
|
|
|
|
availableForPurchase
|
|
|
|
isAvailableForPurchase
|
|
|
|
}
|
2020-09-03 10:25:16 +00:00
|
|
|
errors: productErrors {
|
|
|
|
...ProductErrorFragment
|
|
|
|
message
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
export const useProductSetAvailabilityForPurchase = makeMutation<
|
|
|
|
ProductSetAvailabilityForPurchase,
|
|
|
|
ProductSetAvailabilityForPurchaseVariables
|
|
|
|
>(productSetAvailabilityForPurchase);
|