Fix variant create query

This commit is contained in:
dominik-zeglen 2019-09-19 12:13:48 +02:00
parent b87b0dcb6c
commit 742523bac7
6 changed files with 39 additions and 28 deletions

View file

@ -319,26 +319,8 @@ export const TypedVariantUpdateMutation = TypedMutation<
export const variantCreateMutation = gql`
${fragmentVariant}
mutation VariantCreate(
$attributes: [AttributeValueInput]!
$costPrice: Decimal
$priceOverride: Decimal
$product: ID!
$sku: String
$quantity: Int
$trackInventory: Boolean!
) {
productVariantCreate(
input: {
attributes: $attributes
costPrice: $costPrice
priceOverride: $priceOverride
product: $product
sku: $sku
quantity: $quantity
trackInventory: $trackInventory
}
) {
mutation VariantCreate($input: ProductVariantCreateInput!) {
productVariantCreate(input: $input) {
errors {
field
message

View file

@ -260,6 +260,16 @@ const productDetailsQuery = gql`
query ProductDetails($id: ID!) {
product(id: $id) {
...Product
productType {
variantAttributes {
id
name
values {
id
name
}
}
}
}
}
`;

View file

@ -139,11 +139,25 @@ export interface ProductDetails_product_variants {
stockQuantity: number;
}
export interface ProductDetails_product_productType_variantAttributes_values {
__typename: "AttributeValue";
id: string;
name: string | null;
}
export interface ProductDetails_product_productType_variantAttributes {
__typename: "Attribute";
id: string;
name: string | null;
values: (ProductDetails_product_productType_variantAttributes_values | null)[] | null;
}
export interface ProductDetails_product_productType {
__typename: "ProductType";
id: string;
name: string;
hasVariants: boolean;
variantAttributes: (ProductDetails_product_productType_variantAttributes | null)[] | null;
}
export interface ProductDetails_product {

View file

@ -2,7 +2,7 @@
/* eslint-disable */
// This file was automatically generated and should not be edited.
import { AttributeValueInput } from "./../../types/globalTypes";
import { ProductVariantCreateInput } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: VariantCreate
@ -122,11 +122,5 @@ export interface VariantCreate {
}
export interface VariantCreateVariables {
attributes: (AttributeValueInput | null)[];
costPrice?: any | null;
priceOverride?: any | null;
product: string;
sku?: string | null;
quantity?: number | null;
trackInventory: boolean;
input: ProductVariantCreateInput;
}

View file

@ -614,6 +614,17 @@ export interface ProductTypeInput {
taxCode?: string | null;
}
export interface ProductVariantCreateInput {
attributes: (AttributeValueInput | null)[];
costPrice?: any | null;
priceOverride?: any | null;
sku?: string | null;
quantity?: number | null;
trackInventory?: boolean | null;
weight?: any | null;
product: string;
}
export interface ProductVariantInput {
attributes?: (AttributeValueInput | null)[] | null;
costPrice?: any | null;