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` export const variantCreateMutation = gql`
${fragmentVariant} ${fragmentVariant}
mutation VariantCreate( mutation VariantCreate($input: ProductVariantCreateInput!) {
$attributes: [AttributeValueInput]! productVariantCreate(input: $input) {
$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
}
) {
errors { errors {
field field
message message

View file

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

View file

@ -139,11 +139,25 @@ export interface ProductDetails_product_variants {
stockQuantity: number; 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 { export interface ProductDetails_product_productType {
__typename: "ProductType"; __typename: "ProductType";
id: string; id: string;
name: string; name: string;
hasVariants: boolean; hasVariants: boolean;
variantAttributes: (ProductDetails_product_productType_variantAttributes | null)[] | null;
} }
export interface ProductDetails_product { export interface ProductDetails_product {

View file

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

View file

@ -614,6 +614,17 @@ export interface ProductTypeInput {
taxCode?: string | null; 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 { export interface ProductVariantInput {
attributes?: (AttributeValueInput | null)[] | null; attributes?: (AttributeValueInput | null)[] | null;
costPrice?: any | null; costPrice?: any | null;