|
|
@@ -1,23 +1,33 @@
|
|
|
+/* tslint:disable:no-non-null-assertion */
|
|
|
import gql from 'graphql-tag';
|
|
|
import path from 'path';
|
|
|
|
|
|
+import { FACET_VALUE_FRAGMENT } from '../../admin-ui/src/app/data/definitions/facet-definitions';
|
|
|
import {
|
|
|
CREATE_COLLECTION,
|
|
|
GET_ASSET_LIST,
|
|
|
GET_COLLECTION,
|
|
|
MOVE_COLLECTION,
|
|
|
UPDATE_COLLECTION,
|
|
|
+ UPDATE_PRODUCT,
|
|
|
+ UPDATE_PRODUCT_VARIANTS,
|
|
|
} from '../../admin-ui/src/app/data/definitions/product-definitions';
|
|
|
import {
|
|
|
Collection,
|
|
|
ConfigArgType,
|
|
|
CreateCollection,
|
|
|
+ CreateCollectionInput,
|
|
|
+ FacetValue,
|
|
|
GetAssetList,
|
|
|
GetCollection,
|
|
|
+ GetProductWithVariants,
|
|
|
LanguageCode,
|
|
|
MoveCollection,
|
|
|
+ ProductWithVariants,
|
|
|
SortOrder,
|
|
|
UpdateCollection,
|
|
|
+ UpdateProduct,
|
|
|
+ UpdateProductVariants,
|
|
|
} from '../../shared/generated-types';
|
|
|
import { ROOT_CATEGORY_NAME } from '../../shared/shared-constants';
|
|
|
import { facetValueCollectionFilter } from '../src/config/collection/default-collection-filters';
|
|
|
@@ -27,19 +37,18 @@ import { TestAdminClient } from './test-client';
|
|
|
import { TestServer } from './test-server';
|
|
|
import { assertThrowsWithMessage } from './test-utils';
|
|
|
|
|
|
-// TODO: test collection without filters has no ProductVariants
|
|
|
-
|
|
|
describe('Collection resolver', () => {
|
|
|
const client = new TestAdminClient();
|
|
|
const server = new TestServer();
|
|
|
let assets: GetAssetList.Items[];
|
|
|
- let electronicsCategory: Collection.Fragment;
|
|
|
- let computersCategory: Collection.Fragment;
|
|
|
- let appleCategory: Collection.Fragment;
|
|
|
+ let facetValues: FacetValue.Fragment[];
|
|
|
+ let electronicsCollection: Collection.Fragment;
|
|
|
+ let computersCollection: Collection.Fragment;
|
|
|
+ let pearCollection: Collection.Fragment;
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
const token = await server.init({
|
|
|
- productsCsvPath: path.join(__dirname, 'fixtures/e2e-products-full.csv'),
|
|
|
+ productsCsvPath: path.join(__dirname, 'fixtures/e2e-products-collections.csv'),
|
|
|
customerCount: 1,
|
|
|
});
|
|
|
await client.init();
|
|
|
@@ -51,6 +60,11 @@ describe('Collection resolver', () => {
|
|
|
},
|
|
|
});
|
|
|
assets = assetsResult.assets.items;
|
|
|
+ const facetValuesResult = await client.query(GET_FACET_VALUES);
|
|
|
+ facetValues = facetValuesResult.facets.items.reduce(
|
|
|
+ (values: any, facet: any) => [...values, ...facet.values],
|
|
|
+ [],
|
|
|
+ );
|
|
|
}, TEST_SETUP_TIMEOUT_MS);
|
|
|
|
|
|
afterAll(async () => {
|
|
|
@@ -71,7 +85,7 @@ describe('Collection resolver', () => {
|
|
|
arguments: [
|
|
|
{
|
|
|
name: 'facetValueIds',
|
|
|
- value: `["T_1"]`,
|
|
|
+ value: `["${getFacetValueId('electronics')}"]`,
|
|
|
type: ConfigArgType.FACET_VALUE_IDS,
|
|
|
},
|
|
|
],
|
|
|
@@ -84,9 +98,9 @@ describe('Collection resolver', () => {
|
|
|
},
|
|
|
);
|
|
|
|
|
|
- electronicsCategory = result.createCollection;
|
|
|
- expect(electronicsCategory).toMatchSnapshot();
|
|
|
- expect(electronicsCategory.parent.name).toBe(ROOT_CATEGORY_NAME);
|
|
|
+ electronicsCollection = result.createCollection;
|
|
|
+ expect(electronicsCollection).toMatchSnapshot();
|
|
|
+ expect(electronicsCollection.parent.name).toBe(ROOT_CATEGORY_NAME);
|
|
|
});
|
|
|
|
|
|
it('creates a nested category', async () => {
|
|
|
@@ -94,7 +108,7 @@ describe('Collection resolver', () => {
|
|
|
CREATE_COLLECTION,
|
|
|
{
|
|
|
input: {
|
|
|
- parentId: electronicsCategory.id,
|
|
|
+ parentId: electronicsCollection.id,
|
|
|
translations: [{ languageCode: LanguageCode.en, name: 'Computers', description: '' }],
|
|
|
filters: [
|
|
|
{
|
|
|
@@ -102,7 +116,7 @@ describe('Collection resolver', () => {
|
|
|
arguments: [
|
|
|
{
|
|
|
name: 'facetValueIds',
|
|
|
- value: `["T_2"]`,
|
|
|
+ value: `["${getFacetValueId('computers')}"]`,
|
|
|
type: ConfigArgType.FACET_VALUE_IDS,
|
|
|
},
|
|
|
],
|
|
|
@@ -111,8 +125,8 @@ describe('Collection resolver', () => {
|
|
|
},
|
|
|
},
|
|
|
);
|
|
|
- computersCategory = result.createCollection;
|
|
|
- expect(computersCategory.parent.name).toBe(electronicsCategory.name);
|
|
|
+ computersCollection = result.createCollection;
|
|
|
+ expect(computersCollection.parent.name).toBe(electronicsCollection.name);
|
|
|
});
|
|
|
|
|
|
it('creates a 2nd level nested category', async () => {
|
|
|
@@ -120,26 +134,37 @@ describe('Collection resolver', () => {
|
|
|
CREATE_COLLECTION,
|
|
|
{
|
|
|
input: {
|
|
|
- parentId: computersCategory.id,
|
|
|
- translations: [{ languageCode: LanguageCode.en, name: 'Apple', description: '' }],
|
|
|
- filters: [],
|
|
|
+ parentId: computersCollection.id,
|
|
|
+ translations: [{ languageCode: LanguageCode.en, name: 'Pear', description: '' }],
|
|
|
+ filters: [
|
|
|
+ {
|
|
|
+ code: facetValueCollectionFilter.code,
|
|
|
+ arguments: [
|
|
|
+ {
|
|
|
+ name: 'facetValueIds',
|
|
|
+ value: `["${getFacetValueId('pear')}"]`,
|
|
|
+ type: ConfigArgType.FACET_VALUE_IDS,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ ],
|
|
|
},
|
|
|
},
|
|
|
);
|
|
|
- appleCategory = result.createCollection;
|
|
|
- expect(appleCategory.parent.name).toBe(computersCategory.name);
|
|
|
+ pearCollection = result.createCollection;
|
|
|
+ expect(pearCollection.parent.name).toBe(computersCollection.name);
|
|
|
});
|
|
|
});
|
|
|
|
|
|
it('collection query', async () => {
|
|
|
const result = await client.query<GetCollection.Query, GetCollection.Variables>(GET_COLLECTION, {
|
|
|
- id: computersCategory.id,
|
|
|
+ id: computersCollection.id,
|
|
|
});
|
|
|
if (!result.collection) {
|
|
|
fail(`did not return the category`);
|
|
|
return;
|
|
|
}
|
|
|
- expect(result.collection.id).toBe(computersCategory.id);
|
|
|
+ expect(result.collection.id).toBe(computersCollection.id);
|
|
|
});
|
|
|
|
|
|
it('updateCollection', async () => {
|
|
|
@@ -147,10 +172,9 @@ describe('Collection resolver', () => {
|
|
|
UPDATE_COLLECTION,
|
|
|
{
|
|
|
input: {
|
|
|
- id: appleCategory.id,
|
|
|
+ id: pearCollection.id,
|
|
|
assetIds: [assets[1].id],
|
|
|
featuredAssetId: assets[1].id,
|
|
|
- filters: [],
|
|
|
translations: [{ languageCode: LanguageCode.en, description: 'Apple stuff ' }],
|
|
|
},
|
|
|
},
|
|
|
@@ -165,56 +189,67 @@ describe('Collection resolver', () => {
|
|
|
MOVE_COLLECTION,
|
|
|
{
|
|
|
input: {
|
|
|
- categoryId: appleCategory.id,
|
|
|
- parentId: electronicsCategory.id,
|
|
|
+ collectionId: pearCollection.id,
|
|
|
+ parentId: electronicsCollection.id,
|
|
|
index: 0,
|
|
|
},
|
|
|
},
|
|
|
);
|
|
|
|
|
|
- expect(result.moveCollection.parent.id).toBe(electronicsCategory.id);
|
|
|
+ expect(result.moveCollection.parent.id).toBe(electronicsCollection.id);
|
|
|
+
|
|
|
+ const positions = await getChildrenOf(electronicsCollection.id);
|
|
|
+ expect(positions.map(i => i.id)).toEqual([pearCollection.id, computersCollection.id]);
|
|
|
+ });
|
|
|
|
|
|
- const positions = await getChildrenOf(electronicsCategory.id);
|
|
|
- expect(positions.map(i => i.id)).toEqual([appleCategory.id, computersCategory.id]);
|
|
|
+ it('re-evaluates Collection contents on move', async () => {
|
|
|
+ const result = await client.query(GET_COLLECTION_PRODUCT_VARIANTS, { id: pearCollection.id });
|
|
|
+ expect(result.collection.productVariants.items.map((i: any) => i.name)).toEqual([
|
|
|
+ 'Laptop 13 inch 8GB',
|
|
|
+ 'Laptop 15 inch 8GB',
|
|
|
+ 'Laptop 13 inch 16GB',
|
|
|
+ 'Laptop 15 inch 16GB',
|
|
|
+ 'Instant Camera',
|
|
|
+ ]);
|
|
|
});
|
|
|
|
|
|
it('alters the position in the current parent', async () => {
|
|
|
await client.query<MoveCollection.Mutation, MoveCollection.Variables>(MOVE_COLLECTION, {
|
|
|
input: {
|
|
|
- categoryId: appleCategory.id,
|
|
|
- parentId: electronicsCategory.id,
|
|
|
+ collectionId: pearCollection.id,
|
|
|
+ parentId: electronicsCollection.id,
|
|
|
index: 1,
|
|
|
},
|
|
|
});
|
|
|
|
|
|
- const afterResult = await getChildrenOf(electronicsCategory.id);
|
|
|
- expect(afterResult.map(i => i.id)).toEqual([computersCategory.id, appleCategory.id]);
|
|
|
+ const afterResult = await getChildrenOf(electronicsCollection.id);
|
|
|
+ expect(afterResult.map(i => i.id)).toEqual([computersCollection.id, pearCollection.id]);
|
|
|
});
|
|
|
|
|
|
it('corrects an out-of-bounds negative index value', async () => {
|
|
|
await client.query<MoveCollection.Mutation, MoveCollection.Variables>(MOVE_COLLECTION, {
|
|
|
input: {
|
|
|
- categoryId: appleCategory.id,
|
|
|
- parentId: electronicsCategory.id,
|
|
|
+ collectionId: pearCollection.id,
|
|
|
+ parentId: electronicsCollection.id,
|
|
|
index: -3,
|
|
|
},
|
|
|
});
|
|
|
|
|
|
- const afterResult = await getChildrenOf(electronicsCategory.id);
|
|
|
- expect(afterResult.map(i => i.id)).toEqual([appleCategory.id, computersCategory.id]);
|
|
|
+ const afterResult = await getChildrenOf(electronicsCollection.id);
|
|
|
+ expect(afterResult.map(i => i.id)).toEqual([pearCollection.id, computersCollection.id]);
|
|
|
});
|
|
|
|
|
|
it('corrects an out-of-bounds positive index value', async () => {
|
|
|
await client.query<MoveCollection.Mutation, MoveCollection.Variables>(MOVE_COLLECTION, {
|
|
|
input: {
|
|
|
- categoryId: appleCategory.id,
|
|
|
- parentId: electronicsCategory.id,
|
|
|
+ collectionId: pearCollection.id,
|
|
|
+ parentId: electronicsCollection.id,
|
|
|
index: 10,
|
|
|
},
|
|
|
});
|
|
|
|
|
|
- const afterResult = await getChildrenOf(electronicsCategory.id);
|
|
|
- expect(afterResult.map(i => i.id)).toEqual([computersCategory.id, appleCategory.id]);
|
|
|
+ const afterResult = await getChildrenOf(electronicsCollection.id);
|
|
|
+ expect(afterResult.map(i => i.id)).toEqual([computersCollection.id, pearCollection.id]);
|
|
|
});
|
|
|
|
|
|
it(
|
|
|
@@ -223,8 +258,8 @@ describe('Collection resolver', () => {
|
|
|
() =>
|
|
|
client.query<MoveCollection.Mutation, MoveCollection.Variables>(MOVE_COLLECTION, {
|
|
|
input: {
|
|
|
- categoryId: appleCategory.id,
|
|
|
- parentId: appleCategory.id,
|
|
|
+ collectionId: pearCollection.id,
|
|
|
+ parentId: pearCollection.id,
|
|
|
index: 0,
|
|
|
},
|
|
|
}),
|
|
|
@@ -238,8 +273,8 @@ describe('Collection resolver', () => {
|
|
|
() =>
|
|
|
client.query<MoveCollection.Mutation, MoveCollection.Variables>(MOVE_COLLECTION, {
|
|
|
input: {
|
|
|
- categoryId: appleCategory.id,
|
|
|
- parentId: appleCategory.id,
|
|
|
+ collectionId: pearCollection.id,
|
|
|
+ parentId: pearCollection.id,
|
|
|
index: 0,
|
|
|
},
|
|
|
}),
|
|
|
@@ -249,42 +284,224 @@ describe('Collection resolver', () => {
|
|
|
|
|
|
async function getChildrenOf(parentId: string): Promise<Array<{ name: string; id: string }>> {
|
|
|
const result = await client.query(GET_COLLECTIONS);
|
|
|
- return result.collections.items.filter(i => i.parent.id === parentId);
|
|
|
+ return result.collections.items.filter((i: any) => i.parent.id === parentId);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
describe('filters', () => {
|
|
|
- it('facetValue filter', async () => {
|
|
|
- const result = await client.query(GET_COLLECTION_PRODUCT_VARIANTS, {
|
|
|
- id: electronicsCategory.id,
|
|
|
+ it('Collection with no filters has no productVariants', async () => {
|
|
|
+ const result = await client.query(CREATE_COLLECTION_SELECT_VARIANTS, {
|
|
|
+ input: {
|
|
|
+ translations: [{ languageCode: LanguageCode.en, name: 'Empty', description: '' }],
|
|
|
+ filters: [],
|
|
|
+ } as CreateCollectionInput,
|
|
|
+ });
|
|
|
+ expect(result.createCollection.productVariants.totalItems).toBe(0);
|
|
|
+ });
|
|
|
+
|
|
|
+ describe('facetValue filter', () => {
|
|
|
+ it('electronics', async () => {
|
|
|
+ const result = await client.query(GET_COLLECTION_PRODUCT_VARIANTS, {
|
|
|
+ id: electronicsCollection.id,
|
|
|
+ });
|
|
|
+ expect(result.collection.productVariants.items.map(i => i.name)).toEqual([
|
|
|
+ 'Laptop 13 inch 8GB',
|
|
|
+ 'Laptop 15 inch 8GB',
|
|
|
+ 'Laptop 13 inch 16GB',
|
|
|
+ 'Laptop 15 inch 16GB',
|
|
|
+ 'Curvy Monitor 24 inch',
|
|
|
+ 'Curvy Monitor 27 inch',
|
|
|
+ 'Gaming PC i7-8700 240GB SSD',
|
|
|
+ 'Gaming PC R7-2700 240GB SSD',
|
|
|
+ 'Gaming PC i7-8700 120GB SSD',
|
|
|
+ 'Gaming PC R7-2700 120GB SSD',
|
|
|
+ 'Hard Drive 1TB',
|
|
|
+ 'Hard Drive 2TB',
|
|
|
+ 'Hard Drive 3TB',
|
|
|
+ 'Hard Drive 4TB',
|
|
|
+ 'Hard Drive 6TB',
|
|
|
+ 'Clacky Keyboard',
|
|
|
+ 'USB Cable',
|
|
|
+ 'Instant Camera',
|
|
|
+ 'Camera Lens',
|
|
|
+ 'Tripod',
|
|
|
+ 'SLR Camera',
|
|
|
+ ]);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('computers', async () => {
|
|
|
+ const result = await client.query(GET_COLLECTION_PRODUCT_VARIANTS, {
|
|
|
+ id: computersCollection.id,
|
|
|
+ });
|
|
|
+ expect(result.collection.productVariants.items.map(i => i.name)).toEqual([
|
|
|
+ 'Laptop 13 inch 8GB',
|
|
|
+ 'Laptop 15 inch 8GB',
|
|
|
+ 'Laptop 13 inch 16GB',
|
|
|
+ 'Laptop 15 inch 16GB',
|
|
|
+ 'Curvy Monitor 24 inch',
|
|
|
+ 'Curvy Monitor 27 inch',
|
|
|
+ 'Gaming PC i7-8700 240GB SSD',
|
|
|
+ 'Gaming PC R7-2700 240GB SSD',
|
|
|
+ 'Gaming PC i7-8700 120GB SSD',
|
|
|
+ 'Gaming PC R7-2700 120GB SSD',
|
|
|
+ 'Hard Drive 1TB',
|
|
|
+ 'Hard Drive 2TB',
|
|
|
+ 'Hard Drive 3TB',
|
|
|
+ 'Hard Drive 4TB',
|
|
|
+ 'Hard Drive 6TB',
|
|
|
+ 'Clacky Keyboard',
|
|
|
+ 'USB Cable',
|
|
|
+ ]);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('photo and pear', async () => {
|
|
|
+ const result = await client.query(CREATE_COLLECTION_SELECT_VARIANTS, {
|
|
|
+ input: {
|
|
|
+ translations: [
|
|
|
+ { languageCode: LanguageCode.en, name: 'Photo Pear', description: '' },
|
|
|
+ ],
|
|
|
+ filters: [
|
|
|
+ {
|
|
|
+ code: facetValueCollectionFilter.code,
|
|
|
+ arguments: [
|
|
|
+ {
|
|
|
+ name: 'facetValueIds',
|
|
|
+ value: `["${getFacetValueId('pear')}", "${getFacetValueId(
|
|
|
+ 'photo',
|
|
|
+ )}"]`,
|
|
|
+ type: ConfigArgType.FACET_VALUE_IDS,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ } as CreateCollectionInput,
|
|
|
+ });
|
|
|
+ expect(result.createCollection.productVariants.items.map(i => i.name)).toEqual([
|
|
|
+ 'Instant Camera',
|
|
|
+ ]);
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ describe('re-evaluation of contents on changes', () => {
|
|
|
+ let products: ProductWithVariants.Fragment[];
|
|
|
+
|
|
|
+ beforeAll(async () => {
|
|
|
+ const result = await client.query(gql`
|
|
|
+ query {
|
|
|
+ products {
|
|
|
+ items {
|
|
|
+ id
|
|
|
+ name
|
|
|
+ variants {
|
|
|
+ id
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ `);
|
|
|
+ products = result.products.items;
|
|
|
+ });
|
|
|
+
|
|
|
+ it('updates contents when Product is updated', async () => {
|
|
|
+ await client.query<UpdateProduct.Mutation, UpdateProduct.Variables>(UPDATE_PRODUCT, {
|
|
|
+ input: {
|
|
|
+ id: products[1].id,
|
|
|
+ facetValueIds: [
|
|
|
+ getFacetValueId('electronics'),
|
|
|
+ getFacetValueId('computers'),
|
|
|
+ getFacetValueId('pear'),
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
+ const result = await client.query(GET_COLLECTION_PRODUCT_VARIANTS, { id: pearCollection.id });
|
|
|
+ expect(result.collection.productVariants.items.map((i: any) => i.name)).toEqual([
|
|
|
+ 'Laptop 13 inch 8GB',
|
|
|
+ 'Laptop 15 inch 8GB',
|
|
|
+ 'Laptop 13 inch 16GB',
|
|
|
+ 'Laptop 15 inch 16GB',
|
|
|
+ 'Curvy Monitor 24 inch',
|
|
|
+ 'Curvy Monitor 27 inch',
|
|
|
+ 'Instant Camera',
|
|
|
+ ]);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('updates contents when ProductVariant is updated', async () => {
|
|
|
+ const gamingPcFirstVariant = products.find(p => p.name === 'Gaming PC')!.variants[0];
|
|
|
+ await client.query<UpdateProductVariants.Mutation, UpdateProductVariants.Variables>(
|
|
|
+ UPDATE_PRODUCT_VARIANTS,
|
|
|
+ {
|
|
|
+ input: [
|
|
|
+ {
|
|
|
+ id: gamingPcFirstVariant.id,
|
|
|
+ facetValueIds: [getFacetValueId('pear')],
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ );
|
|
|
+ const result = await client.query(GET_COLLECTION_PRODUCT_VARIANTS, { id: pearCollection.id });
|
|
|
+ expect(result.collection.productVariants.items.map((i: any) => i.name)).toEqual([
|
|
|
+ 'Laptop 13 inch 8GB',
|
|
|
+ 'Laptop 15 inch 8GB',
|
|
|
+ 'Laptop 13 inch 16GB',
|
|
|
+ 'Laptop 15 inch 16GB',
|
|
|
+ 'Curvy Monitor 24 inch',
|
|
|
+ 'Curvy Monitor 27 inch',
|
|
|
+ 'Gaming PC i7-8700 240GB SSD',
|
|
|
+ 'Instant Camera',
|
|
|
+ ]);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('correctly filters when ProductVariant and Product both have matching FacetValue', async () => {
|
|
|
+ const gamingPcFirstVariant = products.find(p => p.name === 'Gaming PC')!.variants[0];
|
|
|
+ await client.query<UpdateProductVariants.Mutation, UpdateProductVariants.Variables>(
|
|
|
+ UPDATE_PRODUCT_VARIANTS,
|
|
|
+ {
|
|
|
+ input: [
|
|
|
+ {
|
|
|
+ id: gamingPcFirstVariant.id,
|
|
|
+ facetValueIds: [getFacetValueId('electronics'), getFacetValueId('pear')],
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ );
|
|
|
+ const result = await client.query(GET_COLLECTION_PRODUCT_VARIANTS, { id: pearCollection.id });
|
|
|
+ expect(result.collection.productVariants.items.map((i: any) => i.name)).toEqual([
|
|
|
+ 'Laptop 13 inch 8GB',
|
|
|
+ 'Laptop 15 inch 8GB',
|
|
|
+ 'Laptop 13 inch 16GB',
|
|
|
+ 'Laptop 15 inch 16GB',
|
|
|
+ 'Curvy Monitor 24 inch',
|
|
|
+ 'Curvy Monitor 27 inch',
|
|
|
+ 'Gaming PC i7-8700 240GB SSD',
|
|
|
+ 'Instant Camera',
|
|
|
+ ]);
|
|
|
});
|
|
|
- expect(result.collection.productVariants.items.map(i => i.name)).toEqual([
|
|
|
- 'Laptop 13 inch 8GB',
|
|
|
- 'Laptop 15 inch 8GB',
|
|
|
- 'Laptop 13 inch 16GB',
|
|
|
- 'Laptop 15 inch 16GB',
|
|
|
- 'Curvy Monitor 24 inch',
|
|
|
- 'Curvy Monitor 27 inch',
|
|
|
- 'Gaming PC i7-8700 240GB SSD',
|
|
|
- 'Gaming PC R7-2700 240GB SSD',
|
|
|
- 'Gaming PC i7-8700 120GB SSD',
|
|
|
- 'Gaming PC R7-2700 120GB SSD',
|
|
|
- 'Hard Drive 1TB',
|
|
|
- 'Hard Drive 2TB',
|
|
|
- 'Hard Drive 3TB',
|
|
|
- 'Hard Drive 4TB',
|
|
|
- 'Hard Drive 6TB',
|
|
|
- 'Clacky Keyboard',
|
|
|
- 'USB Cable',
|
|
|
- 'Instant Camera',
|
|
|
- 'Camera Lens',
|
|
|
- 'Tripod',
|
|
|
- 'SLR Camera',
|
|
|
- ]);
|
|
|
});
|
|
|
});
|
|
|
+
|
|
|
+ function getFacetValueId(code: string): string {
|
|
|
+ const match = facetValues.find(fv => fv.code === code);
|
|
|
+ if (!match) {
|
|
|
+ throw new Error(`Could not find a FacetValue with the code "${code}"`);
|
|
|
+ }
|
|
|
+ return match.id;
|
|
|
+ }
|
|
|
});
|
|
|
|
|
|
+const GET_FACET_VALUES = gql`
|
|
|
+ query {
|
|
|
+ facets {
|
|
|
+ items {
|
|
|
+ values {
|
|
|
+ ...FacetValue
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ${FACET_VALUE_FRAGMENT}
|
|
|
+`;
|
|
|
+
|
|
|
const GET_COLLECTIONS = gql`
|
|
|
query GetCollections {
|
|
|
collections(languageCode: en) {
|
|
|
@@ -316,3 +533,16 @@ const GET_COLLECTION_PRODUCT_VARIANTS = gql`
|
|
|
}
|
|
|
}
|
|
|
`;
|
|
|
+
|
|
|
+const CREATE_COLLECTION_SELECT_VARIANTS = gql`
|
|
|
+ mutation($input: CreateCollectionInput!) {
|
|
|
+ createCollection(input: $input) {
|
|
|
+ productVariants {
|
|
|
+ items {
|
|
|
+ name
|
|
|
+ }
|
|
|
+ totalItems
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+`;
|