Przeglądaj źródła

feat(core): Update codegen errors plugin to use object inputs

BREAKING CHANGE: The internal ErrorResult classes now take all constructors arguments
as a single input object.

feat(core): Update codegen errors plugin to use object inputs

BREAKING CHANGE: The internal ErrorResult classes now take all constructors arguments
as a single input object.
Michael Bromley 3 lat temu
rodzic
commit
6b9b2a4fb6
89 zmienionych plików z 6323 dodań i 5928 usunięć
  1. 0 5
      packages/admin-ui/src/lib/core/src/common/generated-types.ts
  2. 23 17
      packages/asset-server-plugin/e2e/asset-server-plugin.e2e-spec.ts
  3. 0 5
      packages/asset-server-plugin/e2e/graphql/generated-e2e-asset-server-plugin-types.ts
  4. 1 1
      packages/asset-server-plugin/package.json
  5. 0 2
      packages/common/src/generated-shop-types.ts
  6. 0 5
      packages/common/src/generated-types.ts
  7. 81 89
      packages/core/e2e/administrator.e2e-spec.ts
  8. 108 94
      packages/core/e2e/asset-channel.e2e-spec.ts
  9. 143 132
      packages/core/e2e/asset.e2e-spec.ts
  10. 35 39
      packages/core/e2e/auth.e2e-spec.ts
  11. 77 66
      packages/core/e2e/authentication-strategy.e2e-spec.ts
  12. 109 117
      packages/core/e2e/channel.e2e-spec.ts
  13. 387 374
      packages/core/e2e/collection.e2e-spec.ts
  14. 6 5
      packages/core/e2e/configurable-operation.e2e-spec.ts
  15. 38 42
      packages/core/e2e/country.e2e-spec.ts
  16. 1 1
      packages/core/e2e/custom-field-relations.e2e-spec.ts
  17. 10 7
      packages/core/e2e/custom-permissions.e2e-spec.ts
  18. 145 126
      packages/core/e2e/customer-channel.e2e-spec.ts
  19. 71 80
      packages/core/e2e/customer-group.e2e-spec.ts
  20. 179 162
      packages/core/e2e/customer.e2e-spec.ts
  21. 10 6
      packages/core/e2e/default-search-plugin-uuids.e2e-spec.ts
  22. 276 266
      packages/core/e2e/default-search-plugin.e2e-spec.ts
  23. 21 17
      packages/core/e2e/entity-hydrator.e2e-spec.ts
  24. 2 2
      packages/core/e2e/entity-uuid-strategy.e2e-spec.ts
  25. 279 269
      packages/core/e2e/facet.e2e-spec.ts
  26. 1 1
      packages/core/e2e/fixtures/test-plugins/with-job-queue.ts
  27. 42 42
      packages/core/e2e/fulfillment-process.e2e-spec.ts
  28. 9 8
      packages/core/e2e/global-settings.e2e-spec.ts
  29. 12 5
      packages/core/e2e/graphql/generated-e2e-admin-types.ts
  30. 0 2
      packages/core/e2e/graphql/generated-e2e-shop-types.ts
  31. 17 12
      packages/core/e2e/graphql/shared-definitions.ts
  32. 14 5
      packages/core/e2e/job-queue.e2e-spec.ts
  33. 53 54
      packages/core/e2e/localization.e2e-spec.ts
  34. 87 75
      packages/core/e2e/order-changed-price-handling.e2e-spec.ts
  35. 89 94
      packages/core/e2e/order-channel.e2e-spec.ts
  36. 45 48
      packages/core/e2e/order-fulfillment.e2e-spec.ts
  37. 9 3
      packages/core/e2e/order-item-price-calculation-strategy.e2e-spec.ts
  38. 15 11
      packages/core/e2e/order-merge.e2e-spec.ts
  39. 387 349
      packages/core/e2e/order-modification.e2e-spec.ts
  40. 129 101
      packages/core/e2e/order-process.e2e-spec.ts
  41. 218 211
      packages/core/e2e/order-promotion.e2e-spec.ts
  42. 82 67
      packages/core/e2e/order-taxes.e2e-spec.ts
  43. 310 270
      packages/core/e2e/order.e2e-spec.ts
  44. 38 43
      packages/core/e2e/parallel-transactions.e2e-spec.ts
  45. 106 113
      packages/core/e2e/payment-method.e2e-spec.ts
  46. 79 66
      packages/core/e2e/payment-process.e2e-spec.ts
  47. 108 99
      packages/core/e2e/product-channel.e2e-spec.ts
  48. 14 20
      packages/core/e2e/product-option.e2e-spec.ts
  49. 326 349
      packages/core/e2e/product.e2e-spec.ts
  50. 71 81
      packages/core/e2e/promotion.e2e-spec.ts
  51. 139 104
      packages/core/e2e/role.e2e-spec.ts
  52. 10 6
      packages/core/e2e/session-management.e2e-spec.ts
  53. 119 126
      packages/core/e2e/shipping-method-eligibility.e2e-spec.ts
  54. 23 30
      packages/core/e2e/shipping-method.e2e-spec.ts
  55. 260 251
      packages/core/e2e/shop-auth.e2e-spec.ts
  56. 136 147
      packages/core/e2e/shop-catalog.e2e-spec.ts
  57. 92 89
      packages/core/e2e/shop-customer.e2e-spec.ts
  58. 219 236
      packages/core/e2e/shop-order.e2e-spec.ts
  59. 341 322
      packages/core/e2e/stock-control.e2e-spec.ts
  60. 19 6
      packages/core/e2e/tag.e2e-spec.ts
  61. 35 35
      packages/core/e2e/tax-category.e2e-spec.ts
  62. 33 36
      packages/core/e2e/tax-rate.e2e-spec.ts
  63. 9 9
      packages/core/e2e/utils/await-running-jobs.ts
  64. 23 23
      packages/core/e2e/utils/test-order-utils.ts
  65. 65 48
      packages/core/e2e/zone.e2e-spec.ts
  66. 4 4
      packages/core/src/api/resolvers/admin/global-settings.resolver.ts
  67. 1 1
      packages/core/src/api/resolvers/base/base-auth.resolver.ts
  68. 96 32
      packages/core/src/common/error/generated-graphql-admin-errors.ts
  69. 59 16
      packages/core/src/common/error/generated-graphql-shop-errors.ts
  70. 4 4
      packages/core/src/service/helpers/order-modifier/order-modifier.ts
  71. 1 1
      packages/core/src/service/services/asset.service.ts
  72. 3 3
      packages/core/src/service/services/auth.service.ts
  73. 3 3
      packages/core/src/service/services/channel.service.ts
  74. 2 2
      packages/core/src/service/services/fulfillment.service.ts
  75. 17 17
      packages/core/src/service/services/order.service.ts
  76. 10 4
      packages/core/src/service/services/payment.service.ts
  77. 4 1
      packages/core/src/service/services/product.service.ts
  78. 3 3
      packages/core/src/service/services/promotion.service.ts
  79. 2 2
      packages/core/src/service/services/user.service.ts
  80. 43 29
      packages/elasticsearch-plugin/e2e/e2e-helpers.ts
  81. 9 6
      packages/elasticsearch-plugin/e2e/elasticsearch-plugin-uuid.e2e-spec.ts
  82. 236 238
      packages/elasticsearch-plugin/e2e/elasticsearch-plugin.e2e-spec.ts
  83. 0 5
      packages/elasticsearch-plugin/e2e/graphql/generated-e2e-elasticsearch-plugin-types.ts
  84. 0 5
      packages/payments-plugin/e2e/graphql/generated-admin-types.ts
  85. 0 2
      packages/payments-plugin/e2e/graphql/generated-shop-types.ts
  86. 24 15
      packages/payments-plugin/e2e/mollie-payment.e2e-spec.ts
  87. 0 0
      schema-admin.json
  88. 0 0
      schema-shop.json
  89. 16 9
      scripts/codegen/plugins/graphql-errors-plugin.ts

+ 0 - 5
packages/admin-ui/src/lib/core/src/common/generated-types.ts

@@ -3220,12 +3220,10 @@ export type OrderAddress = {
 export type OrderFilterParameter = {
   active?: InputMaybe<BooleanOperators>;
   code?: InputMaybe<StringOperators>;
-  couponCodes?: InputMaybe<StringOperators>;
   createdAt?: InputMaybe<DateOperators>;
   currencyCode?: InputMaybe<StringOperators>;
   customerLastName?: InputMaybe<StringOperators>;
   id?: InputMaybe<IdOperators>;
-  nextStates?: InputMaybe<StringOperators>;
   orderPlacedAt?: InputMaybe<DateOperators>;
   shipping?: InputMaybe<NumberOperators>;
   shippingWithTax?: InputMaybe<NumberOperators>;
@@ -3397,11 +3395,9 @@ export type OrderProcessState = {
 
 export type OrderSortParameter = {
   code?: InputMaybe<SortOrder>;
-  couponCodes?: InputMaybe<SortOrder>;
   createdAt?: InputMaybe<SortOrder>;
   customerLastName?: InputMaybe<SortOrder>;
   id?: InputMaybe<SortOrder>;
-  nextStates?: InputMaybe<SortOrder>;
   orderPlacedAt?: InputMaybe<SortOrder>;
   shipping?: InputMaybe<SortOrder>;
   shippingWithTax?: InputMaybe<SortOrder>;
@@ -4496,7 +4492,6 @@ export type RoleFilterParameter = {
   createdAt?: InputMaybe<DateOperators>;
   description?: InputMaybe<StringOperators>;
   id?: InputMaybe<IdOperators>;
-  permissions?: InputMaybe<StringOperators>;
   updatedAt?: InputMaybe<DateOperators>;
 };
 

+ 23 - 17
packages/asset-server-plugin/e2e/asset-server-plugin.e2e-spec.ts

@@ -1,5 +1,6 @@
 /* tslint:disable:no-non-null-assertion */
 import { DefaultLogger, LogLevel, mergeConfig } from '@vendure/core';
+import { AssetFragment } from '@vendure/core/e2e/graphql/generated-e2e-admin-types';
 import { createTestEnvironment } from '@vendure/testing';
 import fs from 'fs-extra';
 import gql from 'graphql-tag';
@@ -10,13 +11,18 @@ import { initialData } from '../../../e2e-common/e2e-initial-data';
 import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
 import { AssetServerPlugin } from '../src/plugin';
 
-import { CreateAssets, DeleteAsset, DeletionResult } from './graphql/generated-e2e-asset-server-plugin-types';
+import {
+    CreateAssetsMutation,
+    DeleteAssetMutation,
+    DeleteAssetMutationVariables,
+    DeletionResult,
+} from './graphql/generated-e2e-asset-server-plugin-types';
 
 const TEST_ASSET_DIR = 'test-assets';
 const IMAGE_BASENAME = 'derick-david-409858-unsplash';
 
 describe('AssetServerPlugin', () => {
-    let asset: CreateAssets.CreateAssets;
+    let asset: AssetFragment;
     const sourceFilePath = path.join(__dirname, TEST_ASSET_DIR, `source/b6/${IMAGE_BASENAME}.jpg`);
     const previewFilePath = path.join(__dirname, TEST_ASSET_DIR, `preview/71/${IMAGE_BASENAME}__preview.jpg`);
 
@@ -51,7 +57,7 @@ describe('AssetServerPlugin', () => {
 
     it('names the Asset correctly', async () => {
         const filesToUpload = [path.join(__dirname, `fixtures/assets/${IMAGE_BASENAME}.jpg`)];
-        const { createAssets }: CreateAssets.Mutation = await adminClient.fileUploadMutation({
+        const { createAssets }: CreateAssetsMutation = await adminClient.fileUploadMutation({
             mutation: CREATE_ASSETS,
             filePaths: filesToUpload,
             mapVariables: filePaths => ({
@@ -59,8 +65,8 @@ describe('AssetServerPlugin', () => {
             }),
         });
 
-        expect(createAssets[0].name).toBe(`${IMAGE_BASENAME}.jpg`);
-        asset = createAssets[0];
+        asset = createAssets[0] as AssetFragment;
+        expect(asset.name).toBe(`${IMAGE_BASENAME}.jpg`);
     });
 
     it('creates the expected asset files', async () => {
@@ -87,7 +93,7 @@ describe('AssetServerPlugin', () => {
     it('can handle non-latin filenames', async () => {
         const FILE_NAME_ZH = '白飯';
         const filesToUpload = [path.join(__dirname, `fixtures/assets/${FILE_NAME_ZH}.jpg`)];
-        const { createAssets }: CreateAssets.Mutation = await adminClient.fileUploadMutation({
+        const { createAssets }: { createAssets: AssetFragment[] } = await adminClient.fileUploadMutation({
             mutation: CREATE_ASSETS,
             filePaths: filesToUpload,
             mapVariables: filePaths => ({
@@ -190,15 +196,15 @@ describe('AssetServerPlugin', () => {
 
     describe('deletion', () => {
         it('deleting Asset deletes binary file', async () => {
-            const { deleteAsset } = await adminClient.query<DeleteAsset.Mutation, DeleteAsset.Variables>(
-                DELETE_ASSET,
-                {
-                    input: {
-                        assetId: asset.id,
-                        force: true,
-                    },
+            const { deleteAsset } = await adminClient.query<
+                DeleteAssetMutation,
+                DeleteAssetMutationVariables
+            >(DELETE_ASSET, {
+                input: {
+                    assetId: asset.id,
+                    force: true,
                 },
-            );
+            });
 
             expect(deleteAsset.result).toBe(DeletionResult.DELETED);
 
@@ -208,7 +214,7 @@ describe('AssetServerPlugin', () => {
     });
 
     describe('MIME type detection', () => {
-        let testImages: CreateAssets.CreateAssets[] = [];
+        let testImages: AssetFragment[] = [];
 
         async function testMimeTypeOfAssetWithExt(ext: string, expectedMimeType: string) {
             const testImage = testImages.find(i => i.source.endsWith(ext))!;
@@ -222,7 +228,7 @@ describe('AssetServerPlugin', () => {
             const formats = ['gif', 'jpg', 'png', 'svg', 'tiff', 'webp'];
 
             const filesToUpload = formats.map(ext => path.join(__dirname, `fixtures/assets/test.${ext}`));
-            const { createAssets }: CreateAssets.Mutation = await adminClient.fileUploadMutation({
+            const { createAssets }: CreateAssetsMutation = await adminClient.fileUploadMutation({
                 mutation: CREATE_ASSETS,
                 filePaths: filesToUpload,
                 mapVariables: filePaths => ({
@@ -230,7 +236,7 @@ describe('AssetServerPlugin', () => {
                 }),
             });
 
-            testImages = createAssets;
+            testImages = createAssets as AssetFragment[];
         });
 
         it('gif', async () => {

+ 0 - 5
packages/asset-server-plugin/e2e/graphql/generated-e2e-asset-server-plugin-types.ts

@@ -3001,12 +3001,10 @@ export type OrderAddress = {
 export type OrderFilterParameter = {
     active?: InputMaybe<BooleanOperators>;
     code?: InputMaybe<StringOperators>;
-    couponCodes?: InputMaybe<StringOperators>;
     createdAt?: InputMaybe<DateOperators>;
     currencyCode?: InputMaybe<StringOperators>;
     customerLastName?: InputMaybe<StringOperators>;
     id?: InputMaybe<IdOperators>;
-    nextStates?: InputMaybe<StringOperators>;
     orderPlacedAt?: InputMaybe<DateOperators>;
     shipping?: InputMaybe<NumberOperators>;
     shippingWithTax?: InputMaybe<NumberOperators>;
@@ -3171,11 +3169,9 @@ export type OrderProcessState = {
 
 export type OrderSortParameter = {
     code?: InputMaybe<SortOrder>;
-    couponCodes?: InputMaybe<SortOrder>;
     createdAt?: InputMaybe<SortOrder>;
     customerLastName?: InputMaybe<SortOrder>;
     id?: InputMaybe<SortOrder>;
-    nextStates?: InputMaybe<SortOrder>;
     orderPlacedAt?: InputMaybe<SortOrder>;
     shipping?: InputMaybe<SortOrder>;
     shippingWithTax?: InputMaybe<SortOrder>;
@@ -4197,7 +4193,6 @@ export type RoleFilterParameter = {
     createdAt?: InputMaybe<DateOperators>;
     description?: InputMaybe<StringOperators>;
     id?: InputMaybe<IdOperators>;
-    permissions?: InputMaybe<StringOperators>;
     updatedAt?: InputMaybe<DateOperators>;
 };
 

+ 1 - 1
packages/asset-server-plugin/package.json

@@ -28,7 +28,7 @@
     "@vendure/core": "^1.4.7",
     "aws-sdk": "^2.856.0",
     "express": "^4.17.1",
-    "node-fetch": "^3.2.0",
+    "node-fetch": "^2.6.7",
     "rimraf": "^3.0.2",
     "typescript": "4.5.5"
   },

+ 0 - 2
packages/common/src/generated-shop-types.ts

@@ -1908,7 +1908,6 @@ export type OrderAddress = {
 export type OrderFilterParameter = {
     active?: InputMaybe<BooleanOperators>;
     code?: InputMaybe<StringOperators>;
-    couponCodes?: InputMaybe<StringOperators>;
     createdAt?: InputMaybe<DateOperators>;
     currencyCode?: InputMaybe<StringOperators>;
     id?: InputMaybe<IdOperators>;
@@ -2065,7 +2064,6 @@ export type OrderPaymentStateError = ErrorResult & {
 
 export type OrderSortParameter = {
     code?: InputMaybe<SortOrder>;
-    couponCodes?: InputMaybe<SortOrder>;
     createdAt?: InputMaybe<SortOrder>;
     id?: InputMaybe<SortOrder>;
     orderPlacedAt?: InputMaybe<SortOrder>;

+ 0 - 5
packages/common/src/generated-types.ts

@@ -3157,12 +3157,10 @@ export type OrderAddress = {
 export type OrderFilterParameter = {
   active?: InputMaybe<BooleanOperators>;
   code?: InputMaybe<StringOperators>;
-  couponCodes?: InputMaybe<StringOperators>;
   createdAt?: InputMaybe<DateOperators>;
   currencyCode?: InputMaybe<StringOperators>;
   customerLastName?: InputMaybe<StringOperators>;
   id?: InputMaybe<IdOperators>;
-  nextStates?: InputMaybe<StringOperators>;
   orderPlacedAt?: InputMaybe<DateOperators>;
   shipping?: InputMaybe<NumberOperators>;
   shippingWithTax?: InputMaybe<NumberOperators>;
@@ -3334,11 +3332,9 @@ export type OrderProcessState = {
 
 export type OrderSortParameter = {
   code?: InputMaybe<SortOrder>;
-  couponCodes?: InputMaybe<SortOrder>;
   createdAt?: InputMaybe<SortOrder>;
   customerLastName?: InputMaybe<SortOrder>;
   id?: InputMaybe<SortOrder>;
-  nextStates?: InputMaybe<SortOrder>;
   orderPlacedAt?: InputMaybe<SortOrder>;
   shipping?: InputMaybe<SortOrder>;
   shippingWithTax?: InputMaybe<SortOrder>;
@@ -4429,7 +4425,6 @@ export type RoleFilterParameter = {
   createdAt?: InputMaybe<DateOperators>;
   description?: InputMaybe<StringOperators>;
   id?: InputMaybe<IdOperators>;
-  permissions?: InputMaybe<StringOperators>;
   updatedAt?: InputMaybe<DateOperators>;
 };
 

+ 81 - 89
packages/core/e2e/administrator.e2e-spec.ts

@@ -8,23 +8,14 @@ import { initialData } from '../../../e2e-common/e2e-initial-data';
 import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
 
 import { ADMINISTRATOR_FRAGMENT } from './graphql/fragments';
-import {
-    ActiveAdministrator,
-    Administrator,
-    CreateAdministrator,
-    DeleteAdministrator,
-    DeletionResult,
-    GetAdministrator,
-    GetAdministrators,
-    UpdateActiveAdministrator,
-    UpdateAdministrator,
-} from './graphql/generated-e2e-admin-types';
+import * as Codegen from './graphql/generated-e2e-admin-types';
+import { AdministratorFragment, DeletionResult } from './graphql/generated-e2e-admin-types';
 import { CREATE_ADMINISTRATOR } from './graphql/shared-definitions';
 import { assertThrowsWithMessage } from './utils/assert-throws-with-message';
 
 describe('Administrator resolver', () => {
     const { server, adminClient } = createTestEnvironment(testConfig());
-    let createdAdmin: Administrator.Fragment;
+    let createdAdmin: AdministratorFragment;
 
     beforeAll(async () => {
         await server.init({
@@ -40,68 +31,69 @@ describe('Administrator resolver', () => {
     });
 
     it('administrators', async () => {
-        const result = await adminClient.query<GetAdministrators.Query, GetAdministrators.Variables>(
-            GET_ADMINISTRATORS,
-        );
+        const result = await adminClient.query<
+            Codegen.GetAdministratorsQuery,
+            Codegen.GetAdministratorsQueryVariables
+        >(GET_ADMINISTRATORS);
         expect(result.administrators.items.length).toBe(1);
         expect(result.administrators.totalItems).toBe(1);
     });
 
     it('createAdministrator', async () => {
-        const result = await adminClient.query<CreateAdministrator.Mutation, CreateAdministrator.Variables>(
-            CREATE_ADMINISTRATOR,
-            {
-                input: {
-                    emailAddress: 'test@test.com',
-                    firstName: 'First',
-                    lastName: 'Last',
-                    password: 'password',
-                    roleIds: ['1'],
-                },
+        const result = await adminClient.query<
+            Codegen.CreateAdministratorMutation,
+            Codegen.CreateAdministratorMutationVariables
+        >(CREATE_ADMINISTRATOR, {
+            input: {
+                emailAddress: 'test@test.com',
+                firstName: 'First',
+                lastName: 'Last',
+                password: 'password',
+                roleIds: ['1'],
             },
-        );
+        });
 
         createdAdmin = result.createAdministrator;
         expect(createdAdmin).toMatchSnapshot();
     });
 
     it('administrator', async () => {
-        const result = await adminClient.query<GetAdministrator.Query, GetAdministrator.Variables>(
-            GET_ADMINISTRATOR,
-            {
-                id: createdAdmin.id,
-            },
-        );
+        const result = await adminClient.query<
+            Codegen.GetAdministratorQuery,
+            Codegen.GetAdministratorQueryVariables
+        >(GET_ADMINISTRATOR, {
+            id: createdAdmin.id,
+        });
         expect(result.administrator).toEqual(createdAdmin);
     });
 
     it('updateAdministrator', async () => {
-        const result = await adminClient.query<UpdateAdministrator.Mutation, UpdateAdministrator.Variables>(
-            UPDATE_ADMINISTRATOR,
-            {
-                input: {
-                    id: createdAdmin.id,
-                    emailAddress: 'new-email',
-                    firstName: 'new first',
-                    lastName: 'new last',
-                    password: 'new password',
-                    roleIds: ['2'],
-                },
+        const result = await adminClient.query<
+            Codegen.UpdateAdministratorMutation,
+            Codegen.UpdateAdministratorMutationVariables
+        >(UPDATE_ADMINISTRATOR, {
+            input: {
+                id: createdAdmin.id,
+                emailAddress: 'new-email',
+                firstName: 'new first',
+                lastName: 'new last',
+                password: 'new password',
+                roleIds: ['2'],
             },
-        );
+        });
         expect(result.updateAdministrator).toMatchSnapshot();
     });
 
     it('updateAdministrator works with partial input', async () => {
-        const result = await adminClient.query<UpdateAdministrator.Mutation, UpdateAdministrator.Variables>(
-            UPDATE_ADMINISTRATOR,
-            {
-                input: {
-                    id: createdAdmin.id,
-                    emailAddress: 'newest-email',
-                },
+        const result = await adminClient.query<
+            Codegen.UpdateAdministratorMutation,
+            Codegen.UpdateAdministratorMutationVariables
+        >(UPDATE_ADMINISTRATOR, {
+            input: {
+                id: createdAdmin.id,
+                emailAddress: 'newest-email',
             },
-        );
+        });
         expect(result.updateAdministrator.emailAddress).toBe('newest-email');
         expect(result.updateAdministrator.firstName).toBe('new first');
         expect(result.updateAdministrator.lastName).toBe('new last');
@@ -111,33 +103,33 @@ describe('Administrator resolver', () => {
         'updateAdministrator throws with invalid roleId',
         assertThrowsWithMessage(
             () =>
-                adminClient.query<UpdateAdministrator.Mutation, UpdateAdministrator.Variables>(
-                    UPDATE_ADMINISTRATOR,
-                    {
-                        input: {
-                            id: createdAdmin.id,
-                            emailAddress: 'new-email',
-                            firstName: 'new first',
-                            lastName: 'new last',
-                            password: 'new password',
-                            roleIds: ['999'],
-                        },
+                adminClient.query<
+                    Codegen.UpdateAdministratorMutation,
+                    Codegen.UpdateAdministratorMutationVariables
+                >(UPDATE_ADMINISTRATOR, {
+                    input: {
+                        id: createdAdmin.id,
+                        emailAddress: 'new-email',
+                        firstName: 'new first',
+                        lastName: 'new last',
+                        password: 'new password',
+                        roleIds: ['999'],
                     },
-                ),
+                }),
             `No Role with the id '999' could be found`,
         ),
     );
 
     it('deleteAdministrator', async () => {
         const { administrators: before } = await adminClient.query<
-            GetAdministrators.Query,
-            GetAdministrators.Variables
+            Codegen.GetAdministratorsQuery,
+            Codegen.GetAdministratorsQueryVariables
         >(GET_ADMINISTRATORS);
         expect(before.totalItems).toBe(2);
 
         const { deleteAdministrator } = await adminClient.query<
-            DeleteAdministrator.Mutation,
-            DeleteAdministrator.Variables
+            Codegen.DeleteAdministratorMutation,
+            Codegen.DeleteAdministratorMutationVariables
         >(DELETE_ADMINISTRATOR, {
             id: createdAdmin.id,
         });
@@ -145,24 +137,24 @@ describe('Administrator resolver', () => {
         expect(deleteAdministrator.result).toBe(DeletionResult.DELETED);
 
         const { administrators: after } = await adminClient.query<
-            GetAdministrators.Query,
-            GetAdministrators.Variables
+            Codegen.GetAdministratorsQuery,
+            Codegen.GetAdministratorsQueryVariables
         >(GET_ADMINISTRATORS);
         expect(after.totalItems).toBe(1);
     });
 
     it('cannot delete sole SuperAdmin', async () => {
         const { administrators: before } = await adminClient.query<
-            GetAdministrators.Query,
-            GetAdministrators.Variables
+            Codegen.GetAdministratorsQuery,
+            Codegen.GetAdministratorsQueryVariables
         >(GET_ADMINISTRATORS);
         expect(before.totalItems).toBe(1);
         expect(before.items[0].emailAddress).toBe('superadmin');
 
         try {
             const { deleteAdministrator } = await adminClient.query<
-                DeleteAdministrator.Mutation,
-                DeleteAdministrator.Variables
+                Codegen.DeleteAdministratorMutation,
+                Codegen.DeleteAdministratorMutationVariables
             >(DELETE_ADMINISTRATOR, {
                 id: before.items[0].id,
             });
@@ -172,8 +164,8 @@ describe('Administrator resolver', () => {
         }
 
         const { administrators: after } = await adminClient.query<
-            GetAdministrators.Query,
-            GetAdministrators.Variables
+            Codegen.GetAdministratorsQuery,
+            Codegen.GetAdministratorsQueryVariables
         >(GET_ADMINISTRATORS);
         expect(after.totalItems).toBe(1);
     });
@@ -182,8 +174,8 @@ describe('Administrator resolver', () => {
         'cannot remove SuperAdmin role from sole SuperAdmin',
         assertThrowsWithMessage(async () => {
             const result = await adminClient.query<
-                UpdateAdministrator.Mutation,
-                UpdateAdministrator.Variables
+                Codegen.UpdateAdministratorMutation,
+                Codegen.UpdateAdministratorMutationVariables
             >(UPDATE_ADMINISTRATOR, {
                 input: {
                     id: 'T_1',
@@ -194,12 +186,12 @@ describe('Administrator resolver', () => {
     );
 
     it('cannot query a deleted Administrator', async () => {
-        const { administrator } = await adminClient.query<GetAdministrator.Query, GetAdministrator.Variables>(
-            GET_ADMINISTRATOR,
-            {
-                id: createdAdmin.id,
-            },
-        );
+        const { administrator } = await adminClient.query<
+            Codegen.GetAdministratorQuery,
+            Codegen.GetAdministratorQueryVariables
+        >(GET_ADMINISTRATOR, {
+            id: createdAdmin.id,
+        });
 
         expect(administrator).toBeNull();
     });
@@ -207,14 +199,14 @@ describe('Administrator resolver', () => {
     it('activeAdministrator', async () => {
         await adminClient.asAnonymousUser();
 
-        const { activeAdministrator: result1 } = await adminClient.query<ActiveAdministrator.Query>(
+        const { activeAdministrator: result1 } = await adminClient.query<Codegen.ActiveAdministratorQuery>(
             GET_ACTIVE_ADMINISTRATOR,
         );
         expect(result1).toBeNull();
 
         await adminClient.asSuperAdmin();
 
-        const { activeAdministrator: result2 } = await adminClient.query<ActiveAdministrator.Query>(
+        const { activeAdministrator: result2 } = await adminClient.query<Codegen.ActiveAdministratorQuery>(
             GET_ACTIVE_ADMINISTRATOR,
         );
         expect(result2?.emailAddress).toBe(SUPER_ADMIN_USER_IDENTIFIER);
@@ -222,8 +214,8 @@ describe('Administrator resolver', () => {
 
     it('updateActiveAdministrator', async () => {
         const { updateActiveAdministrator } = await adminClient.query<
-            UpdateActiveAdministrator.Mutation,
-            UpdateActiveAdministrator.Variables
+            Codegen.UpdateActiveAdministratorMutation,
+            Codegen.UpdateActiveAdministratorMutationVariables
         >(UPDATE_ACTIVE_ADMINISTRATOR, {
             input: {
                 firstName: 'Thomas',
@@ -235,7 +227,7 @@ describe('Administrator resolver', () => {
         expect(updateActiveAdministrator.firstName).toBe('Thomas');
         expect(updateActiveAdministrator.lastName).toBe('Anderson');
 
-        const { activeAdministrator } = await adminClient.query<ActiveAdministrator.Query>(
+        const { activeAdministrator } = await adminClient.query<Codegen.ActiveAdministratorQuery>(
             GET_ACTIVE_ADMINISTRATOR,
         );
 

+ 108 - 94
packages/core/e2e/asset-channel.e2e-spec.ts

@@ -8,19 +8,9 @@ import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-conf
 import { DefaultLogger, LogLevel } from '../src/config';
 
 import { ASSET_FRAGMENT } from './graphql/fragments';
-import {
-    AssignAssetsToChannel,
-    AssignProductsToChannel,
-    CreateAssets,
-    CreateChannel,
-    CurrencyCode,
-    DeleteAsset,
-    DeletionResult,
-    GetAsset,
-    GetProductWithVariants,
-    LanguageCode,
-    UpdateProduct,
-} from './graphql/generated-e2e-admin-types';
+import { CurrencyCode, LanguageCode } from './graphql/generated-e2e-admin-types';
+import * as Codegen from './graphql/generated-e2e-admin-types';
+import { DeletionResult } from './graphql/generated-e2e-shop-types';
 import {
     ASSIGN_PRODUCT_TO_CHANNEL,
     CREATE_ASSETS,
@@ -45,20 +35,20 @@ beforeAll(async () => {
         customerCount: 1,
     });
     await adminClient.asSuperAdmin();
-    const { createChannel } = await adminClient.query<CreateChannel.Mutation, CreateChannel.Variables>(
-        CREATE_CHANNEL,
-        {
-            input: {
-                code: 'second-channel',
-                token: SECOND_CHANNEL_TOKEN,
-                defaultLanguageCode: LanguageCode.en,
-                currencyCode: CurrencyCode.GBP,
-                pricesIncludeTax: true,
-                defaultShippingZoneId: 'T_1',
-                defaultTaxZoneId: 'T_1',
-            },
+    const { createChannel } = await adminClient.query<
+        Codegen.CreateChannelMutation,
+        Codegen.CreateChannelMutationVariables
+    >(CREATE_CHANNEL, {
+        input: {
+            code: 'second-channel',
+            token: SECOND_CHANNEL_TOKEN,
+            defaultLanguageCode: LanguageCode.en,
+            currencyCode: CurrencyCode.GBP,
+            pricesIncludeTax: true,
+            defaultShippingZoneId: 'T_1',
+            defaultTaxZoneId: 'T_1',
         },
-    );
+    });
     channel2Id = createChannel.id;
 }, TEST_SETUP_TIMEOUT_MS);
 
@@ -69,7 +59,7 @@ afterAll(async () => {
 describe('ChannelAware Assets', () => {
     it('Create asset in default channel', async () => {
         const filesToUpload = [path.join(__dirname, 'fixtures/assets/pps2.jpg')];
-        const { createAssets }: CreateAssets.Mutation = await adminClient.fileUploadMutation({
+        const { createAssets }: Codegen.CreateAssetsMutation = await adminClient.fileUploadMutation({
             mutation: CREATE_ASSETS,
             filePaths: filesToUpload,
             mapVariables: filePaths => ({
@@ -83,25 +73,31 @@ describe('ChannelAware Assets', () => {
     });
 
     it('Get asset from default channel', async () => {
-        const { asset } = await adminClient.query<GetAsset.Query, GetAsset.Variables>(GET_ASSET, {
-            id: createdAssetId,
-        });
+        const { asset } = await adminClient.query<Codegen.GetAssetQuery, Codegen.GetAssetQueryVariables>(
+            GET_ASSET,
+            {
+                id: createdAssetId,
+            },
+        );
         expect(asset?.id).toEqual(createdAssetId);
     });
 
     it('Asset is not in channel2', async () => {
         await adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
-        const { asset } = await adminClient.query<GetAsset.Query, GetAsset.Variables>(GET_ASSET, {
-            id: createdAssetId,
-        });
+        const { asset } = await adminClient.query<Codegen.GetAssetQuery, Codegen.GetAssetQueryVariables>(
+            GET_ASSET,
+            {
+                id: createdAssetId,
+            },
+        );
         expect(asset).toBe(null);
     });
 
     it('Add asset to channel2', async () => {
         await adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
         const { assignAssetsToChannel: assets } = await adminClient.query<
-            AssignAssetsToChannel.Mutation,
-            AssignAssetsToChannel.Variables
+            Codegen.AssignAssetsToChannelMutation,
+            Codegen.AssignAssetsToChannelMutationVariables
         >(ASSIGN_ASSET_TO_CHANNEL, {
             input: {
                 assetIds: [createdAssetId],
@@ -113,37 +109,43 @@ describe('ChannelAware Assets', () => {
 
     it('Get asset from channel2', async () => {
         await adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
-        const { asset } = await adminClient.query<GetAsset.Query, GetAsset.Variables>(GET_ASSET, {
-            id: createdAssetId,
-        });
+        const { asset } = await adminClient.query<Codegen.GetAssetQuery, Codegen.GetAssetQueryVariables>(
+            GET_ASSET,
+            {
+                id: createdAssetId,
+            },
+        );
         expect(asset?.id).toBe(createdAssetId);
     });
 
     it('Delete asset from channel2', async () => {
-        const { deleteAsset } = await adminClient.query<DeleteAsset.Mutation, DeleteAsset.Variables>(
-            DELETE_ASSET,
-            {
-                input: {
-                    assetId: createdAssetId,
-                },
+        const { deleteAsset } = await adminClient.query<
+            Codegen.DeleteAssetMutation,
+            Codegen.DeleteAssetMutationVariables
+        >(DELETE_ASSET, {
+            input: {
+                assetId: createdAssetId,
             },
-        );
+        });
         expect(deleteAsset.result).toBe(DeletionResult.DELETED);
     });
 
     it('Asset is available in default channel', async () => {
         await adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
-        const { asset } = await adminClient.query<GetAsset.Query, GetAsset.Variables>(GET_ASSET, {
-            id: createdAssetId,
-        });
+        const { asset } = await adminClient.query<Codegen.GetAssetQuery, Codegen.GetAssetQueryVariables>(
+            GET_ASSET,
+            {
+                id: createdAssetId,
+            },
+        );
         expect(asset?.id).toEqual(createdAssetId);
     });
 
     it('Add asset to channel2', async () => {
         await adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
         const { assignAssetsToChannel: assets } = await adminClient.query<
-            AssignAssetsToChannel.Mutation,
-            AssignAssetsToChannel.Variables
+            Codegen.AssignAssetsToChannelMutation,
+            Codegen.AssignAssetsToChannelMutationVariables
         >(ASSIGN_ASSET_TO_CHANNEL, {
             input: {
                 assetIds: [createdAssetId],
@@ -157,38 +159,41 @@ describe('ChannelAware Assets', () => {
         'Delete asset from all channels with insufficient permission',
         assertThrowsWithMessage(async () => {
             await adminClient.asAnonymousUser();
-            const { deleteAsset } = await adminClient.query<DeleteAsset.Mutation, DeleteAsset.Variables>(
-                DELETE_ASSET,
-                {
-                    input: {
-                        assetId: createdAssetId,
-                        deleteFromAllChannels: true,
-                    },
+            const { deleteAsset } = await adminClient.query<
+                Codegen.DeleteAssetMutation,
+                Codegen.DeleteAssetMutationVariables
+            >(DELETE_ASSET, {
+                input: {
+                    assetId: createdAssetId,
+                    deleteFromAllChannels: true,
                 },
-            );
+            });
         }, `You are not currently authorized to perform this action`),
     );
 
     it('Delete asset from all channels as superadmin', async () => {
         await adminClient.asSuperAdmin();
         await adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
-        const { deleteAsset } = await adminClient.query<DeleteAsset.Mutation, DeleteAsset.Variables>(
-            DELETE_ASSET,
-            {
-                input: {
-                    assetId: createdAssetId,
-                    deleteFromAllChannels: true,
-                },
+        const { deleteAsset } = await adminClient.query<
+            Codegen.DeleteAssetMutation,
+            Codegen.DeleteAssetMutationVariables
+        >(DELETE_ASSET, {
+            input: {
+                assetId: createdAssetId,
+                deleteFromAllChannels: true,
             },
-        );
+        });
         expect(deleteAsset.result).toEqual(DeletionResult.DELETED);
     });
 
     it('Asset is also deleted in default channel', async () => {
         await adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
-        const { asset } = await adminClient.query<GetAsset.Query, GetAsset.Variables>(GET_ASSET, {
-            id: createdAssetId,
-        });
+        const { asset } = await adminClient.query<Codegen.GetAssetQuery, Codegen.GetAssetQueryVariables>(
+            GET_ASSET,
+            {
+                id: createdAssetId,
+            },
+        );
         expect(asset?.id).toBeUndefined();
     });
 });
@@ -197,8 +202,8 @@ describe('Product related assets', () => {
     it('Featured asset is available in default channel', async () => {
         await adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
         const { product } = await adminClient.query<
-            GetProductWithVariants.Query,
-            GetProductWithVariants.Variables
+            Codegen.GetProductWithVariantsQuery,
+            Codegen.GetProductWithVariantsQueryVariables
         >(GET_PRODUCT_WITH_VARIANTS, {
             id: 'T_1',
         });
@@ -206,25 +211,31 @@ describe('Product related assets', () => {
         expect(featuredAssetId).toBeDefined();
 
         await adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
-        const { asset } = await adminClient.query<GetAsset.Query, GetAsset.Variables>(GET_ASSET, {
-            id: featuredAssetId,
-        });
+        const { asset } = await adminClient.query<Codegen.GetAssetQuery, Codegen.GetAssetQueryVariables>(
+            GET_ASSET,
+            {
+                id: featuredAssetId,
+            },
+        );
         expect(asset?.id).toEqual(featuredAssetId);
     });
 
     it('Featured asset is not available in channel2', async () => {
         await adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
-        const { asset } = await adminClient.query<GetAsset.Query, GetAsset.Variables>(GET_ASSET, {
-            id: featuredAssetId,
-        });
+        const { asset } = await adminClient.query<Codegen.GetAssetQuery, Codegen.GetAssetQueryVariables>(
+            GET_ASSET,
+            {
+                id: featuredAssetId,
+            },
+        );
         expect(asset?.id).toBeUndefined();
     });
 
     it('Add Product to channel2', async () => {
         await adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
         const { assignProductsToChannel } = await adminClient.query<
-            AssignProductsToChannel.Mutation,
-            AssignProductsToChannel.Variables
+            Codegen.AssignProductsToChannelMutation,
+            Codegen.AssignProductsToChannelMutationVariables
         >(ASSIGN_PRODUCT_TO_CHANNEL, {
             input: {
                 channelId: channel2Id,
@@ -237,17 +248,20 @@ describe('Product related assets', () => {
 
     it('Get featured asset from channel2', async () => {
         await adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
-        const { asset } = await adminClient.query<GetAsset.Query, GetAsset.Variables>(GET_ASSET, {
-            id: featuredAssetId,
-        });
+        const { asset } = await adminClient.query<Codegen.GetAssetQuery, Codegen.GetAssetQueryVariables>(
+            GET_ASSET,
+            {
+                id: featuredAssetId,
+            },
+        );
         expect(asset?.id).toEqual(featuredAssetId);
     });
 
     it('Add Product 2 to channel2', async () => {
         await adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
         const { assignProductsToChannel } = await adminClient.query<
-            AssignProductsToChannel.Mutation,
-            AssignProductsToChannel.Variables
+            Codegen.AssignProductsToChannelMutation,
+            Codegen.AssignProductsToChannelMutationVariables
         >(ASSIGN_PRODUCT_TO_CHANNEL, {
             input: {
                 channelId: channel2Id,
@@ -260,23 +274,23 @@ describe('Product related assets', () => {
 
     it('Add asset A to Product 2 in default channel', async () => {
         await adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
-        const { updateProduct } = await adminClient.query<UpdateProduct.Mutation, UpdateProduct.Variables>(
-            UPDATE_PRODUCT,
-            {
-                input: {
-                    id: 'T_2',
-                    assetIds: ['T_3'],
-                },
+        const { updateProduct } = await adminClient.query<
+            Codegen.UpdateProductMutation,
+            Codegen.UpdateProductMutationVariables
+        >(UPDATE_PRODUCT, {
+            input: {
+                id: 'T_2',
+                assetIds: ['T_3'],
             },
-        );
+        });
         expect(updateProduct.assets.map(a => a.id)).toContain('T_3');
     });
 
     it('Channel2 does not have asset A', async () => {
         await adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
         const { product } = await adminClient.query<
-            GetProductWithVariants.Query,
-            GetProductWithVariants.Variables
+            Codegen.GetProductWithVariantsQuery,
+            Codegen.GetProductWithVariantsQueryVariables
         >(GET_PRODUCT_WITH_VARIANTS, {
             id: 'T_2',
         });

+ 143 - 132
packages/core/e2e/asset.e2e-spec.ts

@@ -11,17 +11,14 @@ import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-conf
 
 import {
     AssetFragment,
-    CreateAssets,
-    DeleteAsset,
+    AssetWithTagsAndFocalPointFragment,
+    CreateAssetsMutation,
     DeletionResult,
-    GetAsset,
-    GetAssetFragmentFirst,
-    GetAssetList,
-    GetProductWithVariants,
+    GetProductWithVariantsQuery,
     LogicalOperator,
     SortOrder,
-    UpdateAsset,
 } from './graphql/generated-e2e-admin-types';
+import * as Codegen from './graphql/generated-e2e-admin-types';
 import {
     CREATE_ASSETS,
     DELETE_ASSET,
@@ -58,16 +55,16 @@ describe('Asset resolver', () => {
     });
 
     it('assets', async () => {
-        const { assets } = await adminClient.query<GetAssetList.Query, GetAssetList.Variables>(
-            GET_ASSET_LIST,
-            {
-                options: {
-                    sort: {
-                        name: SortOrder.ASC,
-                    },
+        const { assets } = await adminClient.query<
+            Codegen.GetAssetListQuery,
+            Codegen.GetAssetListQueryVariables
+        >(GET_ASSET_LIST, {
+            options: {
+                sort: {
+                    name: SortOrder.ASC,
                 },
             },
-        );
+        });
 
         expect(assets.totalItems).toBe(4);
         expect(assets.items.map(a => omit(a, ['id']))).toEqual([
@@ -109,9 +106,12 @@ describe('Asset resolver', () => {
     });
 
     it('asset', async () => {
-        const { asset } = await adminClient.query<GetAsset.Query, GetAsset.Variables>(GET_ASSET, {
-            id: firstAssetId,
-        });
+        const { asset } = await adminClient.query<Codegen.GetAssetQuery, Codegen.GetAssetQueryVariables>(
+            GET_ASSET,
+            {
+                id: firstAssetId,
+            },
+        );
 
         expect(asset).toEqual({
             fileSize: 1680,
@@ -131,8 +131,8 @@ describe('Asset resolver', () => {
      */
     it('transforms URL when fragment defined before query (GH issue #459)', async () => {
         const { asset } = await adminClient.query<
-            GetAssetFragmentFirst.Query,
-            GetAssetFragmentFirst.Variables
+            Codegen.GetAssetFragmentFirstQuery,
+            Codegen.GetAssetFragmentFirstQueryVariables
         >(GET_ASSET_FRAGMENT_FIRST, {
             id: firstAssetId,
         });
@@ -141,7 +141,9 @@ describe('Asset resolver', () => {
     });
 
     describe('createAssets', () => {
-        function isAsset(input: CreateAssets.CreateAssets): input is AssetFragment {
+        function isAsset(
+            input: CreateAssetsMutation['createAssets'][number],
+        ): input is AssetWithTagsAndFocalPointFragment {
             return input.hasOwnProperty('name');
         }
 
@@ -150,7 +152,7 @@ describe('Asset resolver', () => {
                 path.join(__dirname, 'fixtures/assets/pps1.jpg'),
                 path.join(__dirname, 'fixtures/assets/pps2.jpg'),
             ];
-            const { createAssets }: CreateAssets.Mutation = await adminClient.fileUploadMutation({
+            const { createAssets }: Codegen.CreateAssetsMutation = await adminClient.fileUploadMutation({
                 mutation: CREATE_ASSETS,
                 filePaths: filesToUpload,
                 mapVariables: filePaths => ({
@@ -188,7 +190,7 @@ describe('Asset resolver', () => {
 
         it('permitted type by file extension', async () => {
             const filesToUpload = [path.join(__dirname, 'fixtures/assets/dummy.pdf')];
-            const { createAssets }: CreateAssets.Mutation = await adminClient.fileUploadMutation({
+            const { createAssets }: Codegen.CreateAssetsMutation = await adminClient.fileUploadMutation({
                 mutation: CREATE_ASSETS,
                 filePaths: filesToUpload,
                 mapVariables: filePaths => ({
@@ -215,7 +217,7 @@ describe('Asset resolver', () => {
         // https://github.com/vendure-ecommerce/vendure/issues/727
         it('file extension with shared type', async () => {
             const filesToUpload = [path.join(__dirname, 'fixtures/assets/dummy.zip')];
-            const { createAssets }: CreateAssets.Mutation = await adminClient.fileUploadMutation({
+            const { createAssets }: Codegen.CreateAssetsMutation = await adminClient.fileUploadMutation({
                 mutation: CREATE_ASSETS,
                 filePaths: filesToUpload,
                 mapVariables: filePaths => ({
@@ -243,7 +245,7 @@ describe('Asset resolver', () => {
 
         it('not permitted type', async () => {
             const filesToUpload = [path.join(__dirname, 'fixtures/assets/dummy.txt')];
-            const { createAssets }: CreateAssets.Mutation = await adminClient.fileUploadMutation({
+            const { createAssets }: Codegen.CreateAssetsMutation = await adminClient.fileUploadMutation({
                 mutation: CREATE_ASSETS,
                 filePaths: filesToUpload,
                 mapVariables: filePaths => ({
@@ -261,7 +263,7 @@ describe('Asset resolver', () => {
 
         it('create with new tags', async () => {
             const filesToUpload = [path.join(__dirname, 'fixtures/assets/pps1.jpg')];
-            const { createAssets }: CreateAssets.Mutation = await adminClient.fileUploadMutation({
+            const { createAssets }: Codegen.CreateAssetsMutation = await adminClient.fileUploadMutation({
                 mutation: CREATE_ASSETS,
                 filePaths: filesToUpload,
                 mapVariables: filePaths => ({
@@ -284,7 +286,7 @@ describe('Asset resolver', () => {
 
         it('create with existing tags', async () => {
             const filesToUpload = [path.join(__dirname, 'fixtures/assets/pps1.jpg')];
-            const { createAssets }: CreateAssets.Mutation = await adminClient.fileUploadMutation({
+            const { createAssets }: Codegen.CreateAssetsMutation = await adminClient.fileUploadMutation({
                 mutation: CREATE_ASSETS,
                 filePaths: filesToUpload,
                 mapVariables: filePaths => ({
@@ -307,7 +309,7 @@ describe('Asset resolver', () => {
 
         it('create with new and existing tags', async () => {
             const filesToUpload = [path.join(__dirname, 'fixtures/assets/pps1.jpg')];
-            const { createAssets }: CreateAssets.Mutation = await adminClient.fileUploadMutation({
+            const { createAssets }: Codegen.CreateAssetsMutation = await adminClient.fileUploadMutation({
                 mutation: CREATE_ASSETS,
                 filePaths: filesToUpload,
                 mapVariables: filePaths => ({
@@ -347,7 +349,7 @@ describe('Asset resolver', () => {
             await createEmptyFileOfSize(filename, twentyOneMib);
 
             try {
-                const { createAssets }: CreateAssets.Mutation = await adminClient.fileUploadMutation({
+                const { createAssets }: Codegen.CreateAssetsMutation = await adminClient.fileUploadMutation({
                     mutation: CREATE_ASSETS,
                     filePaths: [filename],
                     mapVariables: filePaths => ({
@@ -365,42 +367,42 @@ describe('Asset resolver', () => {
 
     describe('filter by tags', () => {
         it('and', async () => {
-            const { assets } = await adminClient.query<GetAssetList.Query, GetAssetList.Variables>(
-                GET_ASSET_LIST,
-                {
-                    options: {
-                        tags: ['foo', 'bar'],
-                        tagsOperator: LogicalOperator.AND,
-                    },
+            const { assets } = await adminClient.query<
+                Codegen.GetAssetListQuery,
+                Codegen.GetAssetListQueryVariables
+            >(GET_ASSET_LIST, {
+                options: {
+                    tags: ['foo', 'bar'],
+                    tagsOperator: LogicalOperator.AND,
                 },
-            );
+            });
 
             expect(assets.items.map(i => i.id).sort()).toEqual(['T_10', 'T_9']);
         });
 
         it('or', async () => {
-            const { assets } = await adminClient.query<GetAssetList.Query, GetAssetList.Variables>(
-                GET_ASSET_LIST,
-                {
-                    options: {
-                        tags: ['foo', 'bar'],
-                        tagsOperator: LogicalOperator.OR,
-                    },
+            const { assets } = await adminClient.query<
+                Codegen.GetAssetListQuery,
+                Codegen.GetAssetListQueryVariables
+            >(GET_ASSET_LIST, {
+                options: {
+                    tags: ['foo', 'bar'],
+                    tagsOperator: LogicalOperator.OR,
                 },
-            );
+            });
 
             expect(assets.items.map(i => i.id).sort()).toEqual(['T_10', 'T_11', 'T_9']);
         });
 
         it('empty array', async () => {
-            const { assets } = await adminClient.query<GetAssetList.Query, GetAssetList.Variables>(
-                GET_ASSET_LIST,
-                {
-                    options: {
-                        tags: [],
-                    },
+            const { assets } = await adminClient.query<
+                Codegen.GetAssetListQuery,
+                Codegen.GetAssetListQueryVariables
+            >(GET_ASSET_LIST, {
+                options: {
+                    tags: [],
                 },
-            );
+            });
 
             expect(assets.totalItems).toBe(11);
         });
@@ -408,32 +410,32 @@ describe('Asset resolver', () => {
 
     describe('updateAsset', () => {
         it('update name', async () => {
-            const { updateAsset } = await adminClient.query<UpdateAsset.Mutation, UpdateAsset.Variables>(
-                UPDATE_ASSET,
-                {
-                    input: {
-                        id: firstAssetId,
-                        name: 'new name',
-                    },
+            const { updateAsset } = await adminClient.query<
+                Codegen.UpdateAssetMutation,
+                Codegen.UpdateAssetMutationVariables
+            >(UPDATE_ASSET, {
+                input: {
+                    id: firstAssetId,
+                    name: 'new name',
                 },
-            );
+            });
 
             expect(updateAsset.name).toEqual('new name');
         });
 
         it('update focalPoint', async () => {
-            const { updateAsset } = await adminClient.query<UpdateAsset.Mutation, UpdateAsset.Variables>(
-                UPDATE_ASSET,
-                {
-                    input: {
-                        id: firstAssetId,
-                        focalPoint: {
-                            x: 0.3,
-                            y: 0.9,
-                        },
+            const { updateAsset } = await adminClient.query<
+                Codegen.UpdateAssetMutation,
+                Codegen.UpdateAssetMutationVariables
+            >(UPDATE_ASSET, {
+                input: {
+                    id: firstAssetId,
+                    focalPoint: {
+                        x: 0.3,
+                        y: 0.9,
                     },
                 },
-            );
+            });
 
             expect(updateAsset.focalPoint).toEqual({
                 x: 0.3,
@@ -442,29 +444,29 @@ describe('Asset resolver', () => {
         });
 
         it('unset focalPoint', async () => {
-            const { updateAsset } = await adminClient.query<UpdateAsset.Mutation, UpdateAsset.Variables>(
-                UPDATE_ASSET,
-                {
-                    input: {
-                        id: firstAssetId,
-                        focalPoint: null,
-                    },
+            const { updateAsset } = await adminClient.query<
+                Codegen.UpdateAssetMutation,
+                Codegen.UpdateAssetMutationVariables
+            >(UPDATE_ASSET, {
+                input: {
+                    id: firstAssetId,
+                    focalPoint: null,
                 },
-            );
+            });
 
             expect(updateAsset.focalPoint).toEqual(null);
         });
 
         it('update tags', async () => {
-            const { updateAsset } = await adminClient.query<UpdateAsset.Mutation, UpdateAsset.Variables>(
-                UPDATE_ASSET,
-                {
-                    input: {
-                        id: firstAssetId,
-                        tags: ['foo', 'quux'],
-                    },
+            const { updateAsset } = await adminClient.query<
+                Codegen.UpdateAssetMutation,
+                Codegen.UpdateAssetMutationVariables
+            >(UPDATE_ASSET, {
+                input: {
+                    id: firstAssetId,
+                    tags: ['foo', 'quux'],
                 },
-            );
+            });
 
             expect(updateAsset.tags).toEqual([
                 { id: 'T_1', value: 'foo' },
@@ -473,27 +475,27 @@ describe('Asset resolver', () => {
         });
 
         it('remove tags', async () => {
-            const { updateAsset } = await adminClient.query<UpdateAsset.Mutation, UpdateAsset.Variables>(
-                UPDATE_ASSET,
-                {
-                    input: {
-                        id: firstAssetId,
-                        tags: [],
-                    },
+            const { updateAsset } = await adminClient.query<
+                Codegen.UpdateAssetMutation,
+                Codegen.UpdateAssetMutationVariables
+            >(UPDATE_ASSET, {
+                input: {
+                    id: firstAssetId,
+                    tags: [],
                 },
-            );
+            });
 
             expect(updateAsset.tags).toEqual([]);
         });
     });
 
     describe('deleteAsset', () => {
-        let firstProduct: GetProductWithVariants.Product;
+        let firstProduct: NonNullable<GetProductWithVariantsQuery['product']>;
 
         beforeAll(async () => {
             const { product } = await adminClient.query<
-                GetProductWithVariants.Query,
-                GetProductWithVariants.Variables
+                Codegen.GetProductWithVariantsQuery,
+                Codegen.GetProductWithVariantsQueryVariables
             >(GET_PRODUCT_WITH_VARIANTS, {
                 id: 'T_1',
             });
@@ -502,71 +504,80 @@ describe('Asset resolver', () => {
         });
 
         it('non-featured asset', async () => {
-            const { deleteAsset } = await adminClient.query<DeleteAsset.Mutation, DeleteAsset.Variables>(
-                DELETE_ASSET,
-                {
-                    input: {
-                        assetId: createdAssetId,
-                    },
+            const { deleteAsset } = await adminClient.query<
+                Codegen.DeleteAssetMutation,
+                Codegen.DeleteAssetMutationVariables
+            >(DELETE_ASSET, {
+                input: {
+                    assetId: createdAssetId,
                 },
-            );
+            });
 
             expect(deleteAsset.result).toBe(DeletionResult.DELETED);
 
-            const { asset } = await adminClient.query<GetAsset.Query, GetAsset.Variables>(GET_ASSET, {
-                id: createdAssetId,
-            });
+            const { asset } = await adminClient.query<Codegen.GetAssetQuery, Codegen.GetAssetQueryVariables>(
+                GET_ASSET,
+                {
+                    id: createdAssetId,
+                },
+            );
             expect(asset).toBeNull();
         });
 
         it('featured asset not deleted', async () => {
-            const { deleteAsset } = await adminClient.query<DeleteAsset.Mutation, DeleteAsset.Variables>(
-                DELETE_ASSET,
-                {
-                    input: {
-                        assetId: firstProduct.featuredAsset!.id,
-                    },
+            const { deleteAsset } = await adminClient.query<
+                Codegen.DeleteAssetMutation,
+                Codegen.DeleteAssetMutationVariables
+            >(DELETE_ASSET, {
+                input: {
+                    assetId: firstProduct.featuredAsset!.id,
                 },
-            );
+            });
 
             expect(deleteAsset.result).toBe(DeletionResult.NOT_DELETED);
             expect(deleteAsset.message).toContain(`The selected Asset is featured by 1 Product`);
 
-            const { asset } = await adminClient.query<GetAsset.Query, GetAsset.Variables>(GET_ASSET, {
-                id: firstAssetId,
-            });
+            const { asset } = await adminClient.query<Codegen.GetAssetQuery, Codegen.GetAssetQueryVariables>(
+                GET_ASSET,
+                {
+                    id: firstAssetId,
+                },
+            );
             expect(asset).not.toBeNull();
         });
 
         it('featured asset force deleted', async () => {
             const { product: p1 } = await adminClient.query<
-                GetProductWithVariants.Query,
-                GetProductWithVariants.Variables
+                Codegen.GetProductWithVariantsQuery,
+                Codegen.GetProductWithVariantsQueryVariables
             >(GET_PRODUCT_WITH_VARIANTS, {
                 id: firstProduct.id,
             });
             expect(p1!.assets.length).toEqual(1);
 
-            const { deleteAsset } = await adminClient.query<DeleteAsset.Mutation, DeleteAsset.Variables>(
-                DELETE_ASSET,
-                {
-                    input: {
-                        assetId: firstProduct.featuredAsset!.id,
-                        force: true,
-                    },
+            const { deleteAsset } = await adminClient.query<
+                Codegen.DeleteAssetMutation,
+                Codegen.DeleteAssetMutationVariables
+            >(DELETE_ASSET, {
+                input: {
+                    assetId: firstProduct.featuredAsset!.id,
+                    force: true,
                 },
-            );
+            });
 
             expect(deleteAsset.result).toBe(DeletionResult.DELETED);
 
-            const { asset } = await adminClient.query<GetAsset.Query, GetAsset.Variables>(GET_ASSET, {
-                id: firstAssetId,
-            });
+            const { asset } = await adminClient.query<Codegen.GetAssetQuery, Codegen.GetAssetQueryVariables>(
+                GET_ASSET,
+                {
+                    id: firstAssetId,
+                },
+            );
             expect(asset).not.toBeNull();
 
             const { product } = await adminClient.query<
-                GetProductWithVariants.Query,
-                GetProductWithVariants.Variables
+                Codegen.GetProductWithVariantsQuery,
+                Codegen.GetProductWithVariantsQueryVariables
             >(GET_PRODUCT_WITH_VARIANTS, {
                 id: firstProduct.id,
             });

+ 35 - 39
packages/core/e2e/auth.e2e-spec.ts

@@ -9,20 +9,8 @@ import { initialData } from '../../../e2e-common/e2e-initial-data';
 import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
 
 import { ProtectedFieldsPlugin, transactions } from './fixtures/test-plugins/with-protected-field-resolver';
-import {
-    CreateAdministrator,
-    CreateCustomerGroup,
-    CreateRole,
-    ErrorCode,
-    GetCustomerList,
-    GetTaxRates,
-    Me,
-    MutationCreateProductArgs,
-    MutationLoginArgs,
-    MutationUpdateProductArgs,
-    Permission,
-    UpdateTaxRate,
-} from './graphql/generated-e2e-admin-types';
+import { ErrorCode, Permission } from './graphql/generated-e2e-admin-types';
+import * as Codegen from './graphql/generated-e2e-admin-types';
 import {
     ATTEMPT_LOGIN,
     CREATE_ADMINISTRATOR,
@@ -66,12 +54,12 @@ describe('Authorization & permissions', () => {
             it(
                 'me is not permitted',
                 assertThrowsWithMessage(async () => {
-                    await adminClient.query<Me.Query>(ME);
+                    await adminClient.query<Codegen.MeQuery>(ME);
                 }, 'You are not currently authorized to perform this action'),
             );
 
             it('can attempt login', async () => {
-                await assertRequestAllowed<MutationLoginArgs>(ATTEMPT_LOGIN, {
+                await assertRequestAllowed<Codegen.MutationLoginArgs>(ATTEMPT_LOGIN, {
                     username: SUPER_ADMIN_USER_IDENTIFIER,
                     password: SUPER_ADMIN_USER_PASSWORD,
                     rememberMe: false,
@@ -83,7 +71,9 @@ describe('Authorization & permissions', () => {
             let customerEmailAddress: string;
             beforeAll(async () => {
                 await adminClient.asSuperAdmin();
-                const { customers } = await adminClient.query<GetCustomerList.Query>(GET_CUSTOMER_LIST);
+                const { customers } = await adminClient.query<Codegen.GetCustomerListQuery>(
+                    GET_CUSTOMER_LIST,
+                );
                 customerEmailAddress = customers.items[0].emailAddress;
             });
 
@@ -104,7 +94,7 @@ describe('Authorization & permissions', () => {
             });
 
             it('me returns correct permissions', async () => {
-                const { me } = await adminClient.query<Me.Query>(ME);
+                const { me } = await adminClient.query<Codegen.MeQuery>(ME);
 
                 expect(me!.channels[0].permissions).toEqual([
                     Permission.Authenticated,
@@ -117,7 +107,7 @@ describe('Authorization & permissions', () => {
             });
 
             it('cannot update', async () => {
-                await assertRequestForbidden<MutationUpdateProductArgs>(UPDATE_PRODUCT, {
+                await assertRequestForbidden<Codegen.MutationUpdateProductArgs>(UPDATE_PRODUCT, {
                     input: {
                         id: '1',
                         translations: [],
@@ -126,7 +116,7 @@ describe('Authorization & permissions', () => {
             });
 
             it('cannot create', async () => {
-                await assertRequestForbidden<MutationCreateProductArgs>(CREATE_PRODUCT, {
+                await assertRequestForbidden<Codegen.MutationCreateProductArgs>(CREATE_PRODUCT, {
                     input: {
                         translations: [],
                     },
@@ -147,7 +137,7 @@ describe('Authorization & permissions', () => {
             });
 
             it('me returns correct permissions', async () => {
-                const { me } = await adminClient.query<Me.Query>(ME);
+                const { me } = await adminClient.query<Codegen.MeQuery>(ME);
 
                 expect(me!.channels[0].permissions).toEqual([
                     Permission.Authenticated,
@@ -239,8 +229,8 @@ describe('Authorization & permissions', () => {
         it('protects against deep query data leakage', async () => {
             await adminClient.asSuperAdmin();
             const { createCustomerGroup } = await adminClient.query<
-                CreateCustomerGroup.Mutation,
-                CreateCustomerGroup.Variables
+                Codegen.CreateCustomerGroupMutation,
+                Codegen.CreateCustomerGroupMutationVariables
             >(CREATE_CUSTOMER_GROUP, {
                 input: {
                     name: 'Test group',
@@ -249,26 +239,29 @@ describe('Authorization & permissions', () => {
             });
 
             const taxRateName = `Standard Tax ${initialData.defaultZone}`;
-            const { taxRates } = await adminClient.query<GetTaxRates.Query, GetTaxRates.Variables>(
-                GET_TAX_RATES_LIST,
-                {
-                    options: {
-                        filter: {
-                            name: { eq: taxRateName },
-                        },
+            const { taxRates } = await adminClient.query<
+                Codegen.GetTaxRatesQuery,
+                Codegen.GetTaxRatesQueryVariables
+            >(GET_TAX_RATES_LIST, {
+                options: {
+                    filter: {
+                        name: { eq: taxRateName },
                     },
                 },
-            );
+            });
 
             const standardTax = taxRates.items[0];
             expect(standardTax.name).toBe(taxRateName);
 
-            await adminClient.query<UpdateTaxRate.Mutation, UpdateTaxRate.Variables>(UPDATE_TAX_RATE, {
-                input: {
-                    id: standardTax.id,
-                    customerGroupId: createCustomerGroup.id,
+            await adminClient.query<Codegen.UpdateTaxRateMutation, Codegen.UpdateTaxRateMutationVariables>(
+                UPDATE_TAX_RATE,
+                {
+                    input: {
+                        id: standardTax.id,
+                        customerGroupId: createCustomerGroup.id,
+                    },
                 },
-            });
+            );
 
             try {
                 const status = await shopClient.query(
@@ -329,7 +322,10 @@ describe('Authorization & permissions', () => {
         code: string,
         permissions: Permission[],
     ): Promise<{ identifier: string; password: string }> {
-        const roleResult = await adminClient.query<CreateRole.Mutation, CreateRole.Variables>(CREATE_ROLE, {
+        const roleResult = await adminClient.query<
+            Codegen.CreateRoleMutation,
+            Codegen.CreateRoleMutationVariables
+        >(CREATE_ROLE, {
             input: {
                 code,
                 description: '',
@@ -343,8 +339,8 @@ describe('Authorization & permissions', () => {
         const password = `test`;
 
         const adminResult = await adminClient.query<
-            CreateAdministrator.Mutation,
-            CreateAdministrator.Variables
+            Codegen.CreateAdministratorMutation,
+            Codegen.CreateAdministratorMutationVariables
         >(CREATE_ADMINISTRATOR, {
             input: {
                 emailAddress: identifier,

+ 77 - 66
packages/core/e2e/authentication-strategy.e2e-spec.ts

@@ -17,19 +17,9 @@ import {
     VALID_AUTH_TOKEN,
 } from './fixtures/test-authentication-strategies';
 import { CURRENT_USER_FRAGMENT } from './graphql/fragments';
-import {
-    Authenticate,
-    CreateCustomer,
-    CurrentUserFragment,
-    CustomerFragment,
-    DeleteCustomer,
-    GetCustomerHistory,
-    GetCustomers,
-    GetCustomerUserAuth,
-    HistoryEntryType,
-    Me,
-} from './graphql/generated-e2e-admin-types';
-import { Register } from './graphql/generated-e2e-shop-types';
+import { CurrentUserFragment, CustomerFragment, HistoryEntryType } from './graphql/generated-e2e-admin-types';
+import * as Codegen from './graphql/generated-e2e-admin-types';
+import { RegisterMutation, RegisterMutationVariables } from './graphql/generated-e2e-shop-types';
 import { CREATE_CUSTOMER, DELETE_CUSTOMER, GET_CUSTOMER_HISTORY, ME } from './graphql/shared-definitions';
 import { REGISTER_ACCOUNT } from './graphql/shop-definitions';
 
@@ -105,10 +95,10 @@ describe('AuthenticationStrategy', () => {
         });
 
         it('creates a new Customer with valid token', async () => {
-            const { customers: before } = await adminClient.query<GetCustomers.Query>(GET_CUSTOMERS);
+            const { customers: before } = await adminClient.query<Codegen.GetCustomersQuery>(GET_CUSTOMERS);
             expect(before.totalItems).toBe(1);
 
-            const { authenticate } = await shopClient.query<Authenticate.Mutation>(AUTHENTICATE, {
+            const { authenticate } = await shopClient.query<Codegen.AuthenticateMutation>(AUTHENTICATE, {
                 input: {
                     test_strategy: {
                         token: VALID_AUTH_TOKEN,
@@ -120,7 +110,7 @@ describe('AuthenticationStrategy', () => {
 
             expect(authenticate.identifier).toEqual(userData.email);
 
-            const { customers: after } = await adminClient.query<GetCustomers.Query>(GET_CUSTOMERS);
+            const { customers: after } = await adminClient.query<Codegen.GetCustomersQuery>(GET_CUSTOMERS);
             expect(after.totalItems).toBe(2);
             expect(after.items.map(i => i.emailAddress)).toEqual([
                 'hayden.zieme12@hotmail.com',
@@ -131,8 +121,8 @@ describe('AuthenticationStrategy', () => {
 
         it('creates customer history entry', async () => {
             const { customer } = await adminClient.query<
-                GetCustomerHistory.Query,
-                GetCustomerHistory.Variables
+                Codegen.GetCustomerHistoryQuery,
+                Codegen.GetCustomerHistoryQueryVariables
             >(GET_CUSTOMER_HISTORY, {
                 id: newCustomerId,
             });
@@ -157,8 +147,8 @@ describe('AuthenticationStrategy', () => {
 
         it('user authenticationMethod populated', async () => {
             const { customer } = await adminClient.query<
-                GetCustomerUserAuth.Query,
-                GetCustomerUserAuth.Variables
+                Codegen.GetCustomerUserAuthQuery,
+                Codegen.GetCustomerUserAuthQueryVariables
             >(GET_CUSTOMER_USER_AUTH, {
                 id: newCustomerId,
             });
@@ -168,7 +158,7 @@ describe('AuthenticationStrategy', () => {
         });
 
         it('creates authenticated session', async () => {
-            const { me } = await shopClient.query<Me.Query>(ME);
+            const { me } = await shopClient.query<Codegen.MeQuery>(ME);
 
             expect(me?.identifier).toBe(userData.email);
         });
@@ -178,7 +168,7 @@ describe('AuthenticationStrategy', () => {
         });
 
         it('logging in again re-uses created User & Customer', async () => {
-            const { authenticate } = await shopClient.query<Authenticate.Mutation>(AUTHENTICATE, {
+            const { authenticate } = await shopClient.query<Codegen.AuthenticateMutation>(AUTHENTICATE, {
                 input: {
                     test_strategy: {
                         token: VALID_AUTH_TOKEN,
@@ -189,7 +179,7 @@ describe('AuthenticationStrategy', () => {
             currentUserGuard.assertSuccess(authenticate);
             expect(authenticate.identifier).toEqual(userData.email);
 
-            const { customers: after } = await adminClient.query<GetCustomers.Query>(GET_CUSTOMERS);
+            const { customers: after } = await adminClient.query<Codegen.GetCustomersQuery>(GET_CUSTOMERS);
             expect(after.totalItems).toBe(2);
             expect(after.items.map(i => i.emailAddress)).toEqual([
                 'hayden.zieme12@hotmail.com',
@@ -210,38 +200,50 @@ describe('AuthenticationStrategy', () => {
                 },
             ];
 
-            const { customers: customers1 } = await adminClient.query<GetCustomers.Query>(GET_CUSTOMERS);
+            const { customers: customers1 } = await adminClient.query<Codegen.GetCustomersQuery>(
+                GET_CUSTOMERS,
+            );
             expect(customers1.items).toEqual(EXPECTED_CUSTOMERS);
-            const { authenticate: auth1 } = await shopClient.query<Authenticate.Mutation>(AUTHENTICATE, {
-                input: {
-                    test_strategy2: {
-                        token: VALID_AUTH_TOKEN,
-                        email: userData.email,
+            const { authenticate: auth1 } = await shopClient.query<Codegen.AuthenticateMutation>(
+                AUTHENTICATE,
+                {
+                    input: {
+                        test_strategy2: {
+                            token: VALID_AUTH_TOKEN,
+                            email: userData.email,
+                        },
                     },
                 },
-            });
+            );
 
             currentUserGuard.assertSuccess(auth1);
             expect(auth1.identifier).toBe(userData.email);
 
-            const { customers: customers2 } = await adminClient.query<GetCustomers.Query>(GET_CUSTOMERS);
+            const { customers: customers2 } = await adminClient.query<Codegen.GetCustomersQuery>(
+                GET_CUSTOMERS,
+            );
             expect(customers2.items).toEqual(EXPECTED_CUSTOMERS);
 
             await shopClient.asAnonymousUser();
 
-            const { authenticate: auth2 } = await shopClient.query<Authenticate.Mutation>(AUTHENTICATE, {
-                input: {
-                    test_strategy: {
-                        token: VALID_AUTH_TOKEN,
-                        userData,
+            const { authenticate: auth2 } = await shopClient.query<Codegen.AuthenticateMutation>(
+                AUTHENTICATE,
+                {
+                    input: {
+                        test_strategy: {
+                            token: VALID_AUTH_TOKEN,
+                            userData,
+                        },
                     },
                 },
-            });
+            );
 
             currentUserGuard.assertSuccess(auth2);
             expect(auth2.identifier).toBe(userData.email);
 
-            const { customers: customers3 } = await adminClient.query<GetCustomers.Query>(GET_CUSTOMERS);
+            const { customers: customers3 } = await adminClient.query<Codegen.GetCustomersQuery>(
+                GET_CUSTOMERS,
+            );
             expect(customers3.items).toEqual(EXPECTED_CUSTOMERS);
         });
 
@@ -250,20 +252,20 @@ describe('AuthenticationStrategy', () => {
                 input => input.success != null,
             );
 
-            const { registerCustomerAccount } = await shopClient.query<Register.Mutation, Register.Variables>(
-                REGISTER_ACCOUNT,
-                {
-                    input: {
-                        emailAddress: userData.email,
-                    },
+            const { registerCustomerAccount } = await shopClient.query<
+                RegisterMutation,
+                RegisterMutationVariables
+            >(REGISTER_ACCOUNT, {
+                input: {
+                    emailAddress: userData.email,
                 },
-            );
+            });
             successErrorGuard.assertSuccess(registerCustomerAccount);
 
             expect(registerCustomerAccount.success).toBe(true);
             const { customer } = await adminClient.query<
-                GetCustomerUserAuth.Query,
-                GetCustomerUserAuth.Variables
+                Codegen.GetCustomerUserAuthQuery,
+                Codegen.GetCustomerUserAuthQueryVariables
             >(GET_CUSTOMER_USER_AUTH, {
                 id: newCustomerId,
             });
@@ -276,8 +278,8 @@ describe('AuthenticationStrategy', () => {
             ]);
 
             const { customer: customer2 } = await adminClient.query<
-                GetCustomerHistory.Query,
-                GetCustomerHistory.Variables
+                Codegen.GetCustomerHistoryQuery,
+                Codegen.GetCustomerHistoryQueryVariables
             >(GET_CUSTOMER_HISTORY, {
                 id: newCustomerId,
                 options: {
@@ -299,22 +301,28 @@ describe('AuthenticationStrategy', () => {
         it('Customer and Admin external auth does not reuse same User for different strategies', async () => {
             const emailAddress = 'hello@test-domain.com';
             await adminClient.asAnonymousUser();
-            const { authenticate: adminAuth } = await adminClient.query<Authenticate.Mutation>(AUTHENTICATE, {
-                input: {
-                    test_sso_strategy_admin: {
-                        email: emailAddress,
+            const { authenticate: adminAuth } = await adminClient.query<Codegen.AuthenticateMutation>(
+                AUTHENTICATE,
+                {
+                    input: {
+                        test_sso_strategy_admin: {
+                            email: emailAddress,
+                        },
                     },
                 },
-            });
+            );
             currentUserGuard.assertSuccess(adminAuth);
 
-            const { authenticate: shopAuth } = await shopClient.query<Authenticate.Mutation>(AUTHENTICATE, {
-                input: {
-                    test_sso_strategy_shop: {
-                        email: emailAddress,
+            const { authenticate: shopAuth } = await shopClient.query<Codegen.AuthenticateMutation>(
+                AUTHENTICATE,
+                {
+                    input: {
+                        test_sso_strategy_shop: {
+                            email: emailAddress,
+                        },
                     },
                 },
-            });
+            );
             currentUserGuard.assertSuccess(shopAuth);
 
             expect(adminAuth.id).not.toBe(shopAuth.id);
@@ -327,8 +335,8 @@ describe('AuthenticationStrategy', () => {
         // https://github.com/vendure-ecommerce/vendure/issues/486#issuecomment-704991768
         it('allows login for an email address which is shared by a previously-deleted Customer', async () => {
             const { createCustomer: result1 } = await adminClient.query<
-                CreateCustomer.Mutation,
-                CreateCustomer.Variables
+                Codegen.CreateCustomerMutation,
+                Codegen.CreateCustomerMutationVariables
             >(CREATE_CUSTOMER, {
                 input: {
                     firstName: 'Test',
@@ -339,13 +347,16 @@ describe('AuthenticationStrategy', () => {
             });
             customerGuard.assertSuccess(result1);
 
-            await adminClient.query<DeleteCustomer.Mutation, DeleteCustomer.Variables>(DELETE_CUSTOMER, {
-                id: result1.id,
-            });
+            await adminClient.query<Codegen.DeleteCustomerMutation, Codegen.DeleteCustomerMutationVariables>(
+                DELETE_CUSTOMER,
+                {
+                    id: result1.id,
+                },
+            );
 
             const { createCustomer: result2 } = await adminClient.query<
-                CreateCustomer.Mutation,
-                CreateCustomer.Variables
+                Codegen.CreateCustomerMutation,
+                Codegen.CreateCustomerMutationVariables
             >(CREATE_CUSTOMER, {
                 input: {
                     firstName: 'Test',

+ 109 - 117
packages/core/e2e/channel.e2e-spec.ts

@@ -13,24 +13,14 @@ import { initialData } from '../../../e2e-common/e2e-initial-data';
 import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
 
 import {
-    AssignProductsToChannel,
     ChannelFragment,
-    CreateAdministrator,
-    CreateChannel,
-    CreateRole,
     CurrencyCode,
-    DeleteChannel,
     DeletionResult,
     ErrorCode,
-    GetChannels,
-    GetCustomerList,
-    GetProductWithVariants,
     LanguageCode,
-    Me,
     Permission,
-    UpdateChannel,
-    UpdateGlobalLanguages,
 } from './graphql/generated-e2e-admin-types';
+import * as Codegen from './graphql/generated-e2e-admin-types';
 import {
     ASSIGN_PRODUCT_TO_CHANNEL,
     CREATE_ADMINISTRATOR,
@@ -47,12 +37,11 @@ import { assertThrowsWithMessage } from './utils/assert-throws-with-message';
 describe('Channels', () => {
     const { server, adminClient, shopClient } = createTestEnvironment(testConfig());
     const SECOND_CHANNEL_TOKEN = 'second_channel_token';
-    let secondChannelAdminRole: CreateRole.CreateRole;
-    let customerUser: GetCustomerList.Items;
+    let secondChannelAdminRole: Codegen.CreateRoleMutation['createRole'];
+    let customerUser: Codegen.GetCustomerListQuery['customers']['items'][number];
 
-    const channelGuard: ErrorResultGuard<ChannelFragment> = createErrorResultGuard<ChannelFragment>(
-        input => !!input.defaultLanguageCode,
-    );
+    const channelGuard: ErrorResultGuard<Codegen.ChannelFragment> =
+        createErrorResultGuard<Codegen.ChannelFragment>(input => !!input.defaultLanguageCode);
 
     beforeAll(async () => {
         await server.init({
@@ -62,12 +51,12 @@ describe('Channels', () => {
         });
         await adminClient.asSuperAdmin();
 
-        const { customers } = await adminClient.query<GetCustomerList.Query, GetCustomerList.Variables>(
-            GET_CUSTOMER_LIST,
-            {
-                options: { take: 1 },
-            },
-        );
+        const { customers } = await adminClient.query<
+            Codegen.GetCustomerListQuery,
+            Codegen.GetCustomerListQueryVariables
+        >(GET_CUSTOMER_LIST, {
+            options: { take: 1 },
+        });
         customerUser = customers.items[0];
     }, TEST_SETUP_TIMEOUT_MS);
 
@@ -76,20 +65,20 @@ describe('Channels', () => {
     });
 
     it('createChannel returns error result defaultLanguageCode not available', async () => {
-        const { createChannel } = await adminClient.query<CreateChannel.Mutation, CreateChannel.Variables>(
-            CREATE_CHANNEL,
-            {
-                input: {
-                    code: 'second-channel',
-                    token: SECOND_CHANNEL_TOKEN,
-                    defaultLanguageCode: LanguageCode.zh,
-                    currencyCode: CurrencyCode.GBP,
-                    pricesIncludeTax: true,
-                    defaultShippingZoneId: 'T_1',
-                    defaultTaxZoneId: 'T_1',
-                },
+        const { createChannel } = await adminClient.query<
+            Codegen.CreateChannelMutation,
+            Codegen.CreateChannelMutationVariables
+        >(CREATE_CHANNEL, {
+            input: {
+                code: 'second-channel',
+                token: SECOND_CHANNEL_TOKEN,
+                defaultLanguageCode: LanguageCode.zh,
+                currencyCode: CurrencyCode.GBP,
+                pricesIncludeTax: true,
+                defaultShippingZoneId: 'T_1',
+                defaultTaxZoneId: 'T_1',
             },
-        );
+        });
         channelGuard.assertErrorResult(createChannel);
 
         expect(createChannel.message).toBe(
@@ -100,20 +89,20 @@ describe('Channels', () => {
     });
 
     it('create a new Channel', async () => {
-        const { createChannel } = await adminClient.query<CreateChannel.Mutation, CreateChannel.Variables>(
-            CREATE_CHANNEL,
-            {
-                input: {
-                    code: 'second-channel',
-                    token: SECOND_CHANNEL_TOKEN,
-                    defaultLanguageCode: LanguageCode.en,
-                    currencyCode: CurrencyCode.GBP,
-                    pricesIncludeTax: true,
-                    defaultShippingZoneId: 'T_1',
-                    defaultTaxZoneId: 'T_1',
-                },
+        const { createChannel } = await adminClient.query<
+            Codegen.CreateChannelMutation,
+            Codegen.CreateChannelMutationVariables
+        >(CREATE_CHANNEL, {
+            input: {
+                code: 'second-channel',
+                token: SECOND_CHANNEL_TOKEN,
+                defaultLanguageCode: LanguageCode.en,
+                currencyCode: CurrencyCode.GBP,
+                pricesIncludeTax: true,
+                defaultShippingZoneId: 'T_1',
+                defaultTaxZoneId: 'T_1',
             },
-        );
+        });
         channelGuard.assertSuccess(createChannel);
 
         expect(createChannel).toEqual({
@@ -133,7 +122,7 @@ describe('Channels', () => {
     });
 
     it('superadmin has all permissions on new channel', async () => {
-        const { me } = await adminClient.query<Me.Query>(ME);
+        const { me } = await adminClient.query<Codegen.MeQuery>(ME);
 
         expect(me!.channels.length).toBe(2);
 
@@ -141,12 +130,12 @@ describe('Channels', () => {
         const nonOwnerPermissions = Object.values(Permission).filter(
             p => p !== Permission.Owner && p !== Permission.Public,
         );
-        expect(secondChannelData!.permissions).toEqual(nonOwnerPermissions);
+        expect(secondChannelData!.permissions.sort()).toEqual(nonOwnerPermissions);
     });
 
     it('customer has Authenticated permission on new channel', async () => {
         await shopClient.asUserWithCredentials(customerUser.emailAddress, 'test');
-        const { me } = await shopClient.query<Me.Query>(ME);
+        const { me } = await shopClient.query<Codegen.MeQuery>(ME);
 
         expect(me!.channels.length).toBe(2);
 
@@ -166,23 +155,23 @@ describe('Channels', () => {
     });
 
     it('createRole on second Channel', async () => {
-        const { createRole } = await adminClient.query<CreateRole.Mutation, CreateRole.Variables>(
-            CREATE_ROLE,
-            {
-                input: {
-                    description: 'second channel admin',
-                    code: 'second-channel-admin',
-                    channelIds: ['T_2'],
-                    permissions: [
-                        Permission.ReadCatalog,
-                        Permission.ReadSettings,
-                        Permission.ReadAdministrator,
-                        Permission.CreateAdministrator,
-                        Permission.UpdateAdministrator,
-                    ],
-                },
+        const { createRole } = await adminClient.query<
+            Codegen.CreateRoleMutation,
+            Codegen.CreateRoleMutationVariables
+        >(CREATE_ROLE, {
+            input: {
+                description: 'second channel admin',
+                code: 'second-channel-admin',
+                channelIds: ['T_2'],
+                permissions: [
+                    Permission.ReadCatalog,
+                    Permission.ReadSettings,
+                    Permission.ReadAdministrator,
+                    Permission.CreateAdministrator,
+                    Permission.UpdateAdministrator,
+                ],
             },
-        );
+        });
 
         expect(createRole.channels).toEqual([
             {
@@ -197,8 +186,8 @@ describe('Channels', () => {
 
     it('createAdministrator with second-channel-admin role', async () => {
         const { createAdministrator } = await adminClient.query<
-            CreateAdministrator.Mutation,
-            CreateAdministrator.Variables
+            Codegen.CreateAdministratorMutation,
+            Codegen.CreateAdministratorMutationVariables
         >(CREATE_ADMINISTRATOR, {
             input: {
                 firstName: 'Admin',
@@ -216,29 +205,32 @@ describe('Channels', () => {
         'cannot create role on channel for which admin does not have CreateAdministrator permission',
         assertThrowsWithMessage(async () => {
             await adminClient.asUserWithCredentials('admin2@test.com', 'test');
-            await adminClient.query<CreateRole.Mutation, CreateRole.Variables>(CREATE_ROLE, {
-                input: {
-                    description: 'read default channel catalog',
-                    code: 'read default channel catalog',
-                    channelIds: ['T_1'],
-                    permissions: [Permission.ReadCatalog],
+            await adminClient.query<Codegen.CreateRoleMutation, Codegen.CreateRoleMutationVariables>(
+                CREATE_ROLE,
+                {
+                    input: {
+                        description: 'read default channel catalog',
+                        code: 'read default channel catalog',
+                        channelIds: ['T_1'],
+                        permissions: [Permission.ReadCatalog],
+                    },
                 },
-            });
+            );
         }, 'You are not currently authorized to perform this action'),
     );
 
     it('can create role on channel for which admin has CreateAdministrator permission', async () => {
-        const { createRole } = await adminClient.query<CreateRole.Mutation, CreateRole.Variables>(
-            CREATE_ROLE,
-            {
-                input: {
-                    description: 'read second channel catalog',
-                    code: 'read-second-channel-catalog',
-                    channelIds: ['T_2'],
-                    permissions: [Permission.ReadCatalog],
-                },
+        const { createRole } = await adminClient.query<
+            Codegen.CreateRoleMutation,
+            Codegen.CreateRoleMutationVariables
+        >(CREATE_ROLE, {
+            input: {
+                description: 'read second channel catalog',
+                code: 'read-second-channel-catalog',
+                channelIds: ['T_2'],
+                permissions: [Permission.ReadCatalog],
             },
-        );
+        });
 
         expect(createRole.channels).toEqual([
             {
@@ -250,16 +242,16 @@ describe('Channels', () => {
     });
 
     it('createRole with no channelId implicitly uses active channel', async () => {
-        const { createRole } = await adminClient.query<CreateRole.Mutation, CreateRole.Variables>(
-            CREATE_ROLE,
-            {
-                input: {
-                    description: 'update second channel catalog',
-                    code: 'update-second-channel-catalog',
-                    permissions: [Permission.UpdateCatalog],
-                },
+        const { createRole } = await adminClient.query<
+            Codegen.CreateRoleMutation,
+            Codegen.CreateRoleMutationVariables
+        >(CREATE_ROLE, {
+            input: {
+                description: 'update second channel catalog',
+                code: 'update-second-channel-catalog',
+                permissions: [Permission.UpdateCatalog],
             },
-        );
+        });
 
         expect(createRole.channels).toEqual([
             {
@@ -275,8 +267,8 @@ describe('Channels', () => {
             await adminClient.asSuperAdmin();
             await adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
             const { updateChannel } = await adminClient.query<
-                UpdateChannel.Mutation,
-                UpdateChannel.Variables
+                Codegen.UpdateChannelMutation,
+                Codegen.UpdateChannelMutationVariables
             >(UPDATE_CHANNEL, {
                 input: {
                     id: 'T_1',
@@ -295,18 +287,18 @@ describe('Channels', () => {
         it('allows setting to an available language', async () => {
             await adminClient.asSuperAdmin();
             await adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
-            await adminClient.query<UpdateGlobalLanguages.Mutation, UpdateGlobalLanguages.Variables>(
-                UPDATE_GLOBAL_LANGUAGES,
-                {
-                    input: {
-                        availableLanguages: [LanguageCode.en, LanguageCode.zh],
-                    },
+            await adminClient.query<
+                Codegen.UpdateGlobalLanguagesMutation,
+                Codegen.UpdateGlobalLanguagesMutationVariables
+            >(UPDATE_GLOBAL_LANGUAGES, {
+                input: {
+                    availableLanguages: [LanguageCode.en, LanguageCode.zh],
                 },
-            );
+            });
 
             const { updateChannel } = await adminClient.query<
-                UpdateChannel.Mutation,
-                UpdateChannel.Variables
+                Codegen.UpdateChannelMutation,
+                Codegen.UpdateChannelMutationVariables
             >(UPDATE_CHANNEL, {
                 input: {
                     id: 'T_1',
@@ -324,8 +316,8 @@ describe('Channels', () => {
         await adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
 
         const { assignProductsToChannel } = await adminClient.query<
-            AssignProductsToChannel.Mutation,
-            AssignProductsToChannel.Variables
+            Codegen.AssignProductsToChannelMutation,
+            Codegen.AssignProductsToChannelMutationVariables
         >(ASSIGN_PRODUCT_TO_CHANNEL, {
             input: {
                 channelId: 'T_2',
@@ -338,21 +330,21 @@ describe('Channels', () => {
         shopClient.setChannelToken(SECOND_CHANNEL_TOKEN);
         await shopClient.query(GET_ACTIVE_ORDER);
 
-        const { deleteChannel } = await adminClient.query<DeleteChannel.Mutation, DeleteChannel.Variables>(
-            DELETE_CHANNEL,
-            {
-                id: 'T_2',
-            },
-        );
+        const { deleteChannel } = await adminClient.query<
+            Codegen.DeleteChannelMutation,
+            Codegen.DeleteChannelMutationVariables
+        >(DELETE_CHANNEL, {
+            id: 'T_2',
+        });
 
         expect(deleteChannel.result).toBe(DeletionResult.DELETED);
 
-        const { channels } = await adminClient.query<GetChannels.Query>(GET_CHANNELS);
+        const { channels } = await adminClient.query<Codegen.GetChannelsQuery>(GET_CHANNELS);
         expect(channels.map(c => c.id).sort()).toEqual(['T_1']);
 
         const { product } = await adminClient.query<
-            GetProductWithVariants.Query,
-            GetProductWithVariants.Variables
+            Codegen.GetProductWithVariantsQuery,
+            Codegen.GetProductWithVariantsQueryVariables
         >(GET_PRODUCT_WITH_VARIANTS, {
             id: PROD_ID,
         });

Plik diff jest za duży
+ 387 - 374
packages/core/e2e/collection.e2e-spec.ts


+ 6 - 5
packages/core/e2e/configurable-operation.e2e-spec.ts

@@ -12,7 +12,8 @@ import path from 'path';
 import { initialData } from '../../../e2e-common/e2e-initial-data';
 import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
 
-import { GetCheckers, UpdateShippingMethod } from './graphql/generated-e2e-admin-types';
+import { UpdateShippingMethodMutationVariables } from './graphql/generated-e2e-admin-types';
+import { GetCheckersQuery, UpdateShippingMethodMutation } from './graphql/generated-e2e-admin-types';
 import { UPDATE_SHIPPING_METHOD } from './graphql/shared-definitions';
 import { assertThrowsWithMessage } from './utils/assert-throws-with-message';
 
@@ -69,8 +70,8 @@ describe('Configurable operations', () => {
     describe('required args', () => {
         it('allows empty optional arg', async () => {
             const { updateShippingMethod } = await adminClient.query<
-                UpdateShippingMethod.Mutation,
-                UpdateShippingMethod.Variables
+                UpdateShippingMethodMutation,
+                UpdateShippingMethodMutationVariables
             >(UPDATE_SHIPPING_METHOD, {
                 input: {
                     id: 'T_1',
@@ -100,7 +101,7 @@ describe('Configurable operations', () => {
         it(
             'throws if a required arg is null',
             assertThrowsWithMessage(async () => {
-                await adminClient.query<UpdateShippingMethod.Mutation, UpdateShippingMethod.Variables>(
+                await adminClient.query<UpdateShippingMethodMutation, UpdateShippingMethodMutationVariables>(
                     UPDATE_SHIPPING_METHOD,
                     {
                         input: {
@@ -121,7 +122,7 @@ describe('Configurable operations', () => {
     });
 
     it('defaultValue', async () => {
-        const { shippingEligibilityCheckers } = await adminClient.query<GetCheckers.Query>(GET_CHECKERS);
+        const { shippingEligibilityCheckers } = await adminClient.query<GetCheckersQuery>(GET_CHECKERS);
         expect(shippingEligibilityCheckers[1].args.map(pick(['name', 'defaultValue']))).toEqual([
             { name: 'optional', defaultValue: null },
             { name: 'required', defaultValue: 'hello' },

+ 38 - 42
packages/core/e2e/country.e2e-spec.ts

@@ -6,15 +6,8 @@ import { initialData } from '../../../e2e-common/e2e-initial-data';
 import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
 
 import { COUNTRY_FRAGMENT } from './graphql/fragments';
-import {
-    CreateCountry,
-    DeleteCountry,
-    DeletionResult,
-    GetCountry,
-    GetCountryList,
-    LanguageCode,
-    UpdateCountry,
-} from './graphql/generated-e2e-admin-types';
+import { DeletionResult, GetCountryListQuery, LanguageCode } from './graphql/generated-e2e-admin-types';
+import * as Codegen from './graphql/generated-e2e-admin-types';
 import { GET_COUNTRY_LIST, UPDATE_COUNTRY } from './graphql/shared-definitions';
 
 // tslint:disable:no-non-null-assertion
@@ -22,8 +15,8 @@ import { GET_COUNTRY_LIST, UPDATE_COUNTRY } from './graphql/shared-definitions';
 describe('Country resolver', () => {
     const { server, adminClient } = createTestEnvironment(testConfig());
     let countries: GetCountryList.Items[];
-    let GB: GetCountryList.Items;
-    let AT: GetCountryList.Items;
+    let GB: GetCountryListQuery['countries']['items'][number];
+    let AT: GetCountryListQuery['countries']['items'][number];
 
     beforeAll(async () => {
         await server.init({
@@ -39,7 +32,7 @@ describe('Country resolver', () => {
     });
 
     it('countries', async () => {
-        const result = await adminClient.query<GetCountryList.Query>(GET_COUNTRY_LIST, {});
+        const result = await adminClient.query<Codegen.GetCountryListQuery>(GET_COUNTRY_LIST, {});
 
         expect(result.countries.totalItems).toBe(7);
         countries = result.countries.items;
@@ -48,70 +41,73 @@ describe('Country resolver', () => {
     });
 
     it('country', async () => {
-        const result = await adminClient.query<GetCountry.Query, GetCountry.Variables>(GET_COUNTRY, {
-            id: GB.id,
-        });
+        const result = await adminClient.query<Codegen.GetCountryQuery, Codegen.GetCountryQueryVariables>(
+            GET_COUNTRY,
+            {
+                id: GB.id,
+            },
+        );
 
         expect(result.country!.name).toBe(GB.name);
     });
 
     it('updateCountry', async () => {
-        const result = await adminClient.query<UpdateCountry.Mutation, UpdateCountry.Variables>(
-            UPDATE_COUNTRY,
-            {
-                input: {
-                    id: AT.id,
-                    enabled: false,
-                },
+        const result = await adminClient.query<
+            Codegen.UpdateCountryMutation,
+            Codegen.UpdateCountryMutationVariables
+        >(UPDATE_COUNTRY, {
+            input: {
+                id: AT.id,
+                enabled: false,
             },
-        );
+        });
 
         expect(result.updateCountry.enabled).toBe(false);
     });
 
     it('createCountry', async () => {
-        const result = await adminClient.query<CreateCountry.Mutation, CreateCountry.Variables>(
-            CREATE_COUNTRY,
-            {
-                input: {
-                    code: 'GL',
-                    enabled: true,
-                    translations: [{ languageCode: LanguageCode.en, name: 'Gondwanaland' }],
-                },
+        const result = await adminClient.query<
+            Codegen.CreateCountryMutation,
+            Codegen.CreateCountryMutationVariables
+        >(CREATE_COUNTRY, {
+            input: {
+                code: 'GL',
+                enabled: true,
+                translations: [{ languageCode: LanguageCode.en, name: 'Gondwanaland' }],
             },
-        );
+        });
 
         expect(result.createCountry.name).toBe('Gondwanaland');
     });
 
     describe('deletion', () => {
         it('deletes Country not used in any address', async () => {
-            const result1 = await adminClient.query<DeleteCountry.Mutation, DeleteCountry.Variables>(
-                DELETE_COUNTRY,
-                { id: AT.id },
-            );
+            const result1 = await adminClient.query<
+                Codegen.DeleteCountryMutation,
+                Codegen.DeleteCountryMutationVariables
+            >(DELETE_COUNTRY, { id: AT.id });
 
             expect(result1.deleteCountry).toEqual({
                 result: DeletionResult.DELETED,
                 message: '',
             });
 
-            const result2 = await adminClient.query<GetCountryList.Query>(GET_COUNTRY_LIST, {});
+            const result2 = await adminClient.query<Codegen.GetCountryListQuery>(GET_COUNTRY_LIST, {});
             expect(result2.countries.items.find(c => c.id === AT.id)).toBeUndefined();
         });
 
         it('does not delete Country that is used in one or more addresses', async () => {
-            const result1 = await adminClient.query<DeleteCountry.Mutation, DeleteCountry.Variables>(
-                DELETE_COUNTRY,
-                { id: GB.id },
-            );
+            const result1 = await adminClient.query<
+                Codegen.DeleteCountryMutation,
+                Codegen.DeleteCountryMutationVariables
+            >(DELETE_COUNTRY, { id: GB.id });
 
             expect(result1.deleteCountry).toEqual({
                 result: DeletionResult.NOT_DELETED,
                 message: 'The selected Country cannot be deleted as it is used in 1 Address',
             });
 
-            const result2 = await adminClient.query<GetCountryList.Query>(GET_COUNTRY_LIST, {});
+            const result2 = await adminClient.query<Codegen.GetCountryListQuery>(GET_COUNTRY_LIST, {});
             expect(result2.countries.items.find(c => c.id === GB.id)).not.toBeUndefined();
         });
     });

+ 1 - 1
packages/core/e2e/custom-field-relations.e2e-spec.ts

@@ -22,7 +22,7 @@ import path from 'path';
 import { initialData } from '../../../e2e-common/e2e-initial-data';
 import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
 
-import { AddItemToOrder } from './graphql/generated-e2e-shop-types';
+import { AddItemToOrderMutation } from './graphql/generated-e2e-shop-types';
 import { ADD_ITEM_TO_ORDER } from './graphql/shop-definitions';
 import { sortById } from './utils/test-order-utils';
 

+ 10 - 7
packages/core/e2e/custom-permissions.e2e-spec.ts

@@ -13,10 +13,13 @@ import {
 } from './fixtures/test-plugins/with-custom-permissions';
 import {
     AdministratorFragment,
-    CreateAdministrator,
-    CreateRole,
+    CreateAdministratorMutation,
+    CreateAdministratorMutationVariables,
+    CreateRoleMutation,
+    CreateRoleMutationVariables,
     RoleFragment,
-    UpdateRole,
+    UpdateRoleMutation,
+    UpdateRoleMutationVariables,
 } from './graphql/generated-e2e-admin-types';
 import { CREATE_ADMINISTRATOR, CREATE_ROLE, UPDATE_ROLE } from './graphql/shared-definitions';
 import { assertThrowsWithMessage } from './utils/assert-throws-with-message';
@@ -40,7 +43,7 @@ describe('Custom permissions', () => {
         await adminClient.asSuperAdmin();
 
         // create a new role and Admin and sign in as that Admin
-        const { createRole } = await adminClient.query<CreateRole.Mutation, CreateRole.Variables>(
+        const { createRole } = await adminClient.query<CreateRoleMutation, CreateRoleMutationVariables>(
             CREATE_ROLE,
             {
                 input: {
@@ -53,8 +56,8 @@ describe('Custom permissions', () => {
         );
         testRole = createRole;
         const { createAdministrator } = await adminClient.query<
-            CreateAdministrator.Mutation,
-            CreateAdministrator.Variables
+            CreateAdministratorMutation,
+            CreateAdministratorMutationVariables
         >(CREATE_ADMINISTRATOR, {
             input: {
                 firstName: 'Test',
@@ -148,7 +151,7 @@ describe('Custom permissions', () => {
     describe('adding permissions enables access', () => {
         beforeAll(async () => {
             await adminClient.asSuperAdmin();
-            await adminClient.query<UpdateRole.Mutation, UpdateRole.Variables>(UPDATE_ROLE, {
+            await adminClient.query<UpdateRoleMutation, UpdateRoleMutationVariables>(UPDATE_ROLE, {
                 input: {
                     id: testRole.id,
                     permissions: [

+ 145 - 126
packages/core/e2e/customer-channel.e2e-spec.ts

@@ -5,24 +5,9 @@ import path from 'path';
 import { initialData } from '../../../e2e-common/e2e-initial-data';
 import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
 
-import {
-    AddCustomersToGroup,
-    CreateAddress,
-    CreateChannel,
-    CreateCustomer,
-    CreateCustomerGroup,
-    CurrencyCode,
-    DeleteCustomer,
-    DeleteCustomerAddress,
-    GetCustomerGroup,
-    GetCustomerList,
-    LanguageCode,
-    Me,
-    RemoveCustomersFromGroup,
-    UpdateAddress,
-    UpdateCustomer,
-} from './graphql/generated-e2e-admin-types';
-import { Register } from './graphql/generated-e2e-shop-types';
+import * as Codegen from './graphql/generated-e2e-admin-types';
+import { CurrencyCode, LanguageCode } from './graphql/generated-e2e-admin-types';
+import { RegisterMutation, RegisterMutationVariables } from './graphql/generated-e2e-shop-types';
 import {
     ADD_CUSTOMERS_TO_GROUP,
     CREATE_ADDRESS,
@@ -40,12 +25,14 @@ import {
 import { DELETE_ADDRESS, REGISTER_ACCOUNT } from './graphql/shop-definitions';
 import { assertThrowsWithMessage } from './utils/assert-throws-with-message';
 
+type CustomerListItem = Codegen.GetCustomerListQuery['customers']['items'][number];
+
 describe('ChannelAware Customers', () => {
     const { server, adminClient, shopClient } = createTestEnvironment(testConfig());
     const SECOND_CHANNEL_TOKEN = 'second_channel_token';
-    let firstCustomer: GetCustomerList.Items;
-    let secondCustomer: GetCustomerList.Items;
-    let thirdCustomer: GetCustomerList.Items;
+    let firstCustomer: CustomerListItem;
+    let secondCustomer: CustomerListItem;
+    let thirdCustomer: CustomerListItem;
     const numberOfCustomers = 3;
     let customerGroupId: string;
 
@@ -57,31 +44,34 @@ describe('ChannelAware Customers', () => {
         });
         await adminClient.asSuperAdmin();
 
-        const { customers } = await adminClient.query<GetCustomerList.Query, GetCustomerList.Variables>(
-            GET_CUSTOMER_LIST,
-            {
-                options: { take: numberOfCustomers },
-            },
-        );
+        const { customers } = await adminClient.query<
+            Codegen.GetCustomerListQuery,
+            Codegen.GetCustomerListQueryVariables
+        >(GET_CUSTOMER_LIST, {
+            options: { take: numberOfCustomers },
+        });
         firstCustomer = customers.items[0];
         secondCustomer = customers.items[1];
         thirdCustomer = customers.items[2];
 
-        await adminClient.query<CreateChannel.Mutation, CreateChannel.Variables>(CREATE_CHANNEL, {
-            input: {
-                code: 'second-channel',
-                token: SECOND_CHANNEL_TOKEN,
-                defaultLanguageCode: LanguageCode.en,
-                currencyCode: CurrencyCode.GBP,
-                pricesIncludeTax: true,
-                defaultShippingZoneId: 'T_1',
-                defaultTaxZoneId: 'T_1',
+        await adminClient.query<Codegen.CreateChannelMutation, Codegen.CreateChannelMutationVariables>(
+            CREATE_CHANNEL,
+            {
+                input: {
+                    code: 'second-channel',
+                    token: SECOND_CHANNEL_TOKEN,
+                    defaultLanguageCode: LanguageCode.en,
+                    currencyCode: CurrencyCode.GBP,
+                    pricesIncludeTax: true,
+                    defaultShippingZoneId: 'T_1',
+                    defaultTaxZoneId: 'T_1',
+                },
             },
-        });
+        );
 
         const { createCustomerGroup } = await adminClient.query<
-            CreateCustomerGroup.Mutation,
-            CreateCustomerGroup.Variables
+            Codegen.CreateCustomerGroupMutation,
+            Codegen.CreateCustomerGroupMutationVariables
         >(CREATE_CUSTOMER_GROUP, {
             input: {
                 name: 'TestGroup',
@@ -99,7 +89,10 @@ describe('ChannelAware Customers', () => {
             'throws when updating address from customer from other channel',
             assertThrowsWithMessage(async () => {
                 adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
-                await adminClient.query<UpdateAddress.Mutation, UpdateAddress.Variables>(UPDATE_ADDRESS, {
+                await adminClient.query<
+                    Codegen.UpdateAddressMutation,
+                    Codegen.UpdateAddressMutationVariables
+                >(UPDATE_ADDRESS, {
                     input: {
                         id: 'T_1',
                         streetLine1: 'Dummy street',
@@ -112,7 +105,10 @@ describe('ChannelAware Customers', () => {
             'throws when creating address for customer from other channel',
             assertThrowsWithMessage(async () => {
                 adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
-                await adminClient.query<CreateAddress.Mutation, CreateAddress.Variables>(CREATE_ADDRESS, {
+                await adminClient.query<
+                    Codegen.CreateAddressMutation,
+                    Codegen.CreateAddressMutationVariables
+                >(CREATE_ADDRESS, {
                     id: firstCustomer.id,
                     input: {
                         streetLine1: 'Dummy street',
@@ -126,12 +122,12 @@ describe('ChannelAware Customers', () => {
             'throws when deleting address from customer from other channel',
             assertThrowsWithMessage(async () => {
                 adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
-                await adminClient.query<DeleteCustomerAddress.Mutation, DeleteCustomerAddress.Variables>(
-                    DELETE_ADDRESS,
-                    {
-                        id: 'T_1',
-                    },
-                );
+                await adminClient.query<
+                    Codegen.DeleteCustomerAddressMutation,
+                    Codegen.DeleteCustomerAddressMutationVariables
+                >(DELETE_ADDRESS, {
+                    id: 'T_1',
+                });
             }, `No Address with the id '1' could be found`),
         );
     });
@@ -141,7 +137,10 @@ describe('ChannelAware Customers', () => {
             'throws when deleting customer from other channel',
             assertThrowsWithMessage(async () => {
                 adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
-                await adminClient.query<DeleteCustomer.Mutation, DeleteCustomer.Variables>(DELETE_CUSTOMER, {
+                await adminClient.query<
+                    Codegen.DeleteCustomerMutation,
+                    Codegen.DeleteCustomerMutationVariables
+                >(DELETE_CUSTOMER, {
                     id: firstCustomer.id,
                 });
             }, `No Customer with the id '1' could be found`),
@@ -151,7 +150,10 @@ describe('ChannelAware Customers', () => {
             'throws when updating customer from other channel',
             assertThrowsWithMessage(async () => {
                 adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
-                await adminClient.query<UpdateCustomer.Mutation, UpdateCustomer.Variables>(UPDATE_CUSTOMER, {
+                await adminClient.query<
+                    Codegen.UpdateCustomerMutation,
+                    Codegen.UpdateCustomerMutationVariables
+                >(UPDATE_CUSTOMER, {
                     input: {
                         id: firstCustomer.id,
                         firstName: 'John',
@@ -163,21 +165,24 @@ describe('ChannelAware Customers', () => {
 
         it('creates customers on current and default channel', async () => {
             adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
-            await adminClient.query<CreateCustomer.Mutation, CreateCustomer.Variables>(CREATE_CUSTOMER, {
-                input: {
-                    firstName: 'John',
-                    lastName: 'Doe',
-                    emailAddress: 'john.doe@test.com',
+            await adminClient.query<Codegen.CreateCustomerMutation, Codegen.CreateCustomerMutationVariables>(
+                CREATE_CUSTOMER,
+                {
+                    input: {
+                        firstName: 'John',
+                        lastName: 'Doe',
+                        emailAddress: 'john.doe@test.com',
+                    },
                 },
-            });
+            );
             const customersSecondChannel = await adminClient.query<
-                GetCustomerList.Query,
-                GetCustomerList.Variables
+                Codegen.GetCustomerListQuery,
+                Codegen.GetCustomerListQueryVariables
             >(GET_CUSTOMER_LIST);
             adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
             const customersDefaultChannel = await adminClient.query<
-                GetCustomerList.Query,
-                GetCustomerList.Variables
+                Codegen.GetCustomerListQuery,
+                Codegen.GetCustomerListQueryVariables
             >(GET_CUSTOMER_LIST);
 
             expect(customersSecondChannel.customers.totalItems).toBe(1);
@@ -186,30 +191,32 @@ describe('ChannelAware Customers', () => {
 
         it('only shows customers from current channel', async () => {
             adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
-            const { customers } = await adminClient.query<GetCustomerList.Query, GetCustomerList.Variables>(
-                GET_CUSTOMER_LIST,
-            );
+            const { customers } = await adminClient.query<
+                Codegen.GetCustomerListQuery,
+                Codegen.GetCustomerListQueryVariables
+            >(GET_CUSTOMER_LIST);
             expect(customers.totalItems).toBe(1);
         });
 
         it('shows all customers on default channel', async () => {
             adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
-            const { customers } = await adminClient.query<GetCustomerList.Query, GetCustomerList.Variables>(
-                GET_CUSTOMER_LIST,
-            );
+            const { customers } = await adminClient.query<
+                Codegen.GetCustomerListQuery,
+                Codegen.GetCustomerListQueryVariables
+            >(GET_CUSTOMER_LIST);
             expect(customers.totalItems).toBe(numberOfCustomers + 1);
         });
 
         it('brings customer to current channel when creating with existing emailAddress', async () => {
             adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
             let customersDefaultChannel = await adminClient.query<
-                GetCustomerList.Query,
-                GetCustomerList.Variables
+                Codegen.GetCustomerListQuery,
+                Codegen.GetCustomerListQueryVariables
             >(GET_CUSTOMER_LIST);
             adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
             let customersSecondChannel = await adminClient.query<
-                GetCustomerList.Query,
-                GetCustomerList.Variables
+                Codegen.GetCustomerListQuery,
+                Codegen.GetCustomerListQueryVariables
             >(GET_CUSTOMER_LIST);
             expect(customersDefaultChannel.customers.items.map(customer => customer.emailAddress)).toContain(
                 firstCustomer.emailAddress,
@@ -218,22 +225,25 @@ describe('ChannelAware Customers', () => {
                 customersSecondChannel.customers.items.map(customer => customer.emailAddress),
             ).not.toContain(firstCustomer.emailAddress);
 
-            await adminClient.query<CreateCustomer.Mutation, CreateCustomer.Variables>(CREATE_CUSTOMER, {
-                input: {
-                    firstName: firstCustomer.firstName + '_new',
-                    lastName: firstCustomer.lastName + '_new',
-                    emailAddress: firstCustomer.emailAddress,
+            await adminClient.query<Codegen.CreateCustomerMutation, Codegen.CreateCustomerMutationVariables>(
+                CREATE_CUSTOMER,
+                {
+                    input: {
+                        firstName: firstCustomer.firstName + '_new',
+                        lastName: firstCustomer.lastName + '_new',
+                        emailAddress: firstCustomer.emailAddress,
+                    },
                 },
-            });
+            );
 
             customersSecondChannel = await adminClient.query<
-                GetCustomerList.Query,
-                GetCustomerList.Variables
+                Codegen.GetCustomerListQuery,
+                Codegen.GetCustomerListQueryVariables
             >(GET_CUSTOMER_LIST);
             adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
             customersDefaultChannel = await adminClient.query<
-                GetCustomerList.Query,
-                GetCustomerList.Variables
+                Codegen.GetCustomerListQuery,
+                Codegen.GetCustomerListQueryVariables
             >(GET_CUSTOMER_LIST);
             const firstCustomerOnNewChannel = customersSecondChannel.customers.items.find(
                 customer => customer.emailAddress === firstCustomer.emailAddress,
@@ -258,12 +268,13 @@ describe('ChannelAware Customers', () => {
         it('assigns authenticated customers to the channels they visit', async () => {
             shopClient.setChannelToken(SECOND_CHANNEL_TOKEN);
             await shopClient.asUserWithCredentials(secondCustomer.emailAddress, 'test');
-            await shopClient.query<Me.Query>(ME);
+            await shopClient.query<Codegen.MeQuery>(ME);
 
             adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
-            const { customers } = await adminClient.query<GetCustomerList.Query, GetCustomerList.Variables>(
-                GET_CUSTOMER_LIST,
-            );
+            const { customers } = await adminClient.query<
+                Codegen.GetCustomerListQuery,
+                Codegen.GetCustomerListQueryVariables
+            >(GET_CUSTOMER_LIST);
             expect(customers.totalItems).toBe(3);
             expect(customers.items.map(customer => customer.emailAddress)).toContain(
                 secondCustomer.emailAddress,
@@ -273,16 +284,17 @@ describe('ChannelAware Customers', () => {
         it('assigns newly registered customers to channel', async () => {
             shopClient.setChannelToken(SECOND_CHANNEL_TOKEN);
             await shopClient.asAnonymousUser();
-            await shopClient.query<Register.Mutation, Register.Variables>(REGISTER_ACCOUNT, {
+            await shopClient.query<RegisterMutation, RegisterMutationVariables>(REGISTER_ACCOUNT, {
                 input: {
                     emailAddress: 'john.doe.2@test.com',
                 },
             });
 
             adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
-            const { customers } = await adminClient.query<GetCustomerList.Query, GetCustomerList.Variables>(
-                GET_CUSTOMER_LIST,
-            );
+            const { customers } = await adminClient.query<
+                Codegen.GetCustomerListQuery,
+                Codegen.GetCustomerListQueryVariables
+            >(GET_CUSTOMER_LIST);
             expect(customers.totalItems).toBe(4);
             expect(customers.items.map(customer => customer.emailAddress)).toContain('john.doe.2@test.com');
         });
@@ -290,31 +302,38 @@ describe('ChannelAware Customers', () => {
         // https://github.com/vendure-ecommerce/vendure/issues/834
         it('handles concurrent assignments to a new channel', async () => {
             const THIRD_CHANNEL_TOKEN = 'third_channel_token';
-            await adminClient.query<CreateChannel.Mutation, CreateChannel.Variables>(CREATE_CHANNEL, {
-                input: {
-                    code: 'third-channel',
-                    token: THIRD_CHANNEL_TOKEN,
-                    defaultLanguageCode: LanguageCode.en,
-                    currencyCode: CurrencyCode.GBP,
-                    pricesIncludeTax: true,
-                    defaultShippingZoneId: 'T_1',
-                    defaultTaxZoneId: 'T_1',
+            await adminClient.query<Codegen.CreateChannelMutation, Codegen.CreateChannelMutationVariables>(
+                CREATE_CHANNEL,
+                {
+                    input: {
+                        code: 'third-channel',
+                        token: THIRD_CHANNEL_TOKEN,
+                        defaultLanguageCode: LanguageCode.en,
+                        currencyCode: CurrencyCode.GBP,
+                        pricesIncludeTax: true,
+                        defaultShippingZoneId: 'T_1',
+                        defaultTaxZoneId: 'T_1',
+                    },
                 },
-            });
+            );
 
             await shopClient.asUserWithCredentials(secondCustomer.emailAddress, 'test');
             shopClient.setChannelToken(THIRD_CHANNEL_TOKEN);
 
             try {
-                await Promise.all([shopClient.query<Me.Query>(ME), shopClient.query<Me.Query>(ME)]);
+                await Promise.all([
+                    shopClient.query<Codegen.MeQuery>(ME),
+                    shopClient.query<Codegen.MeQuery>(ME),
+                ]);
             } catch (e: any) {
                 fail('Threw: ' + e.message);
             }
 
             adminClient.setChannelToken(THIRD_CHANNEL_TOKEN);
-            const { customers } = await adminClient.query<GetCustomerList.Query, GetCustomerList.Variables>(
-                GET_CUSTOMER_LIST,
-            );
+            const { customers } = await adminClient.query<
+                Codegen.GetCustomerListQuery,
+                Codegen.GetCustomerListQueryVariables
+            >(GET_CUSTOMER_LIST);
             expect(customers.totalItems).toBe(1);
             expect(customers.items.map(customer => customer.emailAddress)).toContain(
                 secondCustomer.emailAddress,
@@ -325,18 +344,18 @@ describe('ChannelAware Customers', () => {
     describe('Customergroup manipulation', () => {
         it('does not add a customer from another channel to customerGroup', async () => {
             adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
-            await adminClient.query<AddCustomersToGroup.Mutation, AddCustomersToGroup.Variables>(
-                ADD_CUSTOMERS_TO_GROUP,
-                {
-                    groupId: customerGroupId,
-                    customerIds: [thirdCustomer.id],
-                },
-            );
+            await adminClient.query<
+                Codegen.AddCustomersToGroupMutation,
+                Codegen.AddCustomersToGroupMutationVariables
+            >(ADD_CUSTOMERS_TO_GROUP, {
+                groupId: customerGroupId,
+                customerIds: [thirdCustomer.id],
+            });
 
             adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
             const { customerGroup } = await adminClient.query<
-                GetCustomerGroup.Query,
-                GetCustomerGroup.Variables
+                Codegen.GetCustomerGroupQuery,
+                Codegen.GetCustomerGroupQueryVariables
             >(GET_CUSTOMER_GROUP, {
                 id: customerGroupId,
             });
@@ -345,18 +364,18 @@ describe('ChannelAware Customers', () => {
 
         it('only shows customers from current channel in customerGroup', async () => {
             adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
-            await adminClient.query<AddCustomersToGroup.Mutation, AddCustomersToGroup.Variables>(
-                ADD_CUSTOMERS_TO_GROUP,
-                {
-                    groupId: customerGroupId,
-                    customerIds: [secondCustomer.id, thirdCustomer.id],
-                },
-            );
+            await adminClient.query<
+                Codegen.AddCustomersToGroupMutation,
+                Codegen.AddCustomersToGroupMutationVariables
+            >(ADD_CUSTOMERS_TO_GROUP, {
+                groupId: customerGroupId,
+                customerIds: [secondCustomer.id, thirdCustomer.id],
+            });
 
             adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
             const { customerGroup } = await adminClient.query<
-                GetCustomerGroup.Query,
-                GetCustomerGroup.Variables
+                Codegen.GetCustomerGroupQuery,
+                Codegen.GetCustomerGroupQueryVariables
             >(GET_CUSTOMER_GROUP, {
                 id: customerGroupId,
             });
@@ -366,13 +385,13 @@ describe('ChannelAware Customers', () => {
 
         it('throws when deleting customer from other channel from customerGroup', async () => {
             adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
-            await adminClient.query<RemoveCustomersFromGroup.Mutation, RemoveCustomersFromGroup.Variables>(
-                REMOVE_CUSTOMERS_FROM_GROUP,
-                {
-                    groupId: customerGroupId,
-                    customerIds: [thirdCustomer.id],
-                },
-            );
+            await adminClient.query<
+                Codegen.RemoveCustomersFromGroupMutation,
+                Codegen.RemoveCustomersFromGroupMutationVariables
+            >(REMOVE_CUSTOMERS_FROM_GROUP, {
+                groupId: customerGroupId,
+                customerIds: [thirdCustomer.id],
+            });
         });
     });
 });

+ 71 - 80
packages/core/e2e/customer-group.e2e-spec.ts

@@ -5,19 +5,8 @@ import path from 'path';
 import { initialData } from '../../../e2e-common/e2e-initial-data';
 import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
 
-import {
-    AddCustomersToGroup,
-    CreateCustomerGroup,
-    DeleteCustomerGroup,
-    GetCustomerGroup,
-    GetCustomerGroups,
-    GetCustomerHistory,
-    GetCustomerList,
-    GetCustomerWithGroups,
-    HistoryEntryType,
-    RemoveCustomersFromGroup,
-    UpdateCustomerGroup,
-} from './graphql/generated-e2e-admin-types';
+import * as Codegen from './graphql/generated-e2e-admin-types';
+import { HistoryEntryType } from './graphql/generated-e2e-admin-types';
 import { DeletionResult } from './graphql/generated-e2e-shop-types';
 import {
     ADD_CUSTOMERS_TO_GROUP,
@@ -37,7 +26,7 @@ import { sortById } from './utils/test-order-utils';
 describe('CustomerGroup resolver', () => {
     const { server, adminClient, shopClient } = createTestEnvironment(testConfig());
 
-    let customers: GetCustomerList.Items[];
+    let customers: Codegen.GetCustomerListQuery['customers']['items'];
 
     beforeAll(async () => {
         await server.init({
@@ -46,7 +35,7 @@ describe('CustomerGroup resolver', () => {
             customerCount: 5,
         });
         await adminClient.asSuperAdmin();
-        const result = await adminClient.query<GetCustomerList.Query>(GET_CUSTOMER_LIST);
+        const result = await adminClient.query<Codegen.GetCustomerListQuery>(GET_CUSTOMER_LIST);
         customers = result.customers.items;
     }, TEST_SETUP_TIMEOUT_MS);
 
@@ -56,8 +45,8 @@ describe('CustomerGroup resolver', () => {
 
     it('create', async () => {
         const { createCustomerGroup } = await adminClient.query<
-            CreateCustomerGroup.Mutation,
-            CreateCustomerGroup.Variables
+            Codegen.CreateCustomerGroupMutation,
+            Codegen.CreateCustomerGroupMutationVariables
         >(CREATE_CUSTOMER_GROUP, {
             input: {
                 name: 'group 1',
@@ -73,15 +62,15 @@ describe('CustomerGroup resolver', () => {
     });
 
     it('history entry for CUSTOMER_ADDED_TO_GROUP after group created', async () => {
-        const { customer } = await adminClient.query<GetCustomerHistory.Query, GetCustomerHistory.Variables>(
-            GET_CUSTOMER_HISTORY,
-            {
-                id: customers[0].id,
-                options: {
-                    skip: 3,
-                },
+        const { customer } = await adminClient.query<
+            Codegen.GetCustomerHistoryQuery,
+            Codegen.GetCustomerHistoryQueryVariables
+        >(GET_CUSTOMER_HISTORY, {
+            id: customers[0].id,
+            options: {
+                skip: 3,
             },
-        );
+        });
 
         expect(customer?.history.items.map(pick(['type', 'data']))).toEqual([
             {
@@ -95,8 +84,8 @@ describe('CustomerGroup resolver', () => {
 
     it('customerGroups', async () => {
         const { customerGroups } = await adminClient.query<
-            GetCustomerGroups.Query,
-            GetCustomerGroups.Variables
+            Codegen.GetCustomerGroupsQuery,
+            Codegen.GetCustomerGroupsQueryVariables
         >(GET_CUSTOMER_GROUPS, {
             options: {},
         });
@@ -106,15 +95,15 @@ describe('CustomerGroup resolver', () => {
     });
 
     it('customerGroup with customer list options', async () => {
-        const { customerGroup } = await adminClient.query<GetCustomerGroup.Query, GetCustomerGroup.Variables>(
-            GET_CUSTOMER_GROUP,
-            {
-                id: 'T_1',
-                options: {
-                    take: 1,
-                },
+        const { customerGroup } = await adminClient.query<
+            Codegen.GetCustomerGroupQuery,
+            Codegen.GetCustomerGroupQueryVariables
+        >(GET_CUSTOMER_GROUP, {
+            id: 'T_1',
+            options: {
+                take: 1,
             },
-        );
+        });
 
         expect(customerGroup?.id).toBe('T_1');
         expect(customerGroup?.name).toBe('group 1');
@@ -124,8 +113,8 @@ describe('CustomerGroup resolver', () => {
 
     it('update', async () => {
         const { updateCustomerGroup } = await adminClient.query<
-            UpdateCustomerGroup.Mutation,
-            UpdateCustomerGroup.Variables
+            Codegen.UpdateCustomerGroupMutation,
+            Codegen.UpdateCustomerGroupMutationVariables
         >(UPDATE_CUSTOMER_GROUP, {
             input: {
                 id: 'T_1',
@@ -138,8 +127,8 @@ describe('CustomerGroup resolver', () => {
 
     it('addCustomersToGroup with existing customer', async () => {
         const { addCustomersToGroup } = await adminClient.query<
-            AddCustomersToGroup.Mutation,
-            AddCustomersToGroup.Variables
+            Codegen.AddCustomersToGroupMutation,
+            Codegen.AddCustomersToGroupMutationVariables
         >(ADD_CUSTOMERS_TO_GROUP, {
             groupId: 'T_1',
             customerIds: [customers[0].id],
@@ -152,8 +141,8 @@ describe('CustomerGroup resolver', () => {
 
     it('addCustomersToGroup with new customers', async () => {
         const { addCustomersToGroup } = await adminClient.query<
-            AddCustomersToGroup.Mutation,
-            AddCustomersToGroup.Variables
+            Codegen.AddCustomersToGroupMutation,
+            Codegen.AddCustomersToGroupMutationVariables
         >(ADD_CUSTOMERS_TO_GROUP, {
             groupId: 'T_1',
             customerIds: [customers[2].id, customers[3].id],
@@ -168,17 +157,17 @@ describe('CustomerGroup resolver', () => {
     });
 
     it('history entry for CUSTOMER_ADDED_TO_GROUP not duplicated', async () => {
-        const { customer } = await adminClient.query<GetCustomerHistory.Query, GetCustomerHistory.Variables>(
-            GET_CUSTOMER_HISTORY,
-            {
-                id: customers[0].id,
-                options: {
-                    filter: {
-                        type: { eq: HistoryEntryType.CUSTOMER_ADDED_TO_GROUP },
-                    },
+        const { customer } = await adminClient.query<
+            Codegen.GetCustomerHistoryQuery,
+            Codegen.GetCustomerHistoryQueryVariables
+        >(GET_CUSTOMER_HISTORY, {
+            id: customers[0].id,
+            options: {
+                filter: {
+                    type: { eq: HistoryEntryType.CUSTOMER_ADDED_TO_GROUP },
                 },
             },
-        );
+        });
 
         expect(customer?.history.items.map(pick(['type', 'data']))).toEqual([
             {
@@ -191,15 +180,15 @@ describe('CustomerGroup resolver', () => {
     });
 
     it('history entry for CUSTOMER_ADDED_TO_GROUP after customer added', async () => {
-        const { customer } = await adminClient.query<GetCustomerHistory.Query, GetCustomerHistory.Variables>(
-            GET_CUSTOMER_HISTORY,
-            {
-                id: customers[2].id,
-                options: {
-                    skip: 3,
-                },
+        const { customer } = await adminClient.query<
+            Codegen.GetCustomerHistoryQuery,
+            Codegen.GetCustomerHistoryQueryVariables
+        >(GET_CUSTOMER_HISTORY, {
+            id: customers[2].id,
+            options: {
+                skip: 3,
             },
-        );
+        });
 
         expect(customer?.history.items.map(pick(['type', 'data']))).toEqual([
             {
@@ -213,8 +202,8 @@ describe('CustomerGroup resolver', () => {
 
     it('customer.groups field resolver', async () => {
         const { customer } = await adminClient.query<
-            GetCustomerWithGroups.Query,
-            GetCustomerWithGroups.Variables
+            Codegen.GetCustomerWithGroupsQuery,
+            Codegen.GetCustomerWithGroupsQueryVariables
         >(GET_CUSTOMER_WITH_GROUPS, {
             id: customers[0].id,
         });
@@ -225,20 +214,20 @@ describe('CustomerGroup resolver', () => {
     it(
         'removeCustomersFromGroup with invalid customerId',
         assertThrowsWithMessage(async () => {
-            await adminClient.query<RemoveCustomersFromGroup.Mutation, RemoveCustomersFromGroup.Variables>(
-                REMOVE_CUSTOMERS_FROM_GROUP,
-                {
-                    groupId: 'T_1',
-                    customerIds: [customers[4].id],
-                },
-            );
+            await adminClient.query<
+                Codegen.RemoveCustomersFromGroupMutation,
+                Codegen.RemoveCustomersFromGroupMutationVariables
+            >(REMOVE_CUSTOMERS_FROM_GROUP, {
+                groupId: 'T_1',
+                customerIds: [customers[4].id],
+            });
         }, `Customer does not belong to this CustomerGroup`),
     );
 
     it('removeCustomersFromGroup with valid customerIds', async () => {
         const { removeCustomersFromGroup } = await adminClient.query<
-            RemoveCustomersFromGroup.Mutation,
-            RemoveCustomersFromGroup.Variables
+            Codegen.RemoveCustomersFromGroupMutation,
+            Codegen.RemoveCustomersFromGroupMutationVariables
         >(REMOVE_CUSTOMERS_FROM_GROUP, {
             groupId: 'T_1',
             customerIds: [customers[1].id, customers[3].id],
@@ -251,15 +240,15 @@ describe('CustomerGroup resolver', () => {
     });
 
     it('history entry for CUSTOMER_REMOVED_FROM_GROUP', async () => {
-        const { customer } = await adminClient.query<GetCustomerHistory.Query, GetCustomerHistory.Variables>(
-            GET_CUSTOMER_HISTORY,
-            {
-                id: customers[1].id,
-                options: {
-                    skip: 4,
-                },
+        const { customer } = await adminClient.query<
+            Codegen.GetCustomerHistoryQuery,
+            Codegen.GetCustomerHistoryQueryVariables
+        >(GET_CUSTOMER_HISTORY, {
+            id: customers[1].id,
+            options: {
+                skip: 4,
             },
-        );
+        });
 
         expect(customer?.history.items.map(pick(['type', 'data']))).toEqual([
             {
@@ -273,8 +262,8 @@ describe('CustomerGroup resolver', () => {
 
     it('deleteCustomerGroup', async () => {
         const { deleteCustomerGroup } = await adminClient.query<
-            DeleteCustomerGroup.Mutation,
-            DeleteCustomerGroup.Variables
+            Codegen.DeleteCustomerGroupMutation,
+            Codegen.DeleteCustomerGroupMutationVariables
         >(DELETE_CUSTOMER_GROUP, {
             id: 'T_1',
         });
@@ -282,7 +271,9 @@ describe('CustomerGroup resolver', () => {
         expect(deleteCustomerGroup.message).toBeNull();
         expect(deleteCustomerGroup.result).toBe(DeletionResult.DELETED);
 
-        const { customerGroups } = await adminClient.query<GetCustomerGroups.Query>(GET_CUSTOMER_GROUPS);
+        const { customerGroups } = await adminClient.query<Codegen.GetCustomerGroupsQuery>(
+            GET_CUSTOMER_GROUPS,
+        );
         expect(customerGroups.totalItems).toBe(0);
     });
 });

+ 179 - 162
packages/core/e2e/customer.e2e-spec.ts

@@ -17,27 +17,13 @@ import { initialData } from '../../../e2e-common/e2e-initial-data';
 import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
 
 import { CUSTOMER_FRAGMENT } from './graphql/fragments';
+import { DeletionResult, ErrorCode } from './graphql/generated-e2e-admin-types';
+import * as Codegen from './graphql/generated-e2e-admin-types';
 import {
-    AddNoteToCustomer,
-    CreateAddress,
-    CreateCustomer,
-    CustomerFragment,
-    DeleteCustomer,
-    DeleteCustomerAddress,
-    DeleteCustomerNote,
-    DeletionResult,
-    ErrorCode,
-    GetCustomer,
-    GetCustomerHistory,
-    GetCustomerList,
-    GetCustomerOrders,
-    GetCustomerWithUser,
-    Me,
-    UpdateAddress,
-    UpdateCustomer,
-    UpdateCustomerNote,
-} from './graphql/generated-e2e-admin-types';
-import { AddItemToOrder, UpdatedOrderFragment } from './graphql/generated-e2e-shop-types';
+    AddItemToOrderMutation,
+    AddItemToOrderMutationVariables,
+    UpdatedOrderFragment,
+} from './graphql/generated-e2e-shop-types';
 import {
     CREATE_ADDRESS,
     CREATE_CUSTOMER,
@@ -74,16 +60,18 @@ class TestEmailPlugin implements OnModuleInit {
     }
 }
 
+type CustomerListItem = Codegen.GetCustomerListQuery['customers']['items'][number];
+
 describe('Customer resolver', () => {
     const { server, adminClient, shopClient } = createTestEnvironment(
         mergeConfig(testConfig(), { plugins: [TestEmailPlugin] }),
     );
 
-    let firstCustomer: GetCustomerList.Items;
-    let secondCustomer: GetCustomerList.Items;
-    let thirdCustomer: GetCustomerList.Items;
+    let firstCustomer: CustomerListItem;
+    let secondCustomer: CustomerListItem;
+    let thirdCustomer: CustomerListItem;
 
-    const customerErrorGuard: ErrorResultGuard<CustomerFragment> = createErrorResultGuard(
+    const customerErrorGuard: ErrorResultGuard<Codegen.CustomerFragment> = createErrorResultGuard(
         input => !!input.emailAddress,
     );
 
@@ -101,9 +89,10 @@ describe('Customer resolver', () => {
     });
 
     it('customers list', async () => {
-        const result = await adminClient.query<GetCustomerList.Query, GetCustomerList.Variables>(
-            GET_CUSTOMER_LIST,
-        );
+        const result = await adminClient.query<
+            Codegen.GetCustomerListQuery,
+            Codegen.GetCustomerListQueryVariables
+        >(GET_CUSTOMER_LIST);
 
         expect(result.customers.items.length).toBe(5);
         expect(result.customers.totalItems).toBe(5);
@@ -113,18 +102,18 @@ describe('Customer resolver', () => {
     });
 
     it('customers list filter by postalCode', async () => {
-        const result = await adminClient.query<GetCustomerList.Query, GetCustomerList.Variables>(
-            GET_CUSTOMER_LIST,
-            {
-                options: {
-                    filter: {
-                        postalCode: {
-                            eq: 'NU9 0PW',
-                        },
+        const result = await adminClient.query<
+            Codegen.GetCustomerListQuery,
+            Codegen.GetCustomerListQueryVariables
+        >(GET_CUSTOMER_LIST, {
+            options: {
+                filter: {
+                    postalCode: {
+                        eq: 'NU9 0PW',
                     },
                 },
             },
-        );
+        });
 
         expect(result.customers.items.length).toBe(1);
         expect(result.customers.items[0].emailAddress).toBe('eliezer56@yahoo.com');
@@ -132,8 +121,8 @@ describe('Customer resolver', () => {
 
     it('customer resolver resolves User', async () => {
         const { customer } = await adminClient.query<
-            GetCustomerWithUser.Query,
-            GetCustomerWithUser.Variables
+            Codegen.GetCustomerWithUserQuery,
+            Codegen.GetCustomerWithUserQueryVariables
         >(GET_CUSTOMER_WITH_USER, {
             id: firstCustomer.id,
         });
@@ -153,37 +142,40 @@ describe('Customer resolver', () => {
             'createCustomerAddress throws on invalid countryCode',
             assertThrowsWithMessage(
                 () =>
-                    adminClient.query<CreateAddress.Mutation, CreateAddress.Variables>(CREATE_ADDRESS, {
-                        id: firstCustomer.id,
-                        input: {
-                            streetLine1: 'streetLine1',
-                            countryCode: 'INVALID',
+                    adminClient.query<Codegen.CreateAddressMutation, Codegen.CreateAddressMutationVariables>(
+                        CREATE_ADDRESS,
+                        {
+                            id: firstCustomer.id,
+                            input: {
+                                streetLine1: 'streetLine1',
+                                countryCode: 'INVALID',
+                            },
                         },
-                    }),
+                    ),
                 `The countryCode "INVALID" was not recognized`,
             ),
         );
 
         it('createCustomerAddress creates a new address', async () => {
-            const result = await adminClient.query<CreateAddress.Mutation, CreateAddress.Variables>(
-                CREATE_ADDRESS,
-                {
-                    id: firstCustomer.id,
-                    input: {
-                        fullName: 'fullName',
-                        company: 'company',
-                        streetLine1: 'streetLine1',
-                        streetLine2: 'streetLine2',
-                        city: 'city',
-                        province: 'province',
-                        postalCode: 'postalCode',
-                        countryCode: 'GB',
-                        phoneNumber: 'phoneNumber',
-                        defaultShippingAddress: false,
-                        defaultBillingAddress: false,
-                    },
+            const result = await adminClient.query<
+                Codegen.CreateAddressMutation,
+                Codegen.CreateAddressMutationVariables
+            >(CREATE_ADDRESS, {
+                id: firstCustomer.id,
+                input: {
+                    fullName: 'fullName',
+                    company: 'company',
+                    streetLine1: 'streetLine1',
+                    streetLine2: 'streetLine2',
+                    city: 'city',
+                    province: 'province',
+                    postalCode: 'postalCode',
+                    countryCode: 'GB',
+                    phoneNumber: 'phoneNumber',
+                    defaultShippingAddress: false,
+                    defaultBillingAddress: false,
                 },
-            );
+            });
             expect(omit(result.createCustomerAddress, ['id'])).toEqual({
                 fullName: 'fullName',
                 company: 'company',
@@ -203,7 +195,10 @@ describe('Customer resolver', () => {
         });
 
         it('customer query returns addresses', async () => {
-            const result = await adminClient.query<GetCustomer.Query, GetCustomer.Variables>(GET_CUSTOMER, {
+            const result = await adminClient.query<
+                Codegen.GetCustomerQuery,
+                Codegen.GetCustomerQueryVariables
+            >(GET_CUSTOMER, {
                 id: firstCustomer.id,
             });
 
@@ -212,15 +207,15 @@ describe('Customer resolver', () => {
         });
 
         it('updateCustomerAddress updates the country', async () => {
-            const result = await adminClient.query<UpdateAddress.Mutation, UpdateAddress.Variables>(
-                UPDATE_ADDRESS,
-                {
-                    input: {
-                        id: firstCustomerAddressIds[0],
-                        countryCode: 'AT',
-                    },
+            const result = await adminClient.query<
+                Codegen.UpdateAddressMutation,
+                Codegen.UpdateAddressMutationVariables
+            >(UPDATE_ADDRESS, {
+                input: {
+                    id: firstCustomerAddressIds[0],
+                    countryCode: 'AT',
                 },
-            );
+            });
             expect(result.updateCustomerAddress.country).toEqual({
                 code: 'AT',
                 name: 'Austria',
@@ -229,21 +224,24 @@ describe('Customer resolver', () => {
 
         it('updateCustomerAddress allows only a single default address', async () => {
             // set the first customer's second address to be default
-            const result1 = await adminClient.query<UpdateAddress.Mutation, UpdateAddress.Variables>(
-                UPDATE_ADDRESS,
-                {
-                    input: {
-                        id: firstCustomerAddressIds[1],
-                        defaultShippingAddress: true,
-                        defaultBillingAddress: true,
-                    },
+            const result1 = await adminClient.query<
+                Codegen.UpdateAddressMutation,
+                Codegen.UpdateAddressMutationVariables
+            >(UPDATE_ADDRESS, {
+                input: {
+                    id: firstCustomerAddressIds[1],
+                    defaultShippingAddress: true,
+                    defaultBillingAddress: true,
                 },
-            );
+            });
             expect(result1.updateCustomerAddress.defaultShippingAddress).toBe(true);
             expect(result1.updateCustomerAddress.defaultBillingAddress).toBe(true);
 
             // assert the first customer's other addresse is not default
-            const result2 = await adminClient.query<GetCustomer.Query, GetCustomer.Variables>(GET_CUSTOMER, {
+            const result2 = await adminClient.query<
+                Codegen.GetCustomerQuery,
+                Codegen.GetCustomerQueryVariables
+            >(GET_CUSTOMER, {
                 id: firstCustomer.id,
             });
             const otherAddress = result2.customer!.addresses!.filter(
@@ -253,21 +251,24 @@ describe('Customer resolver', () => {
             expect(otherAddress.defaultBillingAddress).toBe(false);
 
             // set the first customer's first address to be default
-            const result3 = await adminClient.query<UpdateAddress.Mutation, UpdateAddress.Variables>(
-                UPDATE_ADDRESS,
-                {
-                    input: {
-                        id: firstCustomerAddressIds[0],
-                        defaultShippingAddress: true,
-                        defaultBillingAddress: true,
-                    },
+            const result3 = await adminClient.query<
+                Codegen.UpdateAddressMutation,
+                Codegen.UpdateAddressMutationVariables
+            >(UPDATE_ADDRESS, {
+                input: {
+                    id: firstCustomerAddressIds[0],
+                    defaultShippingAddress: true,
+                    defaultBillingAddress: true,
                 },
-            );
+            });
             expect(result3.updateCustomerAddress.defaultShippingAddress).toBe(true);
             expect(result3.updateCustomerAddress.defaultBillingAddress).toBe(true);
 
             // assert the first customer's second address is not default
-            const result4 = await adminClient.query<GetCustomer.Query, GetCustomer.Variables>(GET_CUSTOMER, {
+            const result4 = await adminClient.query<
+                Codegen.GetCustomerQuery,
+                Codegen.GetCustomerQueryVariables
+            >(GET_CUSTOMER, {
                 id: firstCustomer.id,
             });
             const otherAddress2 = result4.customer!.addresses!.filter(
@@ -277,27 +278,33 @@ describe('Customer resolver', () => {
             expect(otherAddress2.defaultBillingAddress).toBe(false);
 
             // get the second customer's address id
-            const result5 = await adminClient.query<GetCustomer.Query, GetCustomer.Variables>(GET_CUSTOMER, {
+            const result5 = await adminClient.query<
+                Codegen.GetCustomerQuery,
+                Codegen.GetCustomerQueryVariables
+            >(GET_CUSTOMER, {
                 id: secondCustomer.id,
             });
             const secondCustomerAddressId = result5.customer!.addresses![0].id;
 
             // set the second customer's address to be default
-            const result6 = await adminClient.query<UpdateAddress.Mutation, UpdateAddress.Variables>(
-                UPDATE_ADDRESS,
-                {
-                    input: {
-                        id: secondCustomerAddressId,
-                        defaultShippingAddress: true,
-                        defaultBillingAddress: true,
-                    },
+            const result6 = await adminClient.query<
+                Codegen.UpdateAddressMutation,
+                Codegen.UpdateAddressMutationVariables
+            >(UPDATE_ADDRESS, {
+                input: {
+                    id: secondCustomerAddressId,
+                    defaultShippingAddress: true,
+                    defaultBillingAddress: true,
                 },
-            );
+            });
             expect(result6.updateCustomerAddress.defaultShippingAddress).toBe(true);
             expect(result6.updateCustomerAddress.defaultBillingAddress).toBe(true);
 
             // assets the first customer's address defaults are unchanged
-            const result7 = await adminClient.query<GetCustomer.Query, GetCustomer.Variables>(GET_CUSTOMER, {
+            const result7 = await adminClient.query<
+                Codegen.GetCustomerQuery,
+                Codegen.GetCustomerQueryVariables
+            >(GET_CUSTOMER, {
                 id: firstCustomer.id,
             });
             expect(result7.customer!.addresses![0].defaultShippingAddress).toBe(true);
@@ -308,8 +315,8 @@ describe('Customer resolver', () => {
 
         it('createCustomerAddress with true defaults unsets existing defaults', async () => {
             const { createCustomerAddress } = await adminClient.query<
-                CreateAddress.Mutation,
-                CreateAddress.Variables
+                Codegen.CreateAddressMutation,
+                Codegen.CreateAddressMutationVariables
             >(CREATE_ADDRESS, {
                 id: firstCustomer.id,
                 input: {
@@ -336,12 +343,12 @@ describe('Customer resolver', () => {
                 defaultBillingAddress: true,
             });
 
-            const { customer } = await adminClient.query<GetCustomer.Query, GetCustomer.Variables>(
-                GET_CUSTOMER,
-                {
-                    id: firstCustomer.id,
-                },
-            );
+            const { customer } = await adminClient.query<
+                Codegen.GetCustomerQuery,
+                Codegen.GetCustomerQueryVariables
+            >(GET_CUSTOMER, {
+                id: firstCustomer.id,
+            });
             for (const address of customer!.addresses!) {
                 const shouldBeDefault = address.id === createCustomerAddress.id;
                 expect(address.defaultShippingAddress).toEqual(shouldBeDefault);
@@ -353,8 +360,8 @@ describe('Customer resolver', () => {
 
         it('deleteCustomerAddress on default address resets defaults', async () => {
             const { deleteCustomerAddress } = await adminClient.query<
-                DeleteCustomerAddress.Mutation,
-                DeleteCustomerAddress.Variables
+                Codegen.DeleteCustomerAddressMutation,
+                Codegen.DeleteCustomerAddressMutationVariables
             >(
                 gql`
                     mutation DeleteCustomerAddress($id: ID!) {
@@ -368,12 +375,12 @@ describe('Customer resolver', () => {
 
             expect(deleteCustomerAddress.success).toBe(true);
 
-            const { customer } = await adminClient.query<GetCustomer.Query, GetCustomer.Variables>(
-                GET_CUSTOMER,
-                {
-                    id: firstCustomer.id,
-                },
-            );
+            const { customer } = await adminClient.query<
+                Codegen.GetCustomerQuery,
+                Codegen.GetCustomerQueryVariables
+            >(GET_CUSTOMER, {
+                id: firstCustomer.id,
+            });
             expect(customer!.addresses!.length).toBe(2);
             const defaultAddress = customer!.addresses!.filter(
                 a => a.defaultBillingAddress && a.defaultShippingAddress,
@@ -396,8 +403,8 @@ describe('Customer resolver', () => {
             await shopClient.asUserWithCredentials(firstCustomer.emailAddress, 'test');
             // add an item to the order to create an order
             const { addItemToOrder } = await shopClient.query<
-                AddItemToOrder.Mutation,
-                AddItemToOrder.Variables
+                AddItemToOrderMutation,
+                AddItemToOrderMutationVariables
             >(ADD_ITEM_TO_ORDER, {
                 productVariantId: 'T_1',
                 quantity: 1,
@@ -405,8 +412,8 @@ describe('Customer resolver', () => {
             orderResultGuard.assertSuccess(addItemToOrder);
 
             const { customer } = await adminClient.query<
-                GetCustomerOrders.Query,
-                GetCustomerOrders.Variables
+                Codegen.GetCustomerOrdersQuery,
+                Codegen.GetCustomerOrdersQueryVariables
             >(GET_CUSTOMER_ORDERS, { id: firstCustomer.id });
 
             expect(customer!.orders.totalItems).toBe(1);
@@ -418,8 +425,8 @@ describe('Customer resolver', () => {
         it('triggers verification event if no password supplied', async () => {
             sendEmailFn = jest.fn();
             const { createCustomer } = await adminClient.query<
-                CreateCustomer.Mutation,
-                CreateCustomer.Variables
+                Codegen.CreateCustomerMutation,
+                Codegen.CreateCustomerMutationVariables
             >(CREATE_CUSTOMER, {
                 input: {
                     emailAddress: 'test1@test.com',
@@ -438,8 +445,8 @@ describe('Customer resolver', () => {
         it('creates a verified Customer', async () => {
             sendEmailFn = jest.fn();
             const { createCustomer } = await adminClient.query<
-                CreateCustomer.Mutation,
-                CreateCustomer.Variables
+                Codegen.CreateCustomerMutation,
+                Codegen.CreateCustomerMutationVariables
             >(CREATE_CUSTOMER, {
                 input: {
                     emailAddress: 'test2@test.com',
@@ -456,8 +463,8 @@ describe('Customer resolver', () => {
 
         it('return error result when using an existing, non-deleted emailAddress', async () => {
             const { createCustomer } = await adminClient.query<
-                CreateCustomer.Mutation,
-                CreateCustomer.Variables
+                Codegen.CreateCustomerMutation,
+                Codegen.CreateCustomerMutationVariables
             >(CREATE_CUSTOMER, {
                 input: {
                     emailAddress: 'test2@test.com',
@@ -476,8 +483,8 @@ describe('Customer resolver', () => {
     describe('update', () => {
         it('returns error result when emailAddress not available', async () => {
             const { updateCustomer } = await adminClient.query<
-                UpdateCustomer.Mutation,
-                UpdateCustomer.Variables
+                Codegen.UpdateCustomerMutation,
+                Codegen.UpdateCustomerMutationVariables
             >(UPDATE_CUSTOMER, {
                 input: {
                     id: thirdCustomer.id,
@@ -492,8 +499,8 @@ describe('Customer resolver', () => {
 
         it('succeeds when emailAddress is available', async () => {
             const { updateCustomer } = await adminClient.query<
-                UpdateCustomer.Mutation,
-                UpdateCustomer.Variables
+                Codegen.UpdateCustomerMutation,
+                Codegen.UpdateCustomerMutationVariables
             >(UPDATE_CUSTOMER, {
                 input: {
                     id: thirdCustomer.id,
@@ -508,7 +515,7 @@ describe('Customer resolver', () => {
         // https://github.com/vendure-ecommerce/vendure/issues/1071
         it('updates the associated User email address', async () => {
             await shopClient.asUserWithCredentials('unique-email@test.com', 'test');
-            const { me } = await shopClient.query<Me.Query>(ME);
+            const { me } = await shopClient.query<Codegen.MeQuery>(ME);
 
             expect(me?.identifier).toBe('unique-email@test.com');
         });
@@ -516,16 +523,19 @@ describe('Customer resolver', () => {
 
     describe('deletion', () => {
         it('deletes a customer', async () => {
-            const result = await adminClient.query<DeleteCustomer.Mutation, DeleteCustomer.Variables>(
-                DELETE_CUSTOMER,
-                { id: thirdCustomer.id },
-            );
+            const result = await adminClient.query<
+                Codegen.DeleteCustomerMutation,
+                Codegen.DeleteCustomerMutationVariables
+            >(DELETE_CUSTOMER, { id: thirdCustomer.id });
 
             expect(result.deleteCustomer).toEqual({ result: DeletionResult.DELETED });
         });
 
         it('cannot get a deleted customer', async () => {
-            const result = await adminClient.query<GetCustomer.Query, GetCustomer.Variables>(GET_CUSTOMER, {
+            const result = await adminClient.query<
+                Codegen.GetCustomerQuery,
+                Codegen.GetCustomerQueryVariables
+            >(GET_CUSTOMER, {
                 id: thirdCustomer.id,
             });
 
@@ -533,9 +543,10 @@ describe('Customer resolver', () => {
         });
 
         it('deleted customer omitted from list', async () => {
-            const result = await adminClient.query<GetCustomerList.Query, GetCustomerList.Variables>(
-                GET_CUSTOMER_LIST,
-            );
+            const result = await adminClient.query<
+                Codegen.GetCustomerListQuery,
+                Codegen.GetCustomerListQueryVariables
+            >(GET_CUSTOMER_LIST);
 
             expect(result.customers.items.map(c => c.id).includes(thirdCustomer.id)).toBe(false);
         });
@@ -544,7 +555,10 @@ describe('Customer resolver', () => {
             'updateCustomer throws for deleted customer',
             assertThrowsWithMessage(
                 () =>
-                    adminClient.query<UpdateCustomer.Mutation, UpdateCustomer.Variables>(UPDATE_CUSTOMER, {
+                    adminClient.query<
+                        Codegen.UpdateCustomerMutation,
+                        Codegen.UpdateCustomerMutationVariables
+                    >(UPDATE_CUSTOMER, {
                         input: {
                             id: thirdCustomer.id,
                             firstName: 'updated',
@@ -558,21 +572,24 @@ describe('Customer resolver', () => {
             'createCustomerAddress throws for deleted customer',
             assertThrowsWithMessage(
                 () =>
-                    adminClient.query<CreateAddress.Mutation, CreateAddress.Variables>(CREATE_ADDRESS, {
-                        id: thirdCustomer.id,
-                        input: {
-                            streetLine1: 'test',
-                            countryCode: 'GB',
+                    adminClient.query<Codegen.CreateAddressMutation, Codegen.CreateAddressMutationVariables>(
+                        CREATE_ADDRESS,
+                        {
+                            id: thirdCustomer.id,
+                            input: {
+                                streetLine1: 'test',
+                                countryCode: 'GB',
+                            },
                         },
-                    }),
+                    ),
                 `No Customer with the id '3' could be found`,
             ),
         );
 
         it('new Customer can be created with same emailAddress as a deleted Customer', async () => {
             const { createCustomer } = await adminClient.query<
-                CreateCustomer.Mutation,
-                CreateCustomer.Variables
+                Codegen.CreateCustomerMutation,
+                Codegen.CreateCustomerMutationVariables
             >(CREATE_CUSTOMER, {
                 input: {
                     emailAddress: thirdCustomer.emailAddress,
@@ -593,8 +610,8 @@ describe('Customer resolver', () => {
 
         it('addNoteToCustomer', async () => {
             const { addNoteToCustomer } = await adminClient.query<
-                AddNoteToCustomer.Mutation,
-                AddNoteToCustomer.Variables
+                Codegen.AddNoteToCustomerMutation,
+                Codegen.AddNoteToCustomerMutationVariables
             >(ADD_NOTE_TO_CUSTOMER, {
                 input: {
                     id: firstCustomer.id,
@@ -604,8 +621,8 @@ describe('Customer resolver', () => {
             });
 
             const { customer } = await adminClient.query<
-                GetCustomerHistory.Query,
-                GetCustomerHistory.Variables
+                Codegen.GetCustomerHistoryQuery,
+                Codegen.GetCustomerHistoryQueryVariables
             >(GET_CUSTOMER_HISTORY, {
                 id: firstCustomer.id,
                 options: {
@@ -631,8 +648,8 @@ describe('Customer resolver', () => {
 
         it('update note', async () => {
             const { updateCustomerNote } = await adminClient.query<
-                UpdateCustomerNote.Mutation,
-                UpdateCustomerNote.Variables
+                Codegen.UpdateCustomerNoteMutation,
+                Codegen.UpdateCustomerNoteMutationVariables
             >(UPDATE_CUSTOMER_NOTE, {
                 input: {
                     noteId,
@@ -647,14 +664,14 @@ describe('Customer resolver', () => {
 
         it('delete note', async () => {
             const { customer: before } = await adminClient.query<
-                GetCustomerHistory.Query,
-                GetCustomerHistory.Variables
+                Codegen.GetCustomerHistoryQuery,
+                Codegen.GetCustomerHistoryQueryVariables
             >(GET_CUSTOMER_HISTORY, { id: firstCustomer.id });
             const historyCount = before?.history.totalItems!;
 
             const { deleteCustomerNote } = await adminClient.query<
-                DeleteCustomerNote.Mutation,
-                DeleteCustomerNote.Variables
+                Codegen.DeleteCustomerNoteMutation,
+                Codegen.DeleteCustomerNoteMutationVariables
             >(DELETE_CUSTOMER_NOTE, {
                 id: noteId,
             });
@@ -662,8 +679,8 @@ describe('Customer resolver', () => {
             expect(deleteCustomerNote.result).toBe(DeletionResult.DELETED);
 
             const { customer: after } = await adminClient.query<
-                GetCustomerHistory.Query,
-                GetCustomerHistory.Variables
+                Codegen.GetCustomerHistoryQuery,
+                Codegen.GetCustomerHistoryQueryVariables
             >(GET_CUSTOMER_HISTORY, { id: firstCustomer.id });
             expect(after?.history.totalItems).toBe(historyCount - 1);
         });

+ 10 - 6
packages/core/e2e/default-search-plugin-uuids.e2e-spec.ts

@@ -6,9 +6,13 @@ import path from 'path';
 import { initialData } from '../../../e2e-common/e2e-initial-data';
 import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
 
-import { FacetValueFragment, GetFacetList } from './graphql/generated-e2e-admin-types';
 import {
-    SearchProductsShop,
+    FacetValueFragment,
+    GetFacetListQuery,
+    GetFacetListQueryVariables,
+} from './graphql/generated-e2e-admin-types';
+import {
+    SearchProductsShopQuery,
     SearchProductsShopQueryVariables,
     SortOrder,
 } from './graphql/generated-e2e-shop-types';
@@ -45,7 +49,7 @@ describe('Default search plugin with UUIDs', () => {
         // rebuild is not completed in time for the first test.
         await new Promise(resolve => setTimeout(resolve, 5000));
 
-        const { facets } = await adminClient.query<GetFacetList.Query, GetFacetList.Variables>(
+        const { facets } = await adminClient.query<GetFacetListQuery, GetFacetListQueryVariables>(
             GET_FACET_LIST,
             {
                 options: {
@@ -67,7 +71,7 @@ describe('Default search plugin with UUIDs', () => {
     });
 
     it('can filter by facetValueIds', async () => {
-        const result = await shopClient.query<SearchProductsShop.Query, SearchProductsShopQueryVariables>(
+        const result = await shopClient.query<SearchProductsShopQuery, SearchProductsShopQueryVariables>(
             SEARCH_PRODUCTS_SHOP,
             {
                 input: {
@@ -85,10 +89,10 @@ describe('Default search plugin with UUIDs', () => {
     });
 
     it('can filter by facetValueFilters', async () => {
-        const { facets } = await adminClient.query<GetFacetList.Query, GetFacetList.Variables>(
+        const { facets } = await adminClient.query<GetFacetListQuery, GetFacetListQueryVariables>(
             GET_FACET_LIST,
         );
-        const result = await shopClient.query<SearchProductsShop.Query, SearchProductsShopQueryVariables>(
+        const result = await shopClient.query<SearchProductsShopQuery, SearchProductsShopQueryVariables>(
             SEARCH_PRODUCTS_SHOP,
             {
                 input: {

Plik diff jest za duży
+ 276 - 266
packages/core/e2e/default-search-plugin.e2e-spec.ts


+ 21 - 17
packages/core/e2e/entity-hydrator.e2e-spec.ts

@@ -8,8 +8,12 @@ import { initialData } from '../../../e2e-common/e2e-initial-data';
 import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
 
 import { HydrationTestPlugin } from './fixtures/test-plugins/hydration-test-plugin';
-import { UpdateChannel } from './graphql/generated-e2e-admin-types';
-import { AddItemToOrder, UpdatedOrderFragment } from './graphql/generated-e2e-shop-types';
+import { UpdateChannelMutation, UpdateChannelMutationVariables } from './graphql/generated-e2e-admin-types';
+import {
+    AddItemToOrderMutation,
+    AddItemToOrderMutationVariables,
+    UpdatedOrderFragment,
+} from './graphql/generated-e2e-shop-types';
 import { UPDATE_CHANNEL } from './graphql/shared-definitions';
 import { ADD_ITEM_TO_ORDER } from './graphql/shop-definitions';
 
@@ -162,13 +166,13 @@ describe('Entity hydration', () => {
 
     // https://github.com/vendure-ecommerce/vendure/issues/1172
     it('can hydrate entity with getters (Order)', async () => {
-        const { addItemToOrder } = await shopClient.query<AddItemToOrder.Mutation, AddItemToOrder.Variables>(
-            ADD_ITEM_TO_ORDER,
-            {
-                productVariantId: 'T_1',
-                quantity: 1,
-            },
-        );
+        const { addItemToOrder } = await shopClient.query<
+            AddItemToOrderMutation,
+            AddItemToOrderMutationVariables
+        >(ADD_ITEM_TO_ORDER, {
+            productVariantId: 'T_1',
+            quantity: 1,
+        });
         orderResultGuard.assertSuccess(addItemToOrder);
 
         const { hydrateOrder } = await adminClient.query<{ hydrateOrder: Order }>(GET_HYDRATED_ORDER, {
@@ -182,13 +186,13 @@ describe('Entity hydration', () => {
     // https://github.com/vendure-ecommerce/vendure/issues/1229
     it('deep merges existing properties', async () => {
         await shopClient.asAnonymousUser();
-        const { addItemToOrder } = await shopClient.query<AddItemToOrder.Mutation, AddItemToOrder.Variables>(
-            ADD_ITEM_TO_ORDER,
-            {
-                productVariantId: 'T_1',
-                quantity: 2,
-            },
-        );
+        const { addItemToOrder } = await shopClient.query<
+            AddItemToOrderMutation,
+            AddItemToOrderMutationVariables
+        >(ADD_ITEM_TO_ORDER, {
+            productVariantId: 'T_1',
+            quantity: 2,
+        });
         orderResultGuard.assertSuccess(addItemToOrder);
 
         const { hydrateOrderReturnQuantities } = await adminClient.query<{
@@ -202,7 +206,7 @@ describe('Entity hydration', () => {
 
     // https://github.com/vendure-ecommerce/vendure/issues/1284
     it('hydrates custom field relations', async () => {
-        await adminClient.query<UpdateChannel.Mutation, UpdateChannel.Variables>(UPDATE_CHANNEL, {
+        await adminClient.query<UpdateChannelMutation, UpdateChannelMutationVariables>(UPDATE_CHANNEL, {
             input: {
                 id: 'T_1',
                 customFields: {

+ 2 - 2
packages/core/e2e/entity-uuid-strategy.e2e-spec.ts

@@ -13,7 +13,7 @@ import path from 'path';
 import { initialData } from '../../../e2e-common/e2e-initial-data';
 import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
 
-import { GetProductList } from './graphql/generated-e2e-admin-types';
+import { GetProductListQuery, GetProductListQueryVariables } from './graphql/generated-e2e-admin-types';
 import { GET_PRODUCT_LIST } from './graphql/shared-definitions';
 
 describe('UuidIdStrategy', () => {
@@ -36,7 +36,7 @@ describe('UuidIdStrategy', () => {
     });
 
     it('uses uuids', async () => {
-        const { products } = await adminClient.query<GetProductList.Query, GetProductList.Variables>(
+        const { products } = await adminClient.query<GetProductListQuery, GetProductListQueryVariables>(
             GET_PRODUCT_LIST,
             {
                 options: {

+ 279 - 269
packages/core/e2e/facet.e2e-spec.ts

@@ -7,27 +7,13 @@ import { initialData } from '../../../e2e-common/e2e-initial-data';
 import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
 
 import { FACET_VALUE_FRAGMENT, FACET_WITH_VALUES_FRAGMENT } from './graphql/fragments';
+import * as Codegen from './graphql/generated-e2e-admin-types';
 import {
-    AssignProductsToChannel,
     ChannelFragment,
-    CreateChannel,
-    CreateFacet,
-    CreateFacetValues,
     CurrencyCode,
-    DeleteFacet,
-    DeleteFacetValues,
     DeletionResult,
-    FacetWithValues,
-    GetFacetList,
-    GetFacetWithValues,
-    GetProductListWithVariants,
-    GetProductWithFacetValues,
-    GetProductWithVariants,
+    FacetWithValuesFragment,
     LanguageCode,
-    UpdateFacet,
-    UpdateFacetValues,
-    UpdateProduct,
-    UpdateProductVariants,
 } from './graphql/generated-e2e-admin-types';
 import {
     ASSIGN_PRODUCT_TO_CHANNEL,
@@ -47,8 +33,8 @@ import { assertThrowsWithMessage } from './utils/assert-throws-with-message';
 describe('Facet resolver', () => {
     const { server, adminClient, shopClient } = createTestEnvironment(testConfig());
 
-    let brandFacet: FacetWithValues.Fragment;
-    let speakerTypeFacet: FacetWithValues.Fragment;
+    let brandFacet: FacetWithValuesFragment;
+    let speakerTypeFacet: FacetWithValuesFragment;
 
     beforeAll(async () => {
         await server.init({
@@ -64,7 +50,10 @@ describe('Facet resolver', () => {
     });
 
     it('createFacet', async () => {
-        const result = await adminClient.query<CreateFacet.Mutation, CreateFacet.Variables>(CREATE_FACET, {
+        const result = await adminClient.query<
+            Codegen.CreateFacetMutation,
+            Codegen.CreateFacetMutationVariables
+        >(CREATE_FACET, {
             input: {
                 isPrivate: false,
                 code: 'speaker-type',
@@ -83,7 +72,10 @@ describe('Facet resolver', () => {
     });
 
     it('updateFacet', async () => {
-        const result = await adminClient.query<UpdateFacet.Mutation, UpdateFacet.Variables>(UPDATE_FACET, {
+        const result = await adminClient.query<
+            Codegen.UpdateFacetMutation,
+            Codegen.UpdateFacetMutationVariables
+        >(UPDATE_FACET, {
             input: {
                 id: speakerTypeFacet.id,
                 translations: [{ languageCode: LanguageCode.en, name: 'Speaker Category' }],
@@ -96,8 +88,8 @@ describe('Facet resolver', () => {
 
     it('createFacetValues', async () => {
         const { createFacetValues } = await adminClient.query<
-            CreateFacetValues.Mutation,
-            CreateFacetValues.Variables
+            Codegen.CreateFacetValuesMutation,
+            Codegen.CreateFacetValuesMutationVariables
         >(CREATE_FACET_VALUES, {
             input: [
                 {
@@ -133,23 +125,23 @@ describe('Facet resolver', () => {
     });
 
     it('updateFacetValues', async () => {
-        const result = await adminClient.query<UpdateFacetValues.Mutation, UpdateFacetValues.Variables>(
-            UPDATE_FACET_VALUES,
-            {
-                input: [
-                    {
-                        id: speakerTypeFacet.values[0].id,
-                        code: 'compact',
-                    },
-                ],
-            },
-        );
+        const result = await adminClient.query<
+            Codegen.UpdateFacetValuesMutation,
+            Codegen.UpdateFacetValuesMutationVariables
+        >(UPDATE_FACET_VALUES, {
+            input: [
+                {
+                    id: speakerTypeFacet.values[0].id,
+                    code: 'compact',
+                },
+            ],
+        });
 
         expect(result.updateFacetValues[0].code).toBe('compact');
     });
 
     it('facets', async () => {
-        const result = await adminClient.query<GetFacetList.Query>(GET_FACET_LIST);
+        const result = await adminClient.query<Codegen.GetFacetListQuery>(GET_FACET_LIST);
 
         const { items } = result.facets;
         expect(items.length).toBe(2);
@@ -161,7 +153,7 @@ describe('Facet resolver', () => {
     });
 
     it('facets by shop-api', async () => {
-        const result = await shopClient.query<GetFacetList.Query>(GET_FACET_LIST_SIMPLE);
+        const result = await shopClient.query<Codegen.GetFacetListQuery>(GET_FACET_LIST_SIMPLE);
 
         const { items } = result.facets;
         expect(items.length).toBe(1);
@@ -169,12 +161,12 @@ describe('Facet resolver', () => {
     });
 
     it('facet', async () => {
-        const result = await adminClient.query<GetFacetWithValues.Query, GetFacetWithValues.Variables>(
-            GET_FACET_WITH_VALUES,
-            {
-                id: speakerTypeFacet.id,
-            },
-        );
+        const result = await adminClient.query<
+            Codegen.GetFacetWithValuesQuery,
+            Codegen.GetFacetWithValuesQueryVariables
+        >(GET_FACET_WITH_VALUES, {
+            id: speakerTypeFacet.id,
+        });
 
         expect(result.facet!.name).toBe('Speaker Category');
     });
@@ -182,15 +174,18 @@ describe('Facet resolver', () => {
     it('product.facetValues resolver omits private facets in shop-api', async () => {
         const publicFacetValue = brandFacet.values[0];
         const privateFacetValue = speakerTypeFacet.values[0];
-        await adminClient.query<UpdateProduct.Mutation, UpdateProduct.Variables>(UPDATE_PRODUCT, {
-            input: {
-                id: 'T_1',
-                facetValueIds: [publicFacetValue.id, privateFacetValue.id],
+        await adminClient.query<Codegen.UpdateProductMutation, Codegen.UpdateProductMutationVariables>(
+            UPDATE_PRODUCT,
+            {
+                input: {
+                    id: 'T_1',
+                    facetValueIds: [publicFacetValue.id, privateFacetValue.id],
+                },
             },
-        });
+        );
         const { product } = await shopClient.query<
-            GetProductWithFacetValues.Query,
-            GetProductWithFacetValues.Variables
+            Codegen.GetProductWithFacetValuesQuery,
+            Codegen.GetProductWithFacetValuesQueryVariables
         >(GET_PRODUCT_WITH_FACET_VALUES, {
             id: 'T_1',
         });
@@ -202,20 +197,20 @@ describe('Facet resolver', () => {
     it('productVariant.facetValues resolver omits private facets in shop-api', async () => {
         const publicFacetValue = brandFacet.values[0];
         const privateFacetValue = speakerTypeFacet.values[0];
-        await adminClient.query<UpdateProductVariants.Mutation, UpdateProductVariants.Variables>(
-            UPDATE_PRODUCT_VARIANTS,
-            {
-                input: [
-                    {
-                        id: 'T_1',
-                        facetValueIds: [publicFacetValue.id, privateFacetValue.id],
-                    },
-                ],
-            },
-        );
+        await adminClient.query<
+            Codegen.UpdateProductVariantsMutation,
+            Codegen.UpdateProductVariantsMutationVariables
+        >(UPDATE_PRODUCT_VARIANTS, {
+            input: [
+                {
+                    id: 'T_1',
+                    facetValueIds: [publicFacetValue.id, privateFacetValue.id],
+                },
+            ],
+        });
         const { product } = await shopClient.query<
-            GetProductWithFacetValues.Query,
-            GetProductWithFacetValues.Variables
+            Codegen.GetProductWithFacetValuesQuery,
+            Codegen.GetProductWithFacetValuesQueryVariables
         >(GET_PRODUCT_WITH_FACET_VALUES, {
             id: 'T_1',
         });
@@ -226,57 +221,63 @@ describe('Facet resolver', () => {
     });
 
     describe('deletion', () => {
-        let products: GetProductListWithVariants.Items[];
+        let products: Codegen.GetProductListWithVariantsQuery['products']['items'];
 
         beforeAll(async () => {
             // add the FacetValues to products and variants
-            const result1 = await adminClient.query<GetProductListWithVariants.Query>(
+            const result1 = await adminClient.query<Codegen.GetProductListWithVariantsQuery>(
                 GET_PRODUCTS_LIST_WITH_VARIANTS,
             );
             products = result1.products.items;
 
-            await adminClient.query<UpdateProduct.Mutation, UpdateProduct.Variables>(UPDATE_PRODUCT, {
-                input: {
-                    id: products[0].id,
-                    facetValueIds: [speakerTypeFacet.values[0].id],
+            await adminClient.query<Codegen.UpdateProductMutation, Codegen.UpdateProductMutationVariables>(
+                UPDATE_PRODUCT,
+                {
+                    input: {
+                        id: products[0].id,
+                        facetValueIds: [speakerTypeFacet.values[0].id],
+                    },
                 },
+            );
+
+            await adminClient.query<
+                Codegen.UpdateProductVariantsMutation,
+                Codegen.UpdateProductVariantsMutationVariables
+            >(UPDATE_PRODUCT_VARIANTS, {
+                input: [
+                    {
+                        id: products[0].variants[0].id,
+                        facetValueIds: [speakerTypeFacet.values[0].id],
+                    },
+                ],
             });
 
-            await adminClient.query<UpdateProductVariants.Mutation, UpdateProductVariants.Variables>(
-                UPDATE_PRODUCT_VARIANTS,
+            await adminClient.query<Codegen.UpdateProductMutation, Codegen.UpdateProductMutationVariables>(
+                UPDATE_PRODUCT,
                 {
-                    input: [
-                        {
-                            id: products[0].variants[0].id,
-                            facetValueIds: [speakerTypeFacet.values[0].id],
-                        },
-                    ],
+                    input: {
+                        id: products[1].id,
+                        facetValueIds: [speakerTypeFacet.values[1].id],
+                    },
                 },
             );
-
-            await adminClient.query<UpdateProduct.Mutation, UpdateProduct.Variables>(UPDATE_PRODUCT, {
-                input: {
-                    id: products[1].id,
-                    facetValueIds: [speakerTypeFacet.values[1].id],
-                },
-            });
         });
 
         it('deleteFacetValues deletes unused facetValue', async () => {
             const facetValueToDelete = speakerTypeFacet.values[2];
-            const result1 = await adminClient.query<DeleteFacetValues.Mutation, DeleteFacetValues.Variables>(
-                DELETE_FACET_VALUES,
-                {
-                    ids: [facetValueToDelete.id],
-                    force: false,
-                },
-            );
-            const result2 = await adminClient.query<GetFacetWithValues.Query, GetFacetWithValues.Variables>(
-                GET_FACET_WITH_VALUES,
-                {
-                    id: speakerTypeFacet.id,
-                },
-            );
+            const result1 = await adminClient.query<
+                Codegen.DeleteFacetValuesMutation,
+                Codegen.DeleteFacetValuesMutationVariables
+            >(DELETE_FACET_VALUES, {
+                ids: [facetValueToDelete.id],
+                force: false,
+            });
+            const result2 = await adminClient.query<
+                Codegen.GetFacetWithValuesQuery,
+                Codegen.GetFacetWithValuesQueryVariables
+            >(GET_FACET_WITH_VALUES, {
+                id: speakerTypeFacet.id,
+            });
 
             expect(result1.deleteFacetValues).toEqual([
                 {
@@ -290,19 +291,19 @@ describe('Facet resolver', () => {
 
         it('deleteFacetValues for FacetValue in use returns NOT_DELETED', async () => {
             const facetValueToDelete = speakerTypeFacet.values[0];
-            const result1 = await adminClient.query<DeleteFacetValues.Mutation, DeleteFacetValues.Variables>(
-                DELETE_FACET_VALUES,
-                {
-                    ids: [facetValueToDelete.id],
-                    force: false,
-                },
-            );
-            const result2 = await adminClient.query<GetFacetWithValues.Query, GetFacetWithValues.Variables>(
-                GET_FACET_WITH_VALUES,
-                {
-                    id: speakerTypeFacet.id,
-                },
-            );
+            const result1 = await adminClient.query<
+                Codegen.DeleteFacetValuesMutation,
+                Codegen.DeleteFacetValuesMutationVariables
+            >(DELETE_FACET_VALUES, {
+                ids: [facetValueToDelete.id],
+                force: false,
+            });
+            const result2 = await adminClient.query<
+                Codegen.GetFacetWithValuesQuery,
+                Codegen.GetFacetWithValuesQueryVariables
+            >(GET_FACET_WITH_VALUES, {
+                id: speakerTypeFacet.id,
+            });
 
             expect(result1.deleteFacetValues).toEqual([
                 {
@@ -316,13 +317,13 @@ describe('Facet resolver', () => {
 
         it('deleteFacetValues for FacetValue in use can be force deleted', async () => {
             const facetValueToDelete = speakerTypeFacet.values[0];
-            const result1 = await adminClient.query<DeleteFacetValues.Mutation, DeleteFacetValues.Variables>(
-                DELETE_FACET_VALUES,
-                {
-                    ids: [facetValueToDelete.id],
-                    force: true,
-                },
-            );
+            const result1 = await adminClient.query<
+                Codegen.DeleteFacetValuesMutation,
+                Codegen.DeleteFacetValuesMutationVariables
+            >(DELETE_FACET_VALUES, {
+                ids: [facetValueToDelete.id],
+                force: true,
+            });
 
             expect(result1.deleteFacetValues).toEqual([
                 {
@@ -332,18 +333,18 @@ describe('Facet resolver', () => {
             ]);
 
             // FacetValue no longer in the Facet.values array
-            const result2 = await adminClient.query<GetFacetWithValues.Query, GetFacetWithValues.Variables>(
-                GET_FACET_WITH_VALUES,
-                {
-                    id: speakerTypeFacet.id,
-                },
-            );
+            const result2 = await adminClient.query<
+                Codegen.GetFacetWithValuesQuery,
+                Codegen.GetFacetWithValuesQueryVariables
+            >(GET_FACET_WITH_VALUES, {
+                id: speakerTypeFacet.id,
+            });
             expect(result2.facet!.values[0]).not.toEqual(facetValueToDelete);
 
             // FacetValue no longer in the Product.facetValues array
             const result3 = await adminClient.query<
-                GetProductWithVariants.Query,
-                GetProductWithVariants.Variables
+                Codegen.GetProductWithVariantsQuery,
+                Codegen.GetProductWithVariantsQueryVariables
             >(GET_PRODUCT_WITH_VARIANTS, {
                 id: products[0].id,
             });
@@ -351,19 +352,19 @@ describe('Facet resolver', () => {
         });
 
         it('deleteFacet that is in use returns NOT_DELETED', async () => {
-            const result1 = await adminClient.query<DeleteFacet.Mutation, DeleteFacet.Variables>(
-                DELETE_FACET,
-                {
-                    id: speakerTypeFacet.id,
-                    force: false,
-                },
-            );
-            const result2 = await adminClient.query<GetFacetWithValues.Query, GetFacetWithValues.Variables>(
-                GET_FACET_WITH_VALUES,
-                {
-                    id: speakerTypeFacet.id,
-                },
-            );
+            const result1 = await adminClient.query<
+                Codegen.DeleteFacetMutation,
+                Codegen.DeleteFacetMutationVariables
+            >(DELETE_FACET, {
+                id: speakerTypeFacet.id,
+                force: false,
+            });
+            const result2 = await adminClient.query<
+                Codegen.GetFacetWithValuesQuery,
+                Codegen.GetFacetWithValuesQueryVariables
+            >(GET_FACET_WITH_VALUES, {
+                id: speakerTypeFacet.id,
+            });
 
             expect(result1.deleteFacet).toEqual({
                 result: DeletionResult.NOT_DELETED,
@@ -374,13 +375,13 @@ describe('Facet resolver', () => {
         });
 
         it('deleteFacet that is in use can be force deleted', async () => {
-            const result1 = await adminClient.query<DeleteFacet.Mutation, DeleteFacet.Variables>(
-                DELETE_FACET,
-                {
-                    id: speakerTypeFacet.id,
-                    force: true,
-                },
-            );
+            const result1 = await adminClient.query<
+                Codegen.DeleteFacetMutation,
+                Codegen.DeleteFacetMutationVariables
+            >(DELETE_FACET, {
+                id: speakerTypeFacet.id,
+                force: true,
+            });
 
             expect(result1.deleteFacet).toEqual({
                 result: DeletionResult.DELETED,
@@ -388,18 +389,18 @@ describe('Facet resolver', () => {
             });
 
             // FacetValue no longer in the Facet.values array
-            const result2 = await adminClient.query<GetFacetWithValues.Query, GetFacetWithValues.Variables>(
-                GET_FACET_WITH_VALUES,
-                {
-                    id: speakerTypeFacet.id,
-                },
-            );
+            const result2 = await adminClient.query<
+                Codegen.GetFacetWithValuesQuery,
+                Codegen.GetFacetWithValuesQueryVariables
+            >(GET_FACET_WITH_VALUES, {
+                id: speakerTypeFacet.id,
+            });
             expect(result2.facet).toBe(null);
 
             // FacetValue no longer in the Product.facetValues array
             const result3 = await adminClient.query<
-                GetProductWithVariants.Query,
-                GetProductWithVariants.Variables
+                Codegen.GetProductWithVariantsQuery,
+                Codegen.GetProductWithVariantsQueryVariables
             >(GET_PRODUCT_WITH_VARIANTS, {
                 id: products[1].id,
             });
@@ -407,35 +408,35 @@ describe('Facet resolver', () => {
         });
 
         it('deleteFacet with no FacetValues works', async () => {
-            const { createFacet } = await adminClient.query<CreateFacet.Mutation, CreateFacet.Variables>(
-                CREATE_FACET,
-                {
-                    input: {
-                        code: 'test',
-                        isPrivate: false,
-                        translations: [{ languageCode: LanguageCode.en, name: 'Test' }],
-                    },
-                },
-            );
-            const result = await adminClient.query<DeleteFacet.Mutation, DeleteFacet.Variables>(
-                DELETE_FACET,
-                {
-                    id: createFacet.id,
-                    force: false,
+            const { createFacet } = await adminClient.query<
+                Codegen.CreateFacetMutation,
+                Codegen.CreateFacetMutationVariables
+            >(CREATE_FACET, {
+                input: {
+                    code: 'test',
+                    isPrivate: false,
+                    translations: [{ languageCode: LanguageCode.en, name: 'Test' }],
                 },
-            );
+            });
+            const result = await adminClient.query<
+                Codegen.DeleteFacetMutation,
+                Codegen.DeleteFacetMutationVariables
+            >(DELETE_FACET, {
+                id: createFacet.id,
+                force: false,
+            });
             expect(result.deleteFacet.result).toBe(DeletionResult.DELETED);
         });
     });
 
     describe('channels', () => {
         const SECOND_CHANNEL_TOKEN = 'second_channel_token';
-        let createdFacet: CreateFacet.CreateFacet;
+        let createdFacet: Codegen.CreateFacetMutation['createFacet'];
 
         beforeAll(async () => {
             const { createChannel } = await adminClient.query<
-                CreateChannel.Mutation,
-                CreateChannel.Variables
+                Codegen.CreateChannelMutation,
+                Codegen.CreateChannelMutationVariables
             >(CREATE_CHANNEL, {
                 input: {
                     code: 'second-channel',
@@ -449,8 +450,8 @@ describe('Facet resolver', () => {
             });
 
             const { assignProductsToChannel } = await adminClient.query<
-                AssignProductsToChannel.Mutation,
-                AssignProductsToChannel.Variables
+                Codegen.AssignProductsToChannelMutation,
+                Codegen.AssignProductsToChannelMutationVariables
             >(ASSIGN_PRODUCT_TO_CHANNEL, {
                 input: {
                     channelId: (createChannel as ChannelFragment).id,
@@ -463,26 +464,26 @@ describe('Facet resolver', () => {
         });
 
         it('create Facet in channel', async () => {
-            const { createFacet } = await adminClient.query<CreateFacet.Mutation, CreateFacet.Variables>(
-                CREATE_FACET,
-                {
-                    input: {
-                        isPrivate: false,
-                        code: 'channel-facet',
-                        translations: [{ languageCode: LanguageCode.en, name: 'Channel Facet' }],
-                        values: [
-                            {
-                                code: 'channel-value-1',
-                                translations: [{ languageCode: LanguageCode.en, name: 'Channel Value 1' }],
-                            },
-                            {
-                                code: 'channel-value-2',
-                                translations: [{ languageCode: LanguageCode.en, name: 'Channel Value 2' }],
-                            },
-                        ],
-                    },
+            const { createFacet } = await adminClient.query<
+                Codegen.CreateFacetMutation,
+                Codegen.CreateFacetMutationVariables
+            >(CREATE_FACET, {
+                input: {
+                    isPrivate: false,
+                    code: 'channel-facet',
+                    translations: [{ languageCode: LanguageCode.en, name: 'Channel Facet' }],
+                    values: [
+                        {
+                            code: 'channel-value-1',
+                            translations: [{ languageCode: LanguageCode.en, name: 'Channel Value 1' }],
+                        },
+                        {
+                            code: 'channel-value-2',
+                            translations: [{ languageCode: LanguageCode.en, name: 'Channel Value 2' }],
+                        },
+                    ],
                 },
-            );
+            });
 
             expect(createFacet.code).toBe('channel-facet');
 
@@ -490,7 +491,7 @@ describe('Facet resolver', () => {
         });
 
         it('facets list in channel', async () => {
-            const result = await adminClient.query<GetFacetList.Query>(GET_FACET_LIST);
+            const result = await adminClient.query<Codegen.GetFacetListQuery>(GET_FACET_LIST);
 
             const { items } = result.facets;
             expect(items.length).toBe(1);
@@ -499,28 +500,31 @@ describe('Facet resolver', () => {
 
         it('Product.facetValues in channel', async () => {
             adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
-            await adminClient.query<UpdateProduct.Mutation, UpdateProduct.Variables>(UPDATE_PRODUCT, {
-                input: {
-                    id: 'T_1',
-                    facetValueIds: [brandFacet.values[0].id, ...createdFacet.values.map(v => v.id)],
-                },
-            });
-            await adminClient.query<UpdateProductVariants.Mutation, UpdateProductVariants.Variables>(
-                UPDATE_PRODUCT_VARIANTS,
+            await adminClient.query<Codegen.UpdateProductMutation, Codegen.UpdateProductMutationVariables>(
+                UPDATE_PRODUCT,
                 {
-                    input: [
-                        {
-                            id: 'T_1',
-                            facetValueIds: [brandFacet.values[0].id, ...createdFacet.values.map(v => v.id)],
-                        },
-                    ],
+                    input: {
+                        id: 'T_1',
+                        facetValueIds: [brandFacet.values[0].id, ...createdFacet.values.map(v => v.id)],
+                    },
                 },
             );
+            await adminClient.query<
+                Codegen.UpdateProductVariantsMutation,
+                Codegen.UpdateProductVariantsMutationVariables
+            >(UPDATE_PRODUCT_VARIANTS, {
+                input: [
+                    {
+                        id: 'T_1',
+                        facetValueIds: [brandFacet.values[0].id, ...createdFacet.values.map(v => v.id)],
+                    },
+                ],
+            });
 
             adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
             const { product } = await adminClient.query<
-                GetProductWithVariants.Query,
-                GetProductWithVariants.Variables
+                Codegen.GetProductWithVariantsQuery,
+                Codegen.GetProductWithVariantsQueryVariables
             >(GET_PRODUCT_WITH_VARIANTS, {
                 id: 'T_1',
             });
@@ -533,8 +537,8 @@ describe('Facet resolver', () => {
 
         it('ProductVariant.facetValues in channel', async () => {
             const { product } = await adminClient.query<
-                GetProductWithVariants.Query,
-                GetProductWithVariants.Variables
+                Codegen.GetProductWithVariantsQuery,
+                Codegen.GetProductWithVariantsQueryVariables
             >(GET_PRODUCT_WITH_VARIANTS, {
                 id: 'T_1',
             });
@@ -547,16 +551,19 @@ describe('Facet resolver', () => {
 
         it('updating Product facetValuesIds in channel only affects that channel', async () => {
             adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
-            await adminClient.query<UpdateProduct.Mutation, UpdateProduct.Variables>(UPDATE_PRODUCT, {
-                input: {
-                    id: 'T_1',
-                    facetValueIds: [createdFacet.values[0].id],
+            await adminClient.query<Codegen.UpdateProductMutation, Codegen.UpdateProductMutationVariables>(
+                UPDATE_PRODUCT,
+                {
+                    input: {
+                        id: 'T_1',
+                        facetValueIds: [createdFacet.values[0].id],
+                    },
                 },
-            });
+            );
 
             const { product: productC2 } = await adminClient.query<
-                GetProductWithVariants.Query,
-                GetProductWithVariants.Variables
+                Codegen.GetProductWithVariantsQuery,
+                Codegen.GetProductWithVariantsQueryVariables
             >(GET_PRODUCT_WITH_VARIANTS, {
                 id: 'T_1',
             });
@@ -565,8 +572,8 @@ describe('Facet resolver', () => {
 
             adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
             const { product: productCD } = await adminClient.query<
-                GetProductWithVariants.Query,
-                GetProductWithVariants.Variables
+                Codegen.GetProductWithVariantsQuery,
+                Codegen.GetProductWithVariantsQueryVariables
             >(GET_PRODUCT_WITH_VARIANTS, {
                 id: 'T_1',
             });
@@ -579,21 +586,21 @@ describe('Facet resolver', () => {
 
         it('updating ProductVariant facetValuesIds in channel only affects that channel', async () => {
             adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
-            await adminClient.query<UpdateProductVariants.Mutation, UpdateProductVariants.Variables>(
-                UPDATE_PRODUCT_VARIANTS,
-                {
-                    input: [
-                        {
-                            id: 'T_1',
-                            facetValueIds: [createdFacet.values[0].id],
-                        },
-                    ],
-                },
-            );
+            await adminClient.query<
+                Codegen.UpdateProductVariantsMutation,
+                Codegen.UpdateProductVariantsMutationVariables
+            >(UPDATE_PRODUCT_VARIANTS, {
+                input: [
+                    {
+                        id: 'T_1',
+                        facetValueIds: [createdFacet.values[0].id],
+                    },
+                ],
+            });
 
             const { product: productC2 } = await adminClient.query<
-                GetProductWithVariants.Query,
-                GetProductWithVariants.Variables
+                Codegen.GetProductWithVariantsQuery,
+                Codegen.GetProductWithVariantsQueryVariables
             >(GET_PRODUCT_WITH_VARIANTS, {
                 id: 'T_1',
             });
@@ -604,8 +611,8 @@ describe('Facet resolver', () => {
 
             adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
             const { product: productCD } = await adminClient.query<
-                GetProductWithVariants.Query,
-                GetProductWithVariants.Variables
+                Codegen.GetProductWithVariantsQuery,
+                Codegen.GetProductWithVariantsQueryVariables
             >(GET_PRODUCT_WITH_VARIANTS, {
                 id: 'T_1',
             });
@@ -620,18 +627,18 @@ describe('Facet resolver', () => {
             'attempting to create FacetValue in Facet from another Channel throws',
             assertThrowsWithMessage(async () => {
                 adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
-                await adminClient.query<CreateFacetValues.Mutation, CreateFacetValues.Variables>(
-                    CREATE_FACET_VALUES,
-                    {
-                        input: [
-                            {
-                                facetId: brandFacet.id,
-                                code: 'channel-brand',
-                                translations: [{ languageCode: LanguageCode.en, name: 'Channel Brand' }],
-                            },
-                        ],
-                    },
-                );
+                await adminClient.query<
+                    Codegen.CreateFacetValuesMutation,
+                    Codegen.CreateFacetValuesMutationVariables
+                >(CREATE_FACET_VALUES, {
+                    input: [
+                        {
+                            facetId: brandFacet.id,
+                            code: 'channel-brand',
+                            translations: [{ languageCode: LanguageCode.en, name: 'Channel Brand' }],
+                        },
+                    ],
+                });
             }, `No Facet with the id '1' could be found`),
         );
     });
@@ -639,28 +646,31 @@ describe('Facet resolver', () => {
     // https://github.com/vendure-ecommerce/vendure/issues/715
     describe('code conflicts', () => {
         function createFacetWithCode(code: string) {
-            return adminClient.query<CreateFacet.Mutation, CreateFacet.Variables>(CREATE_FACET, {
-                input: {
-                    isPrivate: false,
-                    code,
-                    translations: [{ languageCode: LanguageCode.en, name: `Test Facet (${code})` }],
-                    values: [],
+            return adminClient.query<Codegen.CreateFacetMutation, Codegen.CreateFacetMutationVariables>(
+                CREATE_FACET,
+                {
+                    input: {
+                        isPrivate: false,
+                        code,
+                        translations: [{ languageCode: LanguageCode.en, name: `Test Facet (${code})` }],
+                        values: [],
+                    },
                 },
-            });
+            );
         }
 
         // https://github.com/vendure-ecommerce/vendure/issues/831
         it('updateFacet with unchanged code', async () => {
             const { createFacet } = await createFacetWithCode('some-new-facet');
-            const result = await adminClient.query<UpdateFacet.Mutation, UpdateFacet.Variables>(
-                UPDATE_FACET,
-                {
-                    input: {
-                        id: createFacet.id,
-                        code: createFacet.code,
-                    },
+            const result = await adminClient.query<
+                Codegen.UpdateFacetMutation,
+                Codegen.UpdateFacetMutationVariables
+            >(UPDATE_FACET, {
+                input: {
+                    id: createFacet.id,
+                    code: createFacet.code,
                 },
-            );
+            });
 
             expect(result.updateFacet.code).toBe(createFacet.code);
         });
@@ -677,15 +687,15 @@ describe('Facet resolver', () => {
             const { createFacet } = await createFacetWithCode('foo');
             expect(createFacet.code).toBe('foo');
 
-            const { updateFacet } = await adminClient.query<UpdateFacet.Mutation, UpdateFacet.Variables>(
-                UPDATE_FACET,
-                {
-                    input: {
-                        id: createFacet.id,
-                        code: 'test-2',
-                    },
+            const { updateFacet } = await adminClient.query<
+                Codegen.UpdateFacetMutation,
+                Codegen.UpdateFacetMutationVariables
+            >(UPDATE_FACET, {
+                input: {
+                    id: createFacet.id,
+                    code: 'test-2',
                 },
-            );
+            });
 
             expect(updateFacet.code).toBe('test-3');
         });

+ 1 - 1
packages/core/e2e/fixtures/test-plugins/with-job-queue.ts

@@ -51,5 +51,5 @@ class TestController implements OnModuleInit {
 })
 export class PluginWithJobQueue {
     static jobHasDoneWork = false;
-    static jobSubject = new Subject();
+    static jobSubject = new Subject<void>();
 }

+ 42 - 42
packages/core/e2e/fulfillment-process.e2e-spec.ts

@@ -12,15 +12,9 @@ import { initialData } from '../../../e2e-common/e2e-initial-data';
 import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
 
 import { testSuccessfulPaymentMethod } from './fixtures/test-payment-methods';
-import {
-    CreateFulfillment,
-    ErrorCode,
-    FulfillmentFragment,
-    GetCustomerList,
-    GetOrderFulfillments,
-    TransitFulfillment,
-} from './graphql/generated-e2e-admin-types';
-import { AddItemToOrder } from './graphql/generated-e2e-shop-types';
+import { ErrorCode, FulfillmentFragment } from './graphql/generated-e2e-admin-types';
+import * as Codegen from './graphql/generated-e2e-admin-types';
+import { AddItemToOrderMutation, AddItemToOrderMutationVariables } from './graphql/generated-e2e-shop-types';
 import {
     CREATE_FULFILLMENT,
     GET_CUSTOMER_LIST,
@@ -110,14 +104,14 @@ describe('Fulfillment process', () => {
         await adminClient.asSuperAdmin();
 
         // Create a couple of orders to be queried
-        const result = await adminClient.query<GetCustomerList.Query, GetCustomerList.Variables>(
-            GET_CUSTOMER_LIST,
-            {
-                options: {
-                    take: 3,
-                },
+        const result = await adminClient.query<
+            Codegen.GetCustomerListQuery,
+            Codegen.GetCustomerListQueryVariables
+        >(GET_CUSTOMER_LIST, {
+            options: {
+                take: 3,
             },
-        );
+        });
         const customers = result.customers.items;
 
         /**
@@ -125,11 +119,11 @@ describe('Fulfillment process', () => {
          */
         await shopClient.asUserWithCredentials(customers[0].emailAddress, 'test');
         // Add Items
-        await shopClient.query<AddItemToOrder.Mutation, AddItemToOrder.Variables>(ADD_ITEM_TO_ORDER, {
+        await shopClient.query<AddItemToOrderMutation, AddItemToOrderMutationVariables>(ADD_ITEM_TO_ORDER, {
             productVariantId: 'T_1',
             quantity: 1,
         });
-        await shopClient.query<AddItemToOrder.Mutation, AddItemToOrder.Variables>(ADD_ITEM_TO_ORDER, {
+        await shopClient.query<AddItemToOrderMutation, AddItemToOrderMutationVariables>(ADD_ITEM_TO_ORDER, {
             productVariantId: 'T_2',
             quantity: 1,
         });
@@ -138,7 +132,10 @@ describe('Fulfillment process', () => {
         await addPaymentToOrder(shopClient, testSuccessfulPaymentMethod);
 
         // Add a fulfillment without tracking code
-        await adminClient.query<CreateFulfillment.Mutation, CreateFulfillment.Variables>(CREATE_FULFILLMENT, {
+        await adminClient.query<
+            Codegen.CreateFulfillmentMutation,
+            Codegen.CreateFulfillmentMutationVariables
+        >(CREATE_FULFILLMENT, {
             input: {
                 lines: [{ orderLineId: 'T_1', quantity: 1 }],
                 handler: {
@@ -149,7 +146,10 @@ describe('Fulfillment process', () => {
         });
 
         // Add a fulfillment with tracking code
-        await adminClient.query<CreateFulfillment.Mutation, CreateFulfillment.Variables>(CREATE_FULFILLMENT, {
+        await adminClient.query<
+            Codegen.CreateFulfillmentMutation,
+            Codegen.CreateFulfillmentMutationVariables
+        >(CREATE_FULFILLMENT, {
             input: {
                 lines: [{ orderLineId: 'T_2', quantity: 1 }],
                 handler: {
@@ -175,8 +175,8 @@ describe('Fulfillment process', () => {
 
         it('replaced transition target', async () => {
             const { order } = await adminClient.query<
-                GetOrderFulfillments.Query,
-                GetOrderFulfillments.Variables
+                Codegen.GetOrderFulfillmentsQuery,
+                Codegen.GetOrderFulfillmentsQueryVariables
             >(GET_ORDER_FULFILLMENTS, {
                 id: 'T_1',
             });
@@ -186,21 +186,21 @@ describe('Fulfillment process', () => {
 
         it('custom onTransitionStart handler returning error message', async () => {
             // First transit to AwaitingPickup
-            await adminClient.query<TransitFulfillment.Mutation, TransitFulfillment.Variables>(
-                TRANSIT_FULFILLMENT,
-                {
-                    id: 'T_1',
-                    state: 'AwaitingPickup',
-                },
-            );
+            await adminClient.query<
+                Codegen.TransitFulfillmentMutation,
+                Codegen.TransitFulfillmentMutationVariables
+            >(TRANSIT_FULFILLMENT, {
+                id: 'T_1',
+                state: 'AwaitingPickup',
+            });
 
             transitionStartSpy.mockClear();
             transitionErrorSpy.mockClear();
             transitionEndSpy.mockClear();
 
             const { transitionFulfillmentToState } = await adminClient.query<
-                TransitFulfillment.Mutation,
-                TransitFulfillment.Variables
+                Codegen.TransitFulfillmentMutation,
+                Codegen.TransitFulfillmentMutationVariables
             >(TRANSIT_FULFILLMENT, {
                 id: 'T_1',
                 state: 'Shipped',
@@ -224,19 +224,19 @@ describe('Fulfillment process', () => {
             transitionEndSpy.mockClear();
 
             // First transit to AwaitingPickup
-            await adminClient.query<TransitFulfillment.Mutation, TransitFulfillment.Variables>(
-                TRANSIT_FULFILLMENT,
-                {
-                    id: 'T_2',
-                    state: 'AwaitingPickup',
-                },
-            );
+            await adminClient.query<
+                Codegen.TransitFulfillmentMutation,
+                Codegen.TransitFulfillmentMutationVariables
+            >(TRANSIT_FULFILLMENT, {
+                id: 'T_2',
+                state: 'AwaitingPickup',
+            });
 
             transitionEndSpy.mockClear();
 
             const { transitionFulfillmentToState } = await adminClient.query<
-                TransitFulfillment.Mutation,
-                TransitFulfillment.Variables
+                Codegen.TransitFulfillmentMutation,
+                Codegen.TransitFulfillmentMutationVariables
             >(TRANSIT_FULFILLMENT, {
                 id: 'T_2',
                 state: 'Shipped',
@@ -250,8 +250,8 @@ describe('Fulfillment process', () => {
 
         it('composes multiple CustomFulfillmentProcesses', async () => {
             const { order } = await adminClient.query<
-                GetOrderFulfillments.Query,
-                GetOrderFulfillments.Variables
+                Codegen.GetOrderFulfillmentsQuery,
+                Codegen.GetOrderFulfillmentsQueryVariables
             >(GET_ORDER_FULFILLMENTS, {
                 id: 'T_1',
             });

+ 9 - 8
packages/core/e2e/global-settings.e2e-spec.ts

@@ -7,10 +7,11 @@ import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-conf
 
 import { GLOBAL_SETTINGS_FRAGMENT } from './graphql/fragments';
 import {
-    GetGlobalSettings,
+    GetGlobalSettingsQuery,
     GlobalSettingsFragment,
     LanguageCode,
-    UpdateGlobalSettings,
+    UpdateGlobalSettingsMutation,
+    UpdateGlobalSettingsMutationVariables,
 } from './graphql/generated-e2e-admin-types';
 import { UPDATE_GLOBAL_SETTINGS } from './graphql/shared-definitions';
 
@@ -36,7 +37,7 @@ describe('GlobalSettings resolver', () => {
             customerCount: 1,
         });
         await adminClient.asSuperAdmin();
-        await adminClient.query<UpdateGlobalSettings.Mutation, UpdateGlobalSettings.Variables>(
+        await adminClient.query<UpdateGlobalSettingsMutation, UpdateGlobalSettingsMutationVariables>(
             UPDATE_GLOBAL_SETTINGS,
             {
                 input: {
@@ -44,7 +45,7 @@ describe('GlobalSettings resolver', () => {
                 },
             },
         );
-        const result = await adminClient.query<GetGlobalSettings.Query>(GET_GLOBAL_SETTINGS);
+        const result = await adminClient.query<GetGlobalSettingsQuery>(GET_GLOBAL_SETTINGS);
         globalSettings = result.globalSettings;
     }, TEST_SETUP_TIMEOUT_MS);
 
@@ -90,8 +91,8 @@ describe('GlobalSettings resolver', () => {
     describe('update', () => {
         it('returns error result when removing required language', async () => {
             const { updateGlobalSettings } = await adminClient.query<
-                UpdateGlobalSettings.Mutation,
-                UpdateGlobalSettings.Variables
+                UpdateGlobalSettingsMutation,
+                UpdateGlobalSettingsMutationVariables
             >(UPDATE_GLOBAL_SETTINGS, {
                 input: {
                     availableLanguages: [LanguageCode.zh],
@@ -106,8 +107,8 @@ describe('GlobalSettings resolver', () => {
 
         it('successful update', async () => {
             const { updateGlobalSettings } = await adminClient.query<
-                UpdateGlobalSettings.Mutation,
-                UpdateGlobalSettings.Variables
+                UpdateGlobalSettingsMutation,
+                UpdateGlobalSettingsMutationVariables
             >(UPDATE_GLOBAL_SETTINGS, {
                 input: {
                     availableLanguages: [LanguageCode.en, LanguageCode.zh],

+ 12 - 5
packages/core/e2e/graphql/generated-e2e-admin-types.ts

@@ -3001,12 +3001,10 @@ export type OrderAddress = {
 export type OrderFilterParameter = {
     active?: InputMaybe<BooleanOperators>;
     code?: InputMaybe<StringOperators>;
-    couponCodes?: InputMaybe<StringOperators>;
     createdAt?: InputMaybe<DateOperators>;
     currencyCode?: InputMaybe<StringOperators>;
     customerLastName?: InputMaybe<StringOperators>;
     id?: InputMaybe<IdOperators>;
-    nextStates?: InputMaybe<StringOperators>;
     orderPlacedAt?: InputMaybe<DateOperators>;
     shipping?: InputMaybe<NumberOperators>;
     shippingWithTax?: InputMaybe<NumberOperators>;
@@ -3171,11 +3169,9 @@ export type OrderProcessState = {
 
 export type OrderSortParameter = {
     code?: InputMaybe<SortOrder>;
-    couponCodes?: InputMaybe<SortOrder>;
     createdAt?: InputMaybe<SortOrder>;
     customerLastName?: InputMaybe<SortOrder>;
     id?: InputMaybe<SortOrder>;
-    nextStates?: InputMaybe<SortOrder>;
     orderPlacedAt?: InputMaybe<SortOrder>;
     shipping?: InputMaybe<SortOrder>;
     shippingWithTax?: InputMaybe<SortOrder>;
@@ -4197,7 +4193,6 @@ export type RoleFilterParameter = {
     createdAt?: InputMaybe<DateOperators>;
     description?: InputMaybe<StringOperators>;
     id?: InputMaybe<IdOperators>;
-    permissions?: InputMaybe<StringOperators>;
     updatedAt?: InputMaybe<DateOperators>;
 };
 
@@ -7979,6 +7974,18 @@ export type GetAssetFragmentFirstQueryVariables = Exact<{
 
 export type GetAssetFragmentFirstQuery = { asset?: { id: string; preview: string } | null };
 
+export type AssetWithTagsAndFocalPointFragment = {
+    id: string;
+    name: string;
+    fileSize: number;
+    mimeType: string;
+    type: AssetType;
+    preview: string;
+    source: string;
+    focalPoint?: { x: number; y: number } | null;
+    tags: Array<{ id: string; value: string }>;
+};
+
 export type CreateAssetsMutationVariables = Exact<{
     input: Array<CreateAssetInput> | CreateAssetInput;
 }>;

+ 0 - 2
packages/core/e2e/graphql/generated-e2e-shop-types.ts

@@ -1848,7 +1848,6 @@ export type OrderAddress = {
 export type OrderFilterParameter = {
     active?: InputMaybe<BooleanOperators>;
     code?: InputMaybe<StringOperators>;
-    couponCodes?: InputMaybe<StringOperators>;
     createdAt?: InputMaybe<DateOperators>;
     currencyCode?: InputMaybe<StringOperators>;
     id?: InputMaybe<IdOperators>;
@@ -1999,7 +1998,6 @@ export type OrderPaymentStateError = ErrorResult & {
 
 export type OrderSortParameter = {
     code?: InputMaybe<SortOrder>;
-    couponCodes?: InputMaybe<SortOrder>;
     createdAt?: InputMaybe<SortOrder>;
     id?: InputMaybe<SortOrder>;
     orderPlacedAt?: InputMaybe<SortOrder>;

+ 17 - 12
packages/core/e2e/graphql/shared-definitions.ts

@@ -860,20 +860,25 @@ export const GET_ASSET_FRAGMENT_FIRST = gql`
     }
 `;
 
+export const ASSET_WITH_TAGS_AND_FOCAL_POINT_FRAGMENT = gql`
+    fragment AssetWithTagsAndFocalPoint on Asset {
+        ...Asset
+        focalPoint {
+            x
+            y
+        }
+        tags {
+            id
+            value
+        }
+    }
+    ${ASSET_FRAGMENT}
+`;
+
 export const CREATE_ASSETS = gql`
     mutation CreateAssets($input: [CreateAssetInput!]!) {
         createAssets(input: $input) {
-            ...Asset
-            ... on Asset {
-                focalPoint {
-                    x
-                    y
-                }
-                tags {
-                    id
-                    value
-                }
-            }
+            ...AssetWithTagsAndFocalPoint
             ... on MimeTypeError {
                 message
                 fileName
@@ -881,7 +886,7 @@ export const CREATE_ASSETS = gql`
             }
         }
     }
-    ${ASSET_FRAGMENT}
+    ${ASSET_WITH_TAGS_AND_FOCAL_POINT_FRAGMENT}
 `;
 
 export const DELETE_SHIPPING_METHOD = gql`

+ 14 - 5
packages/core/e2e/job-queue.e2e-spec.ts

@@ -7,7 +7,13 @@ import { initialData } from '../../../e2e-common/e2e-initial-data';
 import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
 
 import { PluginWithJobQueue } from './fixtures/test-plugins/with-job-queue';
-import { CancelJob, GetRunningJobs, JobState } from './graphql/generated-e2e-admin-types';
+import {
+    CancelJobMutation,
+    CancelJobMutationVariables,
+    GetRunningJobsQuery,
+    GetRunningJobsQueryVariables,
+    JobState,
+} from './graphql/generated-e2e-admin-types';
 import { GET_RUNNING_JOBS } from './graphql/shared-definitions';
 
 describe('JobQueue', () => {
@@ -45,7 +51,7 @@ describe('JobQueue', () => {
 
     function getJobsInTestQueue(state?: JobState) {
         return adminClient
-            .query<GetRunningJobs.Query, GetRunningJobs.Variables>(GET_RUNNING_JOBS, {
+            .query<GetRunningJobsQuery, GetRunningJobsQueryVariables>(GET_RUNNING_JOBS, {
                 options: {
                     filter: {
                         queueName: {
@@ -120,9 +126,12 @@ describe('JobQueue', () => {
         expect(PluginWithJobQueue.jobHasDoneWork).toBe(false);
         const jobId = jobs.items[0].id;
 
-        const { cancelJob } = await adminClient.query<CancelJob.Mutation, CancelJob.Variables>(CANCEL_JOB, {
-            id: jobId,
-        });
+        const { cancelJob } = await adminClient.query<CancelJobMutation, CancelJobMutationVariables>(
+            CANCEL_JOB,
+            {
+                id: jobId,
+            },
+        );
 
         expect(cancelJob.state).toBe(JobState.CANCELLED);
         expect(cancelJob.isSettled).toBe(true);

+ 53 - 54
packages/core/e2e/localization.e2e-spec.ts

@@ -6,12 +6,8 @@ import path from 'path';
 import { initialData } from '../../../e2e-common/e2e-initial-data';
 import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
 
-import {
-    GetProductWithVariants,
-    LanguageCode,
-    UpdateOptionGroup,
-    UpdateProduct,
-} from './graphql/generated-e2e-admin-types';
+import { LanguageCode } from './graphql/generated-e2e-admin-types';
+import * as Codegen from './graphql/generated-e2e-admin-types';
 import { GET_PRODUCT_WITH_VARIANTS, UPDATE_PRODUCT } from './graphql/shared-definitions';
 
 /* tslint:disable:no-non-null-assertion */
@@ -26,48 +22,48 @@ describe('Localization', () => {
         });
         await adminClient.asSuperAdmin();
 
-        const { updateProduct } = await adminClient.query<UpdateProduct.Mutation, UpdateProduct.Variables>(
-            UPDATE_PRODUCT,
-            {
-                input: {
-                    id: 'T_1',
-                    translations: [
-                        {
-                            languageCode: LanguageCode.en,
-                            name: 'en name',
-                            slug: 'en-slug',
-                            description: 'en-description',
-                        },
-                        {
-                            languageCode: LanguageCode.de,
-                            name: 'de name',
-                            slug: 'de-slug',
-                            description: 'de-description',
-                        },
-                        {
-                            languageCode: LanguageCode.zh,
-                            name: 'zh name',
-                            slug: 'zh-slug',
-                            description: 'zh-description',
-                        },
-                    ],
-                },
+        const { updateProduct } = await adminClient.query<
+            Codegen.UpdateProductMutation,
+            Codegen.UpdateProductMutationVariables
+        >(UPDATE_PRODUCT, {
+            input: {
+                id: 'T_1',
+                translations: [
+                    {
+                        languageCode: LanguageCode.en,
+                        name: 'en name',
+                        slug: 'en-slug',
+                        description: 'en-description',
+                    },
+                    {
+                        languageCode: LanguageCode.de,
+                        name: 'de name',
+                        slug: 'de-slug',
+                        description: 'de-description',
+                    },
+                    {
+                        languageCode: LanguageCode.zh,
+                        name: 'zh name',
+                        slug: 'zh-slug',
+                        description: 'zh-description',
+                    },
+                ],
             },
-        );
+        });
 
-        await adminClient.query<UpdateOptionGroup.Mutation, UpdateOptionGroup.Variables>(
-            UPDATE_OPTION_GROUP,
-            {
-                input: {
-                    id: 'T_1',
-                    translations: [
-                        { languageCode: LanguageCode.en, name: 'en name' },
-                        { languageCode: LanguageCode.de, name: 'de name' },
-                        { languageCode: LanguageCode.zh, name: 'zh name' },
-                    ],
-                },
+        await adminClient.query<
+            Codegen.UpdateOptionGroupMutation,
+            Codegen.UpdateOptionGroupMutationVariables
+        >(UPDATE_OPTION_GROUP, {
+            input: {
+                id: 'T_1',
+                translations: [
+                    { languageCode: LanguageCode.en, name: 'en name' },
+                    { languageCode: LanguageCode.de, name: 'de name' },
+                    { languageCode: LanguageCode.zh, name: 'zh name' },
+                ],
             },
-        );
+        });
     }, TEST_SETUP_TIMEOUT_MS);
 
     afterAll(async () => {
@@ -76,8 +72,8 @@ describe('Localization', () => {
 
     it('returns default language when none specified', async () => {
         const { product } = await adminClient.query<
-            GetProductWithVariants.Query,
-            GetProductWithVariants.Variables
+            Codegen.GetProductWithVariantsQuery,
+            Codegen.GetProductWithVariantsQueryVariables
         >(GET_PRODUCT_WITH_VARIANTS, {
             id: 'T_1',
         });
@@ -90,8 +86,8 @@ describe('Localization', () => {
 
     it('returns specified language', async () => {
         const { product } = await adminClient.query<
-            GetProductWithVariants.Query,
-            GetProductWithVariants.Variables
+            Codegen.GetProductWithVariantsQuery,
+            Codegen.GetProductWithVariantsQueryVariables
         >(
             GET_PRODUCT_WITH_VARIANTS,
             {
@@ -108,8 +104,8 @@ describe('Localization', () => {
 
     it('falls back to default language code', async () => {
         const { product } = await adminClient.query<
-            GetProductWithVariants.Query,
-            GetProductWithVariants.Variables
+            Codegen.GetProductWithVariantsQuery,
+            Codegen.GetProductWithVariantsQueryVariables
         >(
             GET_PRODUCT_WITH_VARIANTS,
             {
@@ -126,8 +122,8 @@ describe('Localization', () => {
 
     it('nested entites are translated', async () => {
         const { product } = await adminClient.query<
-            GetProductWithVariants.Query,
-            GetProductWithVariants.Variables
+            Codegen.GetProductWithVariantsQuery,
+            Codegen.GetProductWithVariantsQueryVariables
         >(
             GET_PRODUCT_WITH_VARIANTS,
             {
@@ -141,7 +137,10 @@ describe('Localization', () => {
     });
 
     it('translates results of mutation', async () => {
-        const { updateProduct } = await adminClient.query<UpdateProduct.Mutation, UpdateProduct.Variables>(
+        const { updateProduct } = await adminClient.query<
+            Codegen.UpdateProductMutation,
+            Codegen.UpdateProductMutationVariables
+        >(
             UPDATE_PRODUCT,
             {
                 input: {

+ 87 - 75
packages/core/e2e/order-changed-price-handling.e2e-spec.ts

@@ -12,8 +12,8 @@ import path from 'path';
 import { initialData } from '../../../e2e-common/e2e-initial-data';
 import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
 
-import { UpdateProductVariants } from './graphql/generated-e2e-admin-types';
-import { AddItemToOrder, AdjustItemQuantity, GetActiveOrder } from './graphql/generated-e2e-shop-types';
+import * as Codegen from './graphql/generated-e2e-admin-types';
+import * as CodegenShop from './graphql/generated-e2e-shop-types';
 import { UPDATE_PRODUCT_VARIANTS } from './graphql/shared-definitions';
 import { ADD_ITEM_TO_ORDER, ADJUST_ITEM_QUANTITY, GET_ACTIVE_ORDER } from './graphql/shop-definitions';
 
@@ -63,12 +63,15 @@ describe('ChangedPriceHandlingStrategy', () => {
     it('unitPriceChangeSinceAdded starts as 0', async () => {
         TestChangedPriceStrategy.spy.mockClear();
 
-        await shopClient.query<AddItemToOrder.Mutation, AddItemToOrder.Variables>(ADD_ITEM_TO_ORDER, {
+        await shopClient.query<
+            CodegenShop.AddItemToOrderMutation,
+            CodegenShop.AddItemToOrderMutationVariables
+        >(ADD_ITEM_TO_ORDER, {
             productVariantId: 'T_12',
             quantity: 1,
         });
 
-        const { activeOrder } = await shopClient.query<GetActiveOrder.Query>(GET_ACTIVE_ORDER);
+        const { activeOrder } = await shopClient.query<CodegenShop.GetActiveOrderQuery>(GET_ACTIVE_ORDER);
 
         expect(activeOrder?.lines[0].unitPriceChangeSinceAdded).toBe(0);
         expect(activeOrder?.lines[0].unitPrice).toBe(5374);
@@ -85,24 +88,27 @@ describe('ChangedPriceHandlingStrategy', () => {
         it('calls handlePriceChange on addItemToOrder', async () => {
             TestChangedPriceStrategy.spy.mockClear();
 
-            await adminClient.query<UpdateProductVariants.Mutation, UpdateProductVariants.Variables>(
-                UPDATE_PRODUCT_VARIANTS,
-                {
-                    input: [
-                        {
-                            id: 'T_12',
-                            price: 6000,
-                        },
-                    ],
-                },
-            );
-
-            await shopClient.query<AddItemToOrder.Mutation, AddItemToOrder.Variables>(ADD_ITEM_TO_ORDER, {
+            await adminClient.query<
+                Codegen.UpdateProductVariantsMutation,
+                Codegen.UpdateProductVariantsMutationVariables
+            >(UPDATE_PRODUCT_VARIANTS, {
+                input: [
+                    {
+                        id: 'T_12',
+                        price: 6000,
+                    },
+                ],
+            });
+
+            await shopClient.query<
+                CodegenShop.AddItemToOrderMutation,
+                CodegenShop.AddItemToOrderMutationVariables
+            >(ADD_ITEM_TO_ORDER, {
                 productVariantId: 'T_12',
                 quantity: 1,
             });
 
-            const { activeOrder } = await shopClient.query<GetActiveOrder.Query>(GET_ACTIVE_ORDER);
+            const { activeOrder } = await shopClient.query<CodegenShop.GetActiveOrderQuery>(GET_ACTIVE_ORDER);
             expect(activeOrder?.lines[0].unitPriceChangeSinceAdded).toBe(626);
             expect(activeOrder?.lines[0].unitPrice).toBe(6000);
             expect(activeOrder?.lines[0].items.every(i => i.unitPrice === 6000)).toBe(true);
@@ -114,27 +120,27 @@ describe('ChangedPriceHandlingStrategy', () => {
         it('calls handlePriceChange on adjustOrderLine', async () => {
             TestChangedPriceStrategy.spy.mockClear();
 
-            await adminClient.query<UpdateProductVariants.Mutation, UpdateProductVariants.Variables>(
-                UPDATE_PRODUCT_VARIANTS,
-                {
-                    input: [
-                        {
-                            id: 'T_12',
-                            price: 3000,
-                        },
-                    ],
-                },
-            );
-
-            await shopClient.query<AdjustItemQuantity.Mutation, AdjustItemQuantity.Variables>(
-                ADJUST_ITEM_QUANTITY,
-                {
-                    orderLineId: firstOrderLineId,
-                    quantity: 3,
-                },
-            );
-
-            const { activeOrder } = await shopClient.query<GetActiveOrder.Query>(GET_ACTIVE_ORDER);
+            await adminClient.query<
+                Codegen.UpdateProductVariantsMutation,
+                Codegen.UpdateProductVariantsMutationVariables
+            >(UPDATE_PRODUCT_VARIANTS, {
+                input: [
+                    {
+                        id: 'T_12',
+                        price: 3000,
+                    },
+                ],
+            });
+
+            await shopClient.query<
+                CodegenShop.AdjustItemQuantityMutation,
+                CodegenShop.AdjustItemQuantityMutationVariables
+            >(ADJUST_ITEM_QUANTITY, {
+                orderLineId: firstOrderLineId,
+                quantity: 3,
+            });
+
+            const { activeOrder } = await shopClient.query<CodegenShop.GetActiveOrderQuery>(GET_ACTIVE_ORDER);
             expect(activeOrder?.lines[0].unitPriceChangeSinceAdded).toBe(-2374);
             expect(activeOrder?.lines[0].unitPrice).toBe(3000);
             expect(activeOrder?.lines[0].items.every(i => i.unitPrice === 3000)).toBe(true);
@@ -153,29 +159,35 @@ describe('ChangedPriceHandlingStrategy', () => {
         it('calls handlePriceChange on addItemToOrder', async () => {
             TestChangedPriceStrategy.spy.mockClear();
 
-            await shopClient.query<AddItemToOrder.Mutation, AddItemToOrder.Variables>(ADD_ITEM_TO_ORDER, {
+            await shopClient.query<
+                CodegenShop.AddItemToOrderMutation,
+                CodegenShop.AddItemToOrderMutationVariables
+            >(ADD_ITEM_TO_ORDER, {
                 productVariantId: 'T_13',
                 quantity: 1,
             });
 
-            await adminClient.query<UpdateProductVariants.Mutation, UpdateProductVariants.Variables>(
-                UPDATE_PRODUCT_VARIANTS,
-                {
-                    input: [
-                        {
-                            id: 'T_13',
-                            price: 8000,
-                        },
-                    ],
-                },
-            );
-
-            await shopClient.query<AddItemToOrder.Mutation, AddItemToOrder.Variables>(ADD_ITEM_TO_ORDER, {
+            await adminClient.query<
+                Codegen.UpdateProductVariantsMutation,
+                Codegen.UpdateProductVariantsMutationVariables
+            >(UPDATE_PRODUCT_VARIANTS, {
+                input: [
+                    {
+                        id: 'T_13',
+                        price: 8000,
+                    },
+                ],
+            });
+
+            await shopClient.query<
+                CodegenShop.AddItemToOrderMutation,
+                CodegenShop.AddItemToOrderMutationVariables
+            >(ADD_ITEM_TO_ORDER, {
                 productVariantId: 'T_13',
                 quantity: 1,
             });
 
-            const { activeOrder } = await shopClient.query<GetActiveOrder.Query>(GET_ACTIVE_ORDER);
+            const { activeOrder } = await shopClient.query<CodegenShop.GetActiveOrderQuery>(GET_ACTIVE_ORDER);
             expect(activeOrder?.lines[1].unitPriceChangeSinceAdded).toBe(0);
             expect(activeOrder?.lines[1].unitPrice).toBe(ORIGINAL_PRICE);
             expect(activeOrder?.lines[1].items.every(i => i.unitPrice === ORIGINAL_PRICE)).toBe(true);
@@ -187,27 +199,27 @@ describe('ChangedPriceHandlingStrategy', () => {
         it('calls handlePriceChange on adjustOrderLine', async () => {
             TestChangedPriceStrategy.spy.mockClear();
 
-            await adminClient.query<UpdateProductVariants.Mutation, UpdateProductVariants.Variables>(
-                UPDATE_PRODUCT_VARIANTS,
-                {
-                    input: [
-                        {
-                            id: 'T_13',
-                            price: 3000,
-                        },
-                    ],
-                },
-            );
-
-            await shopClient.query<AdjustItemQuantity.Mutation, AdjustItemQuantity.Variables>(
-                ADJUST_ITEM_QUANTITY,
-                {
-                    orderLineId: secondOrderLineId,
-                    quantity: 3,
-                },
-            );
-
-            const { activeOrder } = await shopClient.query<GetActiveOrder.Query>(GET_ACTIVE_ORDER);
+            await adminClient.query<
+                Codegen.UpdateProductVariantsMutation,
+                Codegen.UpdateProductVariantsMutationVariables
+            >(UPDATE_PRODUCT_VARIANTS, {
+                input: [
+                    {
+                        id: 'T_13',
+                        price: 3000,
+                    },
+                ],
+            });
+
+            await shopClient.query<
+                CodegenShop.AdjustItemQuantityMutation,
+                CodegenShop.AdjustItemQuantityMutationVariables
+            >(ADJUST_ITEM_QUANTITY, {
+                orderLineId: secondOrderLineId,
+                quantity: 3,
+            });
+
+            const { activeOrder } = await shopClient.query<CodegenShop.GetActiveOrderQuery>(GET_ACTIVE_ORDER);
             expect(activeOrder?.lines[1].unitPriceChangeSinceAdded).toBe(0);
             expect(activeOrder?.lines[1].unitPrice).toBe(ORIGINAL_PRICE);
             expect(activeOrder?.lines[1].items.every(i => i.unitPrice === ORIGINAL_PRICE)).toBe(true);

+ 89 - 94
packages/core/e2e/order-channel.e2e-spec.ts

@@ -10,21 +10,10 @@ import path from 'path';
 import { initialData } from '../../../e2e-common/e2e-initial-data';
 import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
 
-import {
-    AssignProductsToChannel,
-    CreateChannel,
-    CurrencyCode,
-    GetCustomerList,
-    GetOrderList,
-    GetProductWithVariants,
-    LanguageCode,
-} from './graphql/generated-e2e-admin-types';
-import {
-    AddItemToOrder,
-    GetActiveOrder,
-    GetOrderShop,
-    UpdatedOrderFragment,
-} from './graphql/generated-e2e-shop-types';
+import { CurrencyCode, LanguageCode } from './graphql/generated-e2e-admin-types';
+import * as Codegen from './graphql/generated-e2e-admin-types';
+import { UpdatedOrderFragment } from './graphql/generated-e2e-shop-types';
+import * as CodegenShop from './graphql/generated-e2e-shop-types';
 import {
     ASSIGN_PRODUCT_TO_CHANNEL,
     CREATE_CHANNEL,
@@ -38,9 +27,9 @@ describe('Channelaware orders', () => {
     const { server, adminClient, shopClient } = createTestEnvironment(testConfig());
     const SECOND_CHANNEL_TOKEN = 'second_channel_token';
     const THIRD_CHANNEL_TOKEN = 'third_channel_token';
-    let customerUser: GetCustomerList.Items;
-    let product1: GetProductWithVariants.Product;
-    let product2: GetProductWithVariants.Product;
+    let customerUser: Codegen.GetCustomerListQuery['customers']['items'][number];
+    let product1: Codegen.GetProductWithVariantsQuery['product'];
+    let product2: Codegen.GetProductWithVariantsQuery['product'];
     let order1Id: string;
     let order2Id: string;
 
@@ -52,76 +41,82 @@ describe('Channelaware orders', () => {
         });
         await adminClient.asSuperAdmin();
 
-        const { customers } = await adminClient.query<GetCustomerList.Query, GetCustomerList.Variables>(
-            GET_CUSTOMER_LIST,
-            {
-                options: { take: 1 },
-            },
-        );
+        const { customers } = await adminClient.query<
+            Codegen.GetCustomerListQuery,
+            Codegen.GetCustomerListQueryVariables
+        >(GET_CUSTOMER_LIST, {
+            options: { take: 1 },
+        });
         customerUser = customers.items[0];
         await shopClient.asUserWithCredentials(customerUser.emailAddress, 'test');
 
-        await adminClient.query<CreateChannel.Mutation, CreateChannel.Variables>(CREATE_CHANNEL, {
-            input: {
-                code: 'second-channel',
-                token: SECOND_CHANNEL_TOKEN,
-                defaultLanguageCode: LanguageCode.en,
-                currencyCode: CurrencyCode.GBP,
-                pricesIncludeTax: true,
-                defaultShippingZoneId: 'T_1',
-                defaultTaxZoneId: 'T_1',
+        await adminClient.query<Codegen.CreateChannelMutation, Codegen.CreateChannelMutationVariables>(
+            CREATE_CHANNEL,
+            {
+                input: {
+                    code: 'second-channel',
+                    token: SECOND_CHANNEL_TOKEN,
+                    defaultLanguageCode: LanguageCode.en,
+                    currencyCode: CurrencyCode.GBP,
+                    pricesIncludeTax: true,
+                    defaultShippingZoneId: 'T_1',
+                    defaultTaxZoneId: 'T_1',
+                },
             },
-        });
+        );
 
-        await adminClient.query<CreateChannel.Mutation, CreateChannel.Variables>(CREATE_CHANNEL, {
-            input: {
-                code: 'third-channel',
-                token: THIRD_CHANNEL_TOKEN,
-                defaultLanguageCode: LanguageCode.en,
-                currencyCode: CurrencyCode.GBP,
-                pricesIncludeTax: true,
-                defaultShippingZoneId: 'T_1',
-                defaultTaxZoneId: 'T_1',
+        await adminClient.query<Codegen.CreateChannelMutation, Codegen.CreateChannelMutationVariables>(
+            CREATE_CHANNEL,
+            {
+                input: {
+                    code: 'third-channel',
+                    token: THIRD_CHANNEL_TOKEN,
+                    defaultLanguageCode: LanguageCode.en,
+                    currencyCode: CurrencyCode.GBP,
+                    pricesIncludeTax: true,
+                    defaultShippingZoneId: 'T_1',
+                    defaultTaxZoneId: 'T_1',
+                },
             },
-        });
+        );
 
         product1 = (
-            await adminClient.query<GetProductWithVariants.Query, GetProductWithVariants.Variables>(
-                GET_PRODUCT_WITH_VARIANTS,
-                {
-                    id: 'T_1',
-                },
-            )
+            await adminClient.query<
+                Codegen.GetProductWithVariantsQuery,
+                Codegen.GetProductWithVariantsQueryVariables
+            >(GET_PRODUCT_WITH_VARIANTS, {
+                id: 'T_1',
+            })
         ).product!;
 
-        await adminClient.query<AssignProductsToChannel.Mutation, AssignProductsToChannel.Variables>(
-            ASSIGN_PRODUCT_TO_CHANNEL,
-            {
-                input: {
-                    channelId: 'T_2',
-                    productIds: [product1.id],
-                },
+        await adminClient.query<
+            Codegen.AssignProductsToChannelMutation,
+            Codegen.AssignProductsToChannelMutationVariables
+        >(ASSIGN_PRODUCT_TO_CHANNEL, {
+            input: {
+                channelId: 'T_2',
+                productIds: [product1.id],
             },
-        );
+        });
 
         product2 = (
-            await adminClient.query<GetProductWithVariants.Query, GetProductWithVariants.Variables>(
-                GET_PRODUCT_WITH_VARIANTS,
-                {
-                    id: 'T_2',
-                },
-            )
+            await adminClient.query<
+                Codegen.GetProductWithVariantsQuery,
+                Codegen.GetProductWithVariantsQueryVariables
+            >(GET_PRODUCT_WITH_VARIANTS, {
+                id: 'T_2',
+            })
         ).product!;
 
-        await adminClient.query<AssignProductsToChannel.Mutation, AssignProductsToChannel.Variables>(
-            ASSIGN_PRODUCT_TO_CHANNEL,
-            {
-                input: {
-                    channelId: 'T_3',
-                    productIds: [product2.id],
-                },
+        await adminClient.query<
+            Codegen.AssignProductsToChannelMutation,
+            Codegen.AssignProductsToChannelMutationVariables
+        >(ASSIGN_PRODUCT_TO_CHANNEL, {
+            input: {
+                channelId: 'T_3',
+                productIds: [product2.id],
             },
-        );
+        });
     }, TEST_SETUP_TIMEOUT_MS);
 
     afterAll(async () => {
@@ -134,60 +129,60 @@ describe('Channelaware orders', () => {
 
     it('creates order on current channel', async () => {
         shopClient.setChannelToken(SECOND_CHANNEL_TOKEN);
-        const { addItemToOrder } = await shopClient.query<AddItemToOrder.Mutation, AddItemToOrder.Variables>(
-            ADD_ITEM_TO_ORDER,
-            {
-                productVariantId: product1.variants[0].id,
-                quantity: 1,
-            },
-        );
+        const { addItemToOrder } = await shopClient.query<
+            CodegenShop.AddItemToOrderMutation,
+            CodegenShop.AddItemToOrderMutationVariables
+        >(ADD_ITEM_TO_ORDER, {
+            productVariantId: product1!.variants[0].id,
+            quantity: 1,
+        });
         orderResultGuard.assertSuccess(addItemToOrder);
 
         expect(addItemToOrder!.lines.length).toBe(1);
         expect(addItemToOrder!.lines[0].quantity).toBe(1);
-        expect(addItemToOrder!.lines[0].productVariant.id).toBe(product1.variants[0].id);
+        expect(addItemToOrder!.lines[0].productVariant.id).toBe(product1!.variants[0].id);
 
         order1Id = addItemToOrder!.id;
     });
 
     it('sets active order to null when switching channel', async () => {
         shopClient.setChannelToken(THIRD_CHANNEL_TOKEN);
-        const result = await shopClient.query<GetActiveOrder.Query>(GET_ACTIVE_ORDER);
+        const result = await shopClient.query<CodegenShop.GetActiveOrderQuery>(GET_ACTIVE_ORDER);
         expect(result.activeOrder).toBeNull();
     });
 
     it('creates new order on current channel when already active order on other channel', async () => {
-        const { addItemToOrder } = await shopClient.query<AddItemToOrder.Mutation, AddItemToOrder.Variables>(
-            ADD_ITEM_TO_ORDER,
-            {
-                productVariantId: product2.variants[0].id,
-                quantity: 1,
-            },
-        );
+        const { addItemToOrder } = await shopClient.query<
+            CodegenShop.AddItemToOrderMutation,
+            CodegenShop.AddItemToOrderMutationVariables
+        >(ADD_ITEM_TO_ORDER, {
+            productVariantId: product2!.variants[0].id,
+            quantity: 1,
+        });
         orderResultGuard.assertSuccess(addItemToOrder);
 
         expect(addItemToOrder!.lines.length).toBe(1);
         expect(addItemToOrder!.lines[0].quantity).toBe(1);
-        expect(addItemToOrder!.lines[0].productVariant.id).toBe(product2.variants[0].id);
+        expect(addItemToOrder!.lines[0].productVariant.id).toBe(product2!.variants[0].id);
 
         order2Id = addItemToOrder!.id;
     });
 
     it('goes back to most recent active order when switching channel', async () => {
         shopClient.setChannelToken(SECOND_CHANNEL_TOKEN);
-        const { activeOrder } = await shopClient.query<GetActiveOrder.Query>(GET_ACTIVE_ORDER);
+        const { activeOrder } = await shopClient.query<CodegenShop.GetActiveOrderQuery>(GET_ACTIVE_ORDER);
         expect(activeOrder!.id).toBe(order1Id);
     });
 
     it('returns null when requesting order from other channel', async () => {
-        const result = await shopClient.query<GetOrderShop.Query>(GET_ORDER_SHOP, {
+        const result = await shopClient.query<CodegenShop.GetOrderShopQuery>(GET_ORDER_SHOP, {
             id: order2Id,
         });
         expect(result!.order).toBeNull();
     });
 
     it('returns order when requesting order from correct channel', async () => {
-        const result = await shopClient.query<GetOrderShop.Query>(GET_ORDER_SHOP, {
+        const result = await shopClient.query<CodegenShop.GetOrderShopQuery>(GET_ORDER_SHOP, {
             id: order1Id,
         });
         expect(result.order!.id).toBe(order1Id);
@@ -195,13 +190,13 @@ describe('Channelaware orders', () => {
 
     it('returns all orders on default channel', async () => {
         adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
-        const result = await adminClient.query<GetOrderList.Query>(GET_ORDERS_LIST);
+        const result = await adminClient.query<Codegen.GetOrderListQuery>(GET_ORDERS_LIST);
         expect(result.orders.items.map(o => o.id).sort()).toEqual([order1Id, order2Id]);
     });
 
     it('returns only channel specific orders when on other than default channel', async () => {
         adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
-        const result = await adminClient.query<GetOrderList.Query>(GET_ORDERS_LIST);
+        const result = await adminClient.query<Codegen.GetOrderListQuery>(GET_ORDERS_LIST);
         expect(result.orders.items.map(o => o.id)).toEqual([order1Id]);
     });
 });

+ 45 - 48
packages/core/e2e/order-fulfillment.e2e-spec.ts

@@ -14,16 +14,13 @@ import { initialData } from '../../../e2e-common/e2e-initial-data';
 import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
 
 import { testSuccessfulPaymentMethod } from './fixtures/test-payment-methods';
+import * as Codegen from './graphql/generated-e2e-admin-types';
+import { CreateFulfillmentError, ErrorCode, FulfillmentFragment } from './graphql/generated-e2e-admin-types';
 import {
-    CreateFulfillment,
-    CreateFulfillmentError,
-    CreateShippingMethod,
-    ErrorCode,
-    FulfillmentFragment,
-    GetFulfillmentHandlers,
-    TransitFulfillment,
-} from './graphql/generated-e2e-admin-types';
-import { AddItemToOrder, TestOrderWithPaymentsFragment } from './graphql/generated-e2e-shop-types';
+    AddItemToOrderMutation,
+    AddItemToOrderMutationVariables,
+    TestOrderWithPaymentsFragment,
+} from './graphql/generated-e2e-shop-types';
 import {
     CREATE_FULFILLMENT,
     CREATE_SHIPPING_METHOD,
@@ -96,44 +93,44 @@ describe('Order fulfillments', () => {
             customerCount: 2,
         });
         await adminClient.asSuperAdmin();
-        await adminClient.query<CreateShippingMethod.Mutation, CreateShippingMethod.Variables>(
-            CREATE_SHIPPING_METHOD,
-            {
-                input: {
-                    code: 'test-method',
-                    fulfillmentHandler: manualFulfillmentHandler.code,
-                    checker: {
-                        code: defaultShippingEligibilityChecker.code,
-                        arguments: [
-                            {
-                                name: 'orderMinimum',
-                                value: '0',
-                            },
-                        ],
-                    },
-                    calculator: {
-                        code: defaultShippingCalculator.code,
-                        arguments: [
-                            {
-                                name: 'rate',
-                                value: '500',
-                            },
-                            {
-                                name: 'taxRate',
-                                value: '0',
-                            },
-                        ],
-                    },
-                    translations: [{ languageCode: LanguageCode.en, name: 'test method', description: '' }],
+        await adminClient.query<
+            Codegen.CreateShippingMethodMutation,
+            Codegen.CreateShippingMethodMutationVariables
+        >(CREATE_SHIPPING_METHOD, {
+            input: {
+                code: 'test-method',
+                fulfillmentHandler: manualFulfillmentHandler.code,
+                checker: {
+                    code: defaultShippingEligibilityChecker.code,
+                    arguments: [
+                        {
+                            name: 'orderMinimum',
+                            value: '0',
+                        },
+                    ],
+                },
+                calculator: {
+                    code: defaultShippingCalculator.code,
+                    arguments: [
+                        {
+                            name: 'rate',
+                            value: '500',
+                        },
+                        {
+                            name: 'taxRate',
+                            value: '0',
+                        },
+                    ],
                 },
+                translations: [{ languageCode: LanguageCode.en, name: 'test method', description: '' }],
             },
-        );
+        });
         await shopClient.asUserWithCredentials('hayden.zieme12@hotmail.com', 'test');
-        await shopClient.query<AddItemToOrder.Mutation, AddItemToOrder.Variables>(ADD_ITEM_TO_ORDER, {
+        await shopClient.query<AddItemToOrderMutation, AddItemToOrderMutationVariables>(ADD_ITEM_TO_ORDER, {
             productVariantId: 'T_1',
             quantity: 1,
         });
-        await shopClient.query<AddItemToOrder.Mutation, AddItemToOrder.Variables>(ADD_ITEM_TO_ORDER, {
+        await shopClient.query<AddItemToOrderMutation, AddItemToOrderMutationVariables>(ADD_ITEM_TO_ORDER, {
             productVariantId: 'T_2',
             quantity: 1,
         });
@@ -148,7 +145,7 @@ describe('Order fulfillments', () => {
     });
 
     it('fulfillmentHandlers query', async () => {
-        const { fulfillmentHandlers } = await adminClient.query<GetFulfillmentHandlers.Query>(
+        const { fulfillmentHandlers } = await adminClient.query<Codegen.GetFulfillmentHandlersQuery>(
             GET_FULFILLMENT_HANDLERS,
         );
 
@@ -160,8 +157,8 @@ describe('Order fulfillments', () => {
 
     it('creates fulfillment based on args', async () => {
         const { addFulfillmentToOrder } = await adminClient.query<
-            CreateFulfillment.Mutation,
-            CreateFulfillment.Variables
+            Codegen.CreateFulfillmentMutation,
+            Codegen.CreateFulfillmentMutationVariables
         >(CREATE_FULFILLMENT, {
             input: {
                 lines: order.lines.slice(0, 1).map(l => ({ orderLineId: l.id, quantity: l.quantity })),
@@ -189,8 +186,8 @@ describe('Order fulfillments', () => {
 
     it('onFulfillmentTransition can prevent state transition', async () => {
         const { transitionFulfillmentToState } = await adminClient.query<
-            TransitFulfillment.Mutation,
-            TransitFulfillment.Variables
+            Codegen.TransitFulfillmentMutation,
+            Codegen.TransitFulfillmentMutationVariables
         >(TRANSIT_FULFILLMENT, {
             id: f1Id,
             state: 'Shipped',
@@ -203,8 +200,8 @@ describe('Order fulfillments', () => {
 
     it('throwing from createFulfillment returns CreateFulfillmentError result', async () => {
         const { addFulfillmentToOrder } = await adminClient.query<
-            CreateFulfillment.Mutation,
-            CreateFulfillment.Variables
+            Codegen.CreateFulfillmentMutation,
+            Codegen.CreateFulfillmentMutationVariables
         >(CREATE_FULFILLMENT, {
             input: {
                 lines: order.lines.slice(1, 2).map(l => ({ orderLineId: l.id, quantity: l.quantity })),

+ 9 - 3
packages/core/e2e/order-item-price-calculation-strategy.e2e-spec.ts

@@ -7,11 +7,17 @@ import { initialData } from '../../../e2e-common/e2e-initial-data';
 import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
 
 import { TestOrderItemPriceCalculationStrategy } from './fixtures/test-order-item-price-calculation-strategy';
-import { AddItemToOrder, SearchProductsShop, SinglePrice } from './graphql/generated-e2e-shop-types';
+import {
+    AddItemToOrderMutation,
+    AddItemToOrderMutationVariables,
+    SearchProductsShopQuery,
+    SearchProductsShopQueryVariables,
+    SinglePrice,
+} from './graphql/generated-e2e-shop-types';
 import { ADD_ITEM_TO_ORDER, SEARCH_PRODUCTS_SHOP } from './graphql/shop-definitions';
 
 describe('custom OrderItemPriceCalculationStrategy', () => {
-    let variants: SearchProductsShop.Items[];
+    let variants: SearchProductsShopQuery['search']['items'];
     const { server, adminClient, shopClient } = createTestEnvironment(
         mergeConfig(testConfig(), {
             customFields: {
@@ -30,7 +36,7 @@ describe('custom OrderItemPriceCalculationStrategy', () => {
             productsCsvPath: path.join(__dirname, 'fixtures/e2e-products-full.csv'),
             customerCount: 3,
         });
-        const { search } = await shopClient.query<SearchProductsShop.Query, SearchProductsShop.Variables>(
+        const { search } = await shopClient.query<SearchProductsShopQuery, SearchProductsShopQueryVariables>(
             SEARCH_PRODUCTS_SHOP,
             {
                 input: { take: 3, groupByProduct: false },

+ 15 - 11
packages/core/e2e/order-merge.e2e-spec.ts

@@ -17,9 +17,10 @@ import path from 'path';
 import { initialData } from '../../../e2e-common/e2e-initial-data';
 import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
 
-import { AttemptLogin, GetCustomerList } from './graphql/generated-e2e-admin-types';
+import * as Codegen from './graphql/generated-e2e-admin-types';
 import {
-    AddItemToOrder,
+    AddItemToOrderMutation,
+    AddItemToOrderMutationVariables,
     TestOrderFragmentFragment,
     UpdatedOrderFragment,
 } from './graphql/generated-e2e-shop-types';
@@ -38,7 +39,7 @@ class DelegateMergeStrategy implements OrderMergeStrategy {
     }
 }
 
-type AddItemToOrderWithCustomFields = AddItemToOrder.Variables & {
+type AddItemToOrderWithCustomFields = AddItemToOrderMutationVariables & {
     customFields?: { inscription?: string };
 };
 
@@ -48,7 +49,7 @@ describe('Order merging', () => {
         input => !!input.lines,
     );
 
-    let customers: GetCustomerList.Items[];
+    let customers: Codegen.GetCustomerListQuery['customers']['items'];
 
     const { server, shopClient, adminClient } = createTestEnvironment(
         mergeConfig(testConfig(), {
@@ -67,7 +68,7 @@ describe('Order merging', () => {
             customerCount: 10,
         });
         await adminClient.asSuperAdmin();
-        const result = await adminClient.query<GetCustomerList.Query>(GET_CUSTOMER_LIST);
+        const result = await adminClient.query<Codegen.GetCustomerListQuery>(GET_CUSTOMER_LIST);
         customers = result.customers.items;
     }, TEST_SETUP_TIMEOUT_MS);
 
@@ -86,7 +87,7 @@ describe('Order merging', () => {
 
         await shopClient.asUserWithCredentials(customerEmailAddress, 'test');
         for (const line of existingOrderLines) {
-            await shopClient.query<AddItemToOrder.Mutation, AddItemToOrderWithCustomFields>(
+            await shopClient.query<AddItemToOrderMutation, AddItemToOrderWithCustomFields>(
                 ADD_ITEM_TO_ORDER_WITH_CUSTOM_FIELDS,
                 line,
             );
@@ -94,16 +95,19 @@ describe('Order merging', () => {
 
         await shopClient.asAnonymousUser();
         for (const line of guestOrderLines) {
-            await shopClient.query<AddItemToOrder.Mutation, AddItemToOrderWithCustomFields>(
+            await shopClient.query<AddItemToOrderMutation, AddItemToOrderWithCustomFields>(
                 ADD_ITEM_TO_ORDER_WITH_CUSTOM_FIELDS,
                 line,
             );
         }
 
-        await shopClient.query<AttemptLogin.Mutation, AttemptLogin.Variables>(ATTEMPT_LOGIN, {
-            username: customerEmailAddress,
-            password: 'test',
-        });
+        await shopClient.query<Codegen.AttemptLoginMutation, Codegen.AttemptLoginMutationVariables>(
+            ATTEMPT_LOGIN,
+            {
+                username: customerEmailAddress,
+                password: 'test',
+            },
+        );
         const { activeOrder } = await shopClient.query(GET_ACTIVE_ORDER_WITH_CUSTOM_FIELDS);
         return activeOrder;
     }

Plik diff jest za duży
+ 387 - 349
packages/core/e2e/order-modification.e2e-spec.ts


+ 129 - 101
packages/core/e2e/order-process.e2e-spec.ts

@@ -122,10 +122,13 @@ describe('Order process', () => {
             transitionEndSpy.mockClear();
             await shopClient.asAnonymousUser();
 
-            await shopClient.query<AddItemToOrder.Mutation, AddItemToOrder.Variables>(ADD_ITEM_TO_ORDER, {
-                productVariantId: 'T_1',
-                quantity: 1,
-            });
+            await shopClient.query<Codegen.AddItemToOrderMutation, Codegen.AddItemToOrderMutationVariables>(
+                ADD_ITEM_TO_ORDER,
+                {
+                    productVariantId: 'T_1',
+                    quantity: 1,
+                },
+            );
 
             expect(transitionStartSpy).toHaveBeenCalledTimes(1);
             expect(transitionEndSpy).toHaveBeenCalledTimes(1);
@@ -141,12 +144,17 @@ describe('Order process', () => {
         });
 
         it('replaced transition target', async () => {
-            await shopClient.query<AddItemToOrder.Mutation, AddItemToOrder.Variables>(ADD_ITEM_TO_ORDER, {
-                productVariantId: 'T_1',
-                quantity: 1,
-            });
+            await shopClient.query<Codegen.AddItemToOrderMutation, Codegen.AddItemToOrderMutationVariables>(
+                ADD_ITEM_TO_ORDER,
+                {
+                    productVariantId: 'T_1',
+                    quantity: 1,
+                },
+            );
 
-            const { nextOrderStates } = await shopClient.query<GetNextOrderStates.Query>(GET_NEXT_STATES);
+            const { nextOrderStates } = await shopClient.query<Codegen.GetNextOrderStatesQuery>(
+                GET_NEXT_STATES,
+            );
 
             expect(nextOrderStates).toEqual(['ValidatingCustomer']);
         });
@@ -156,8 +164,8 @@ describe('Order process', () => {
             transitionEndSpy.mockClear();
 
             const { transitionOrderToState } = await shopClient.query<
-                TransitionToState.Mutation,
-                TransitionToState.Variables
+                Codegen.TransitionToStateMutation,
+                Codegen.TransitionToStateMutationVariables
             >(TRANSITION_TO_STATE, {
                 state: 'ValidatingCustomer',
             });
@@ -176,20 +184,20 @@ describe('Order process', () => {
             transitionStartSpy.mockClear();
             transitionErrorSpy.mockClear();
 
-            await shopClient.query<SetCustomerForOrder.Mutation, SetCustomerForOrder.Variables>(
-                SET_CUSTOMER,
-                {
-                    input: {
-                        firstName: 'Joe',
-                        lastName: 'Test',
-                        emailAddress: 'joetest@gmail.com',
-                    },
+            await shopClient.query<
+                Codegen.SetCustomerForOrderMutation,
+                Codegen.SetCustomerForOrderMutationVariables
+            >(SET_CUSTOMER, {
+                input: {
+                    firstName: 'Joe',
+                    lastName: 'Test',
+                    emailAddress: 'joetest@gmail.com',
                 },
-            );
+            });
 
             const { transitionOrderToState } = await shopClient.query<
-                TransitionToState.Mutation,
-                TransitionToState.Variables
+                Codegen.TransitionToStateMutation,
+                Codegen.TransitionToStateMutationVariables
             >(TRANSITION_TO_STATE, {
                 state: 'ValidatingCustomer',
             });
@@ -216,20 +224,20 @@ describe('Order process', () => {
         it('custom onTransitionStart handler allows transition', async () => {
             transitionEndSpy.mockClear();
 
-            await shopClient.query<SetCustomerForOrder.Mutation, SetCustomerForOrder.Variables>(
-                SET_CUSTOMER,
-                {
-                    input: {
-                        firstName: 'Joe',
-                        lastName: 'Test',
-                        emailAddress: 'joetest@company.com',
-                    },
+            await shopClient.query<
+                Codegen.SetCustomerForOrderMutation,
+                Codegen.SetCustomerForOrderMutationVariables
+            >(SET_CUSTOMER, {
+                input: {
+                    firstName: 'Joe',
+                    lastName: 'Test',
+                    emailAddress: 'joetest@company.com',
                 },
-            );
+            });
 
             const { transitionOrderToState } = await shopClient.query<
-                TransitionToState.Mutation,
-                TransitionToState.Variables
+                Codegen.TransitionToStateMutation,
+                Codegen.TransitionToStateMutationVariables
             >(TRANSITION_TO_STATE, {
                 state: 'ValidatingCustomer',
             });
@@ -244,16 +252,18 @@ describe('Order process', () => {
             transitionEndSpy.mockClear();
             transitionEndSpy2.mockClear();
 
-            const { nextOrderStates } = await shopClient.query<GetNextOrderStates.Query>(GET_NEXT_STATES);
+            const { nextOrderStates } = await shopClient.query<Codegen.GetNextOrderStatesQuery>(
+                GET_NEXT_STATES,
+            );
 
             expect(nextOrderStates).toEqual(['ArrangingPayment', 'AddingItems', 'Cancelled']);
 
-            await shopClient.query<TransitionToState.Mutation, TransitionToState.Variables>(
-                TRANSITION_TO_STATE,
-                {
-                    state: 'AddingItems',
-                },
-            );
+            await shopClient.query<
+                Codegen.TransitionToStateMutation,
+                Codegen.TransitionToStateMutationVariables
+            >(TRANSITION_TO_STATE, {
+                state: 'AddingItems',
+            });
 
             expect(transitionEndSpy.mock.calls[0].slice(0, 2)).toEqual(['ValidatingCustomer', 'AddingItems']);
             expect(transitionEndSpy2.mock.calls[0].slice(0, 2)).toEqual([
@@ -268,46 +278,49 @@ describe('Order process', () => {
 
         beforeAll(async () => {
             await shopClient.asAnonymousUser();
-            await shopClient.query<AddItemToOrder.Mutation, AddItemToOrder.Variables>(ADD_ITEM_TO_ORDER, {
-                productVariantId: 'T_1',
-                quantity: 1,
-            });
-            await shopClient.query<SetCustomerForOrder.Mutation, SetCustomerForOrder.Variables>(
-                SET_CUSTOMER,
+            await shopClient.query<Codegen.AddItemToOrderMutation, Codegen.AddItemToOrderMutationVariables>(
+                ADD_ITEM_TO_ORDER,
                 {
-                    input: {
-                        firstName: 'Su',
-                        lastName: 'Test',
-                        emailAddress: 'sutest@company.com',
-                    },
+                    productVariantId: 'T_1',
+                    quantity: 1,
                 },
             );
-            await shopClient.query<SetShippingAddress.Mutation, SetShippingAddress.Variables>(
-                SET_SHIPPING_ADDRESS,
-                {
-                    input: {
-                        fullName: 'name',
-                        streetLine1: '12 the street',
-                        city: 'foo',
-                        postalCode: '123456',
-                        countryCode: 'US',
-                        phoneNumber: '4444444',
-                    },
+            await shopClient.query<
+                Codegen.SetCustomerForOrderMutation,
+                Codegen.SetCustomerForOrderMutationVariables
+            >(SET_CUSTOMER, {
+                input: {
+                    firstName: 'Su',
+                    lastName: 'Test',
+                    emailAddress: 'sutest@company.com',
                 },
-            );
-            await shopClient.query<SetShippingMethod.Mutation, SetShippingMethod.Variables>(
-                SET_SHIPPING_METHOD,
-                { id: 'T_1' },
-            );
-            await shopClient.query<TransitionToState.Mutation, TransitionToState.Variables>(
-                TRANSITION_TO_STATE,
-                {
-                    state: 'ValidatingCustomer',
+            });
+            await shopClient.query<
+                Codegen.SetShippingAddressMutation,
+                Codegen.SetShippingAddressMutationVariables
+            >(SET_SHIPPING_ADDRESS, {
+                input: {
+                    fullName: 'name',
+                    streetLine1: '12 the street',
+                    city: 'foo',
+                    postalCode: '123456',
+                    countryCode: 'US',
+                    phoneNumber: '4444444',
                 },
-            );
+            });
+            await shopClient.query<
+                Codegen.SetShippingMethodMutation,
+                Codegen.SetShippingMethodMutationVariables
+            >(SET_SHIPPING_METHOD, { id: 'T_1' });
+            await shopClient.query<
+                Codegen.TransitionToStateMutation,
+                Codegen.TransitionToStateMutationVariables
+            >(TRANSITION_TO_STATE, {
+                state: 'ValidatingCustomer',
+            });
             const { transitionOrderToState } = await shopClient.query<
-                TransitionToState.Mutation,
-                TransitionToState.Variables
+                Codegen.TransitionToStateMutation,
+                Codegen.TransitionToStateMutationVariables
             >(TRANSITION_TO_STATE, {
                 state: 'ArrangingPayment',
             });
@@ -320,8 +333,8 @@ describe('Order process', () => {
             expect(order.state).toBe('ArrangingPayment');
 
             const { transitionOrderToState } = await adminClient.query<
-                AdminTransition.Mutation,
-                AdminTransition.Variables
+                Codegen.AdminTransitionMutation,
+                Codegen.AdminTransitionMutationVariables
             >(ADMIN_TRANSITION_TO_STATE, {
                 id: order.id,
                 state: 'PaymentAuthorized',
@@ -335,16 +348,19 @@ describe('Order process', () => {
                 'Cannot transition Order to the "PaymentAuthorized" state when the total is not covered by authorized Payments',
             );
 
-            const result = await adminClient.query<GetOrder.Query, GetOrder.Variables>(GET_ORDER, {
-                id: order.id,
-            });
+            const result = await adminClient.query<Codegen.GetOrderQuery, Codegen.GetOrderQueryVariables>(
+                GET_ORDER,
+                {
+                    id: order.id,
+                },
+            );
             expect(result.order?.state).toBe('ArrangingPayment');
         });
 
         it('cannot manually transition to PaymentSettled', async () => {
             const { transitionOrderToState } = await adminClient.query<
-                AdminTransition.Mutation,
-                AdminTransition.Variables
+                Codegen.AdminTransitionMutation,
+                Codegen.AdminTransitionMutationVariables
             >(ADMIN_TRANSITION_TO_STATE, {
                 id: order.id,
                 state: 'PaymentSettled',
@@ -358,16 +374,19 @@ describe('Order process', () => {
                 'Cannot transition Order to the "PaymentSettled" state when the total is not covered by settled Payments',
             );
 
-            const result = await adminClient.query<GetOrder.Query, GetOrder.Variables>(GET_ORDER, {
-                id: order.id,
-            });
+            const result = await adminClient.query<Codegen.GetOrderQuery, Codegen.GetOrderQueryVariables>(
+                GET_ORDER,
+                {
+                    id: order.id,
+                },
+            );
             expect(result.order?.state).toBe('ArrangingPayment');
         });
 
         it('cannot manually transition to Cancelled', async () => {
             const { addPaymentToOrder } = await shopClient.query<
-                AddPaymentToOrder.Mutation,
-                AddPaymentToOrder.Variables
+                Codegen.AddPaymentToOrderMutation,
+                Codegen.AddPaymentToOrderMutationVariables
             >(ADD_PAYMENT, {
                 input: {
                     method: testSuccessfulPaymentMethod.code,
@@ -379,8 +398,8 @@ describe('Order process', () => {
             expect(addPaymentToOrder?.state).toBe('PaymentSettled');
 
             const { transitionOrderToState } = await adminClient.query<
-                AdminTransition.Mutation,
-                AdminTransition.Variables
+                Codegen.AdminTransitionMutation,
+                Codegen.AdminTransitionMutationVariables
             >(ADMIN_TRANSITION_TO_STATE, {
                 id: order.id,
                 state: 'Cancelled',
@@ -394,16 +413,19 @@ describe('Order process', () => {
                 'Cannot transition Order to the "Cancelled" state unless all OrderItems are cancelled',
             );
 
-            const result = await adminClient.query<GetOrder.Query, GetOrder.Variables>(GET_ORDER, {
-                id: order.id,
-            });
+            const result = await adminClient.query<Codegen.GetOrderQuery, Codegen.GetOrderQueryVariables>(
+                GET_ORDER,
+                {
+                    id: order.id,
+                },
+            );
             expect(result.order?.state).toBe('PaymentSettled');
         });
 
         it('cannot manually transition to PartiallyDelivered', async () => {
             const { transitionOrderToState } = await adminClient.query<
-                AdminTransition.Mutation,
-                AdminTransition.Variables
+                Codegen.AdminTransitionMutation,
+                Codegen.AdminTransitionMutationVariables
             >(ADMIN_TRANSITION_TO_STATE, {
                 id: order.id,
                 state: 'PartiallyDelivered',
@@ -417,16 +439,19 @@ describe('Order process', () => {
                 'Cannot transition Order to the "PartiallyDelivered" state unless some OrderItems are delivered',
             );
 
-            const result = await adminClient.query<GetOrder.Query, GetOrder.Variables>(GET_ORDER, {
-                id: order.id,
-            });
+            const result = await adminClient.query<Codegen.GetOrderQuery, Codegen.GetOrderQueryVariables>(
+                GET_ORDER,
+                {
+                    id: order.id,
+                },
+            );
             expect(result.order?.state).toBe('PaymentSettled');
         });
 
         it('cannot manually transition to PartiallyDelivered', async () => {
             const { transitionOrderToState } = await adminClient.query<
-                AdminTransition.Mutation,
-                AdminTransition.Variables
+                Codegen.AdminTransitionMutation,
+                Codegen.AdminTransitionMutationVariables
             >(ADMIN_TRANSITION_TO_STATE, {
                 id: order.id,
                 state: 'Delivered',
@@ -440,9 +465,12 @@ describe('Order process', () => {
                 'Cannot transition Order to the "Delivered" state unless all OrderItems are delivered',
             );
 
-            const result = await adminClient.query<GetOrder.Query, GetOrder.Variables>(GET_ORDER, {
-                id: order.id,
-            });
+            const result = await adminClient.query<Codegen.GetOrderQuery, Codegen.GetOrderQueryVariables>(
+                GET_ORDER,
+                {
+                    id: order.id,
+                },
+            );
             expect(result.order?.state).toBe('PaymentSettled');
         });
     });

Plik diff jest za duży
+ 218 - 211
packages/core/e2e/order-promotion.e2e-spec.ts


+ 82 - 67
packages/core/e2e/order-taxes.e2e-spec.ts

@@ -17,20 +17,8 @@ import { initialData } from '../../../e2e-common/e2e-initial-data';
 import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
 
 import { testSuccessfulPaymentMethod } from './fixtures/test-payment-methods';
-import {
-    GetProductsWithVariantPrices,
-    GetTaxRateList,
-    UpdateChannel,
-    UpdateTaxRate,
-} from './graphql/generated-e2e-admin-types';
-import {
-    AddItemToOrder,
-    GetActiveOrderWithPriceData,
-    SetBillingAddress,
-    SetShippingAddress,
-    TestOrderFragmentFragment,
-    UpdatedOrderFragment,
-} from './graphql/generated-e2e-shop-types';
+import * as Codegen from './graphql/generated-e2e-admin-types';
+import * as CodegenShop from './graphql/generated-e2e-shop-types';
 import {
     GET_PRODUCTS_WITH_VARIANT_PRICES,
     UPDATE_CHANNEL,
@@ -73,7 +61,7 @@ class TestTaxZoneStrategy implements TaxZoneStrategy {
         return zoneForCountryCode ?? channel.defaultTaxZone;
     }
 
-    private getZoneForCountryCode(ctx: RequestContext, countryCode: string): Promise<Zone | undefined> {
+    private getZoneForCountryCode(ctx: RequestContext, countryCode?: string): Promise<Zone | undefined> {
         return this.connection
             .getRepository(ctx, Zone)
             .createQueryBuilder('zone')
@@ -96,11 +84,11 @@ describe('Order taxes', () => {
         },
     });
 
-    type OrderSuccessResult = UpdatedOrderFragment | TestOrderFragmentFragment;
+    type OrderSuccessResult = CodegenShop.UpdatedOrderFragment | CodegenShop.TestOrderFragmentFragment;
     const orderResultGuard: ErrorResultGuard<OrderSuccessResult> = createErrorResultGuard(
         input => !!input.lines,
     );
-    let products: GetProductsWithVariantPrices.Items[];
+    let products: Codegen.GetProductsWithVariantPricesQuery['products']['items'];
 
     beforeAll(async () => {
         await server.init({
@@ -117,7 +105,7 @@ describe('Order taxes', () => {
             customerCount: 2,
         });
         await adminClient.asSuperAdmin();
-        const result = await adminClient.query<GetProductsWithVariantPrices.Query>(
+        const result = await adminClient.query<Codegen.GetProductsWithVariantPricesQuery>(
             GET_PRODUCTS_WITH_VARIANT_PRICES,
         );
         products = result.products.items;
@@ -129,23 +117,29 @@ describe('Order taxes', () => {
 
     describe('Channel.pricesIncludeTax = false', () => {
         beforeAll(async () => {
-            await adminClient.query<UpdateChannel.Mutation, UpdateChannel.Variables>(UPDATE_CHANNEL, {
-                input: {
-                    id: 'T_1',
-                    pricesIncludeTax: false,
+            await adminClient.query<Codegen.UpdateChannelMutation, Codegen.UpdateChannelMutationVariables>(
+                UPDATE_CHANNEL,
+                {
+                    input: {
+                        id: 'T_1',
+                        pricesIncludeTax: false,
+                    },
                 },
-            });
+            );
             await shopClient.asAnonymousUser();
         });
 
         it('prices are correct', async () => {
             const variant = products.sort(sortById)[0].variants.sort(sortById)[0];
-            await shopClient.query<AddItemToOrder.Mutation, AddItemToOrder.Variables>(ADD_ITEM_TO_ORDER, {
+            await shopClient.query<
+                CodegenShop.AddItemToOrderMutation,
+                CodegenShop.AddItemToOrderMutationVariables
+            >(ADD_ITEM_TO_ORDER, {
                 productVariantId: variant.id,
                 quantity: 2,
             });
 
-            const { activeOrder } = await shopClient.query<GetActiveOrderWithPriceData.Query>(
+            const { activeOrder } = await shopClient.query<CodegenShop.GetActiveOrderWithPriceDataQuery>(
                 GET_ACTIVE_ORDER_WITH_PRICE_DATA,
             );
             expect(activeOrder?.totalWithTax).toBe(240);
@@ -170,23 +164,29 @@ describe('Order taxes', () => {
 
     describe('Channel.pricesIncludeTax = true', () => {
         beforeAll(async () => {
-            await adminClient.query<UpdateChannel.Mutation, UpdateChannel.Variables>(UPDATE_CHANNEL, {
-                input: {
-                    id: 'T_1',
-                    pricesIncludeTax: true,
+            await adminClient.query<Codegen.UpdateChannelMutation, Codegen.UpdateChannelMutationVariables>(
+                UPDATE_CHANNEL,
+                {
+                    input: {
+                        id: 'T_1',
+                        pricesIncludeTax: true,
+                    },
                 },
-            });
+            );
             await shopClient.asAnonymousUser();
         });
 
         it('prices are correct', async () => {
             const variant = products[0].variants[0];
-            await shopClient.query<AddItemToOrder.Mutation, AddItemToOrder.Variables>(ADD_ITEM_TO_ORDER, {
+            await shopClient.query<
+                CodegenShop.AddItemToOrderMutation,
+                CodegenShop.AddItemToOrderMutationVariables
+            >(ADD_ITEM_TO_ORDER, {
                 productVariantId: variant.id,
                 quantity: 2,
             });
 
-            const { activeOrder } = await shopClient.query<GetActiveOrderWithPriceData.Query>(
+            const { activeOrder } = await shopClient.query<CodegenShop.GetActiveOrderWithPriceDataQuery>(
                 GET_ACTIVE_ORDER_WITH_PRICE_DATA,
             );
             expect(activeOrder?.totalWithTax).toBe(200);
@@ -210,11 +210,14 @@ describe('Order taxes', () => {
 
         // https://github.com/vendure-ecommerce/vendure/issues/1216
         it('re-calculates OrderItem prices when shippingAddress causes activeTaxZone change', async () => {
-            const { taxRates } = await adminClient.query<GetTaxRateList.Query>(GET_TAX_RATE_LIST);
+            const { taxRates } = await adminClient.query<Codegen.GetTaxRateListQuery>(GET_TAX_RATE_LIST);
             // Set the TaxRates to Asia to 0%
             const taxRatesAsia = taxRates.items.filter(tr => tr.name.includes('Asia'));
             for (const taxRate of taxRatesAsia) {
-                await adminClient.query<UpdateTaxRate.Mutation, UpdateTaxRate.Variables>(UPDATE_TAX_RATE, {
+                await adminClient.query<
+                    Codegen.UpdateTaxRateMutation,
+                    Codegen.UpdateTaxRateMutationVariables
+                >(UPDATE_TAX_RATE, {
                     input: {
                         id: taxRate.id,
                         value: 0,
@@ -222,20 +225,20 @@ describe('Order taxes', () => {
                 });
             }
 
-            await shopClient.query<SetShippingAddress.Mutation, SetShippingAddress.Variables>(
-                SET_SHIPPING_ADDRESS,
-                {
-                    input: {
-                        countryCode: 'CN',
-                        streetLine1: '123 Lugu St',
-                        city: 'Beijing',
-                        province: 'Beijing',
-                        postalCode: '12340',
-                    },
+            await shopClient.query<
+                CodegenShop.SetShippingAddressMutation,
+                CodegenShop.SetShippingAddressMutationVariables
+            >(SET_SHIPPING_ADDRESS, {
+                input: {
+                    countryCode: 'CN',
+                    streetLine1: '123 Lugu St',
+                    city: 'Beijing',
+                    province: 'Beijing',
+                    postalCode: '12340',
                 },
-            );
+            });
 
-            const { activeOrder } = await shopClient.query<GetActiveOrderWithPriceData.Query>(
+            const { activeOrder } = await shopClient.query<CodegenShop.GetActiveOrderWithPriceDataQuery>(
                 GET_ACTIVE_ORDER_WITH_PRICE_DATA,
             );
             expect(activeOrder?.totalWithTax).toBe(166);
@@ -259,20 +262,20 @@ describe('Order taxes', () => {
 
         // https://github.com/vendure-ecommerce/vendure/issues/1216
         it('re-calculates OrderItem prices when billingAddress causes activeTaxZone change', async () => {
-            await shopClient.query<SetBillingAddress.Mutation, SetBillingAddress.Variables>(
-                SET_BILLING_ADDRESS,
-                {
-                    input: {
-                        countryCode: 'US',
-                        streetLine1: '123 Chad Street',
-                        city: 'Houston',
-                        province: 'Texas',
-                        postalCode: '12345',
-                    },
+            await shopClient.query<
+                CodegenShop.SetBillingAddressMutation,
+                CodegenShop.SetBillingAddressMutationVariables
+            >(SET_BILLING_ADDRESS, {
+                input: {
+                    countryCode: 'US',
+                    streetLine1: '123 Chad Street',
+                    city: 'Houston',
+                    province: 'Texas',
+                    postalCode: '12345',
                 },
-            );
+            });
 
-            const { activeOrder } = await shopClient.query<GetActiveOrderWithPriceData.Query>(
+            const { activeOrder } = await shopClient.query<CodegenShop.GetActiveOrderWithPriceDataQuery>(
                 GET_ACTIVE_ORDER_WITH_PRICE_DATA,
             );
             expect(activeOrder?.totalWithTax).toBe(200);
@@ -296,27 +299,39 @@ describe('Order taxes', () => {
     });
 
     it('taxSummary works', async () => {
-        await adminClient.query<UpdateChannel.Mutation, UpdateChannel.Variables>(UPDATE_CHANNEL, {
-            input: {
-                id: 'T_1',
-                pricesIncludeTax: false,
+        await adminClient.query<Codegen.UpdateChannelMutation, Codegen.UpdateChannelMutationVariables>(
+            UPDATE_CHANNEL,
+            {
+                input: {
+                    id: 'T_1',
+                    pricesIncludeTax: false,
+                },
             },
-        });
+        );
         await shopClient.asAnonymousUser();
-        await shopClient.query<AddItemToOrder.Mutation, AddItemToOrder.Variables>(ADD_ITEM_TO_ORDER, {
+        await shopClient.query<
+            CodegenShop.AddItemToOrderMutation,
+            CodegenShop.AddItemToOrderMutationVariables
+        >(ADD_ITEM_TO_ORDER, {
             productVariantId: products[0].variants[0].id,
             quantity: 2,
         });
-        await shopClient.query<AddItemToOrder.Mutation, AddItemToOrder.Variables>(ADD_ITEM_TO_ORDER, {
+        await shopClient.query<
+            CodegenShop.AddItemToOrderMutation,
+            CodegenShop.AddItemToOrderMutationVariables
+        >(ADD_ITEM_TO_ORDER, {
             productVariantId: products[1].variants[0].id,
             quantity: 2,
         });
-        await shopClient.query<AddItemToOrder.Mutation, AddItemToOrder.Variables>(ADD_ITEM_TO_ORDER, {
+        await shopClient.query<
+            CodegenShop.AddItemToOrderMutation,
+            CodegenShop.AddItemToOrderMutationVariables
+        >(ADD_ITEM_TO_ORDER, {
             productVariantId: products[2].variants[0].id,
             quantity: 2,
         });
 
-        const { activeOrder } = await shopClient.query<GetActiveOrderWithPriceData.Query>(
+        const { activeOrder } = await shopClient.query<CodegenShop.GetActiveOrderWithPriceDataQuery>(
             GET_ACTIVE_ORDER_WITH_PRICE_DATA,
         );
 

Plik diff jest za duży
+ 310 - 270
packages/core/e2e/order.e2e-spec.ts


+ 38 - 43
packages/core/e2e/parallel-transactions.e2e-spec.ts

@@ -6,13 +6,8 @@ import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-conf
 import { createTestEnvironment } from '../../testing/lib/create-test-environment';
 
 import { SlowMutationPlugin } from './fixtures/test-plugins/slow-mutation-plugin';
-import {
-    AddOptionGroupToProduct,
-    CreateProduct,
-    CreateProductOptionGroup,
-    CreateProductVariants,
-    LanguageCode,
-} from './graphql/generated-e2e-admin-types';
+import * as Codegen from './graphql/generated-e2e-admin-types';
+import { LanguageCode } from './graphql/generated-e2e-admin-types';
 import {
     ADD_OPTION_GROUP_TO_PRODUCT,
     CREATE_PRODUCT,
@@ -67,22 +62,22 @@ describe('Parallel transactions', () => {
     it('does not deadlock on concurrent creating ProductVariants', async () => {
         const CONCURRENCY_LIMIT = 4;
 
-        const { createProduct } = await adminClient.query<CreateProduct.Mutation, CreateProduct.Variables>(
-            CREATE_PRODUCT,
-            {
-                input: {
-                    translations: [
-                        { languageCode: LanguageCode.en, name: 'Test', slug: 'test', description: 'test' },
-                    ],
-                },
+        const { createProduct } = await adminClient.query<
+            Codegen.CreateProductMutation,
+            Codegen.CreateProductMutationVariables
+        >(CREATE_PRODUCT, {
+            input: {
+                translations: [
+                    { languageCode: LanguageCode.en, name: 'Test', slug: 'test', description: 'test' },
+                ],
             },
-        );
+        });
 
         const sizes = Array.from({ length: CONCURRENCY_LIMIT }).map(i => `size-${i}`);
 
         const { createProductOptionGroup } = await adminClient.query<
-            CreateProductOptionGroup.Mutation,
-            CreateProductOptionGroup.Variables
+            Codegen.CreateProductOptionGroupMutation,
+            Codegen.CreateProductOptionGroupMutationVariables
         >(CREATE_PRODUCT_OPTION_GROUP, {
             input: {
                 code: 'size',
@@ -94,35 +89,35 @@ describe('Parallel transactions', () => {
             },
         });
 
-        await adminClient.query<AddOptionGroupToProduct.Mutation, AddOptionGroupToProduct.Variables>(
-            ADD_OPTION_GROUP_TO_PRODUCT,
-            {
-                productId: createProduct.id,
-                optionGroupId: createProductOptionGroup.id,
-            },
-        );
+        await adminClient.query<
+            Codegen.AddOptionGroupToProductMutation,
+            Codegen.AddOptionGroupToProductMutationVariables
+        >(ADD_OPTION_GROUP_TO_PRODUCT, {
+            productId: createProduct.id,
+            optionGroupId: createProductOptionGroup.id,
+        });
 
         const createVariantMutations = createProductOptionGroup.options
             .filter((_, index) => index < CONCURRENCY_LIMIT)
             .map((option, i) => {
-                return adminClient.query<CreateProductVariants.Mutation, CreateProductVariants.Variables>(
-                    CREATE_PRODUCT_VARIANTS,
-                    {
-                        input: [
-                            {
-                                sku: `VARIANT-${i}`,
-                                productId: createProduct.id,
-                                optionIds: [option.id],
-                                translations: [{ languageCode: LanguageCode.en, name: `Variant ${i}` }],
-                                price: 1000,
-                                taxCategoryId: 'T_1',
-                                facetValueIds: ['T_1', 'T_2'],
-                                featuredAssetId: 'T_1',
-                                assetIds: ['T_1'],
-                            },
-                        ],
-                    },
-                );
+                return adminClient.query<
+                    Codegen.CreateProductVariantsMutation,
+                    Codegen.CreateProductVariantsMutationVariables
+                >(CREATE_PRODUCT_VARIANTS, {
+                    input: [
+                        {
+                            sku: `VARIANT-${i}`,
+                            productId: createProduct.id,
+                            optionIds: [option.id],
+                            translations: [{ languageCode: LanguageCode.en, name: `Variant ${i}` }],
+                            price: 1000,
+                            taxCategoryId: 'T_1',
+                            facetValueIds: ['T_1', 'T_2'],
+                            featuredAssetId: 'T_1',
+                            assetIds: ['T_1'],
+                        },
+                    ],
+                });
             });
 
         const results = await Promise.all(createVariantMutations);

+ 106 - 113
packages/core/e2e/payment-method.e2e-spec.ts

@@ -1,3 +1,4 @@
+/* tslint:disable:no-non-null-assertion */
 import {
     DefaultLogger,
     dummyPaymentHandler,
@@ -16,25 +17,10 @@ import path from 'path';
 import { initialData } from '../../../e2e-common/e2e-initial-data';
 import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
 
-import {
-    CreateChannel,
-    CreatePaymentMethod,
-    CurrencyCode,
-    DeletePaymentMethod,
-    DeletionResult,
-    GetPaymentMethod,
-    GetPaymentMethodCheckers,
-    GetPaymentMethodHandlers,
-    GetPaymentMethodList,
-    UpdatePaymentMethod,
-} from './graphql/generated-e2e-admin-types';
-import {
-    AddItemToOrder,
-    AddPaymentToOrder,
-    ErrorCode,
-    GetEligiblePaymentMethods,
-    TestOrderWithPaymentsFragment,
-} from './graphql/generated-e2e-shop-types';
+import { CurrencyCode, DeletionResult } from './graphql/generated-e2e-admin-types';
+import * as Codegen from './graphql/generated-e2e-admin-types';
+import { ErrorCode } from './graphql/generated-e2e-shop-types';
+import * as CodegenShop from './graphql/generated-e2e-shop-types';
 import { CREATE_CHANNEL } from './graphql/shared-definitions';
 import { ADD_ITEM_TO_ORDER, ADD_PAYMENT, GET_ELIGIBLE_PAYMENT_METHODS } from './graphql/shop-definitions';
 import { proceedToArrangingPayment } from './utils/test-order-utils';
@@ -60,7 +46,7 @@ const minPriceChecker = new PaymentMethodEligibilityChecker({
 });
 
 describe('PaymentMethod resolver', () => {
-    const orderGuard: ErrorResultGuard<TestOrderWithPaymentsFragment> = createErrorResultGuard(
+    const orderGuard: ErrorResultGuard<CodegenShop.TestOrderWithPaymentsFragment> = createErrorResultGuard(
         input => !!input.lines,
     );
 
@@ -88,8 +74,8 @@ describe('PaymentMethod resolver', () => {
 
     it('create', async () => {
         const { createPaymentMethod } = await adminClient.query<
-            CreatePaymentMethod.Mutation,
-            CreatePaymentMethod.Variables
+            Codegen.CreatePaymentMethodMutation,
+            Codegen.CreatePaymentMethodMutationVariables
         >(CREATE_PAYMENT_METHOD, {
             input: {
                 code: 'no-checks',
@@ -124,8 +110,8 @@ describe('PaymentMethod resolver', () => {
 
     it('update', async () => {
         const { updatePaymentMethod } = await adminClient.query<
-            UpdatePaymentMethod.Mutation,
-            UpdatePaymentMethod.Variables
+            Codegen.UpdatePaymentMethodMutation,
+            Codegen.UpdatePaymentMethodMutationVariables
         >(UPDATE_PAYMENT_METHOD, {
             input: {
                 id: 'T_1',
@@ -165,8 +151,8 @@ describe('PaymentMethod resolver', () => {
 
     it('unset checker', async () => {
         const { updatePaymentMethod } = await adminClient.query<
-            UpdatePaymentMethod.Mutation,
-            UpdatePaymentMethod.Variables
+            Codegen.UpdatePaymentMethodMutation,
+            Codegen.UpdatePaymentMethodMutationVariables
         >(UPDATE_PAYMENT_METHOD, {
             input: {
                 id: 'T_1',
@@ -176,17 +162,16 @@ describe('PaymentMethod resolver', () => {
 
         expect(updatePaymentMethod.checker).toEqual(null);
 
-        const { paymentMethod } = await adminClient.query<GetPaymentMethod.Query, GetPaymentMethod.Variables>(
-            GET_PAYMENT_METHOD,
-            { id: 'T_1' },
-        );
-        expect(paymentMethod.checker).toEqual(null);
+        const { paymentMethod } = await adminClient.query<
+            Codegen.GetPaymentMethodQuery,
+            Codegen.GetPaymentMethodQueryVariables
+        >(GET_PAYMENT_METHOD, { id: 'T_1' });
+        expect(paymentMethod!.checker).toEqual(null);
     });
 
     it('paymentMethodEligibilityCheckers', async () => {
-        const { paymentMethodEligibilityCheckers } = await adminClient.query<GetPaymentMethodCheckers.Query>(
-            GET_PAYMENT_METHOD_CHECKERS,
-        );
+        const { paymentMethodEligibilityCheckers } =
+            await adminClient.query<Codegen.GetPaymentMethodCheckersQuery>(GET_PAYMENT_METHOD_CHECKERS);
         expect(paymentMethodEligibilityCheckers).toEqual([
             {
                 code: minPriceChecker.code,
@@ -196,7 +181,7 @@ describe('PaymentMethod resolver', () => {
     });
 
     it('paymentMethodHandlers', async () => {
-        const { paymentMethodHandlers } = await adminClient.query<GetPaymentMethodHandlers.Query>(
+        const { paymentMethodHandlers } = await adminClient.query<Codegen.GetPaymentMethodHandlersQuery>(
             GET_PAYMENT_METHOD_HANDLERS,
         );
         expect(paymentMethodHandlers).toEqual([
@@ -209,43 +194,46 @@ describe('PaymentMethod resolver', () => {
 
     describe('eligibility checks', () => {
         beforeAll(async () => {
-            await adminClient.query<CreatePaymentMethod.Mutation, CreatePaymentMethod.Variables>(
-                CREATE_PAYMENT_METHOD,
-                {
-                    input: {
-                        code: 'price-check',
-                        name: 'With Min Price Checker',
-                        description: 'Order total must be more than 2k',
-                        enabled: true,
-                        checker: {
-                            code: minPriceChecker.code,
-                            arguments: [{ name: 'minPrice', value: '200000' }],
-                        },
-                        handler: {
-                            code: dummyPaymentHandler.code,
-                            arguments: [{ name: 'automaticSettle', value: 'true' }],
-                        },
+            await adminClient.query<
+                Codegen.CreatePaymentMethodMutation,
+                Codegen.CreatePaymentMethodMutationVariables
+            >(CREATE_PAYMENT_METHOD, {
+                input: {
+                    code: 'price-check',
+                    name: 'With Min Price Checker',
+                    description: 'Order total must be more than 2k',
+                    enabled: true,
+                    checker: {
+                        code: minPriceChecker.code,
+                        arguments: [{ name: 'minPrice', value: '200000' }],
+                    },
+                    handler: {
+                        code: dummyPaymentHandler.code,
+                        arguments: [{ name: 'automaticSettle', value: 'true' }],
                     },
                 },
-            );
-            await adminClient.query<CreatePaymentMethod.Mutation, CreatePaymentMethod.Variables>(
-                CREATE_PAYMENT_METHOD,
-                {
-                    input: {
-                        code: 'disabled-method',
-                        name: 'Disabled ones',
-                        description: 'This method is disabled',
-                        enabled: false,
-                        handler: {
-                            code: dummyPaymentHandler.code,
-                            arguments: [{ name: 'automaticSettle', value: 'true' }],
-                        },
+            });
+            await adminClient.query<
+                Codegen.CreatePaymentMethodMutation,
+                Codegen.CreatePaymentMethodMutationVariables
+            >(CREATE_PAYMENT_METHOD, {
+                input: {
+                    code: 'disabled-method',
+                    name: 'Disabled ones',
+                    description: 'This method is disabled',
+                    enabled: false,
+                    handler: {
+                        code: dummyPaymentHandler.code,
+                        arguments: [{ name: 'automaticSettle', value: 'true' }],
                     },
                 },
-            );
+            });
 
             await shopClient.asUserWithCredentials('hayden.zieme12@hotmail.com', 'test');
-            await shopClient.query<AddItemToOrder.Mutation, AddItemToOrder.Variables>(ADD_ITEM_TO_ORDER, {
+            await shopClient.query<
+                CodegenShop.AddItemToOrderMutation,
+                CodegenShop.AddItemToOrderMutationVariables
+            >(ADD_ITEM_TO_ORDER, {
                 productVariantId: 'T_1',
                 quantity: 1,
             });
@@ -254,9 +242,10 @@ describe('PaymentMethod resolver', () => {
         });
 
         it('eligiblePaymentMethods', async () => {
-            const { eligiblePaymentMethods } = await shopClient.query<GetEligiblePaymentMethods.Query>(
-                GET_ELIGIBLE_PAYMENT_METHODS,
-            );
+            const { eligiblePaymentMethods } =
+                await shopClient.query<CodegenShop.GetEligiblePaymentMethodsQuery>(
+                    GET_ELIGIBLE_PAYMENT_METHODS,
+                );
             expect(eligiblePaymentMethods).toEqual([
                 {
                     id: 'T_1',
@@ -276,8 +265,8 @@ describe('PaymentMethod resolver', () => {
         it('addPaymentToOrder does not allow ineligible method', async () => {
             checkerSpy.mockClear();
             const { addPaymentToOrder } = await shopClient.query<
-                AddPaymentToOrder.Mutation,
-                AddPaymentToOrder.Variables
+                CodegenShop.AddPaymentToOrderMutation,
+                CodegenShop.AddPaymentToOrderMutationVariables
             >(ADD_PAYMENT, {
                 input: {
                     method: 'price-check',
@@ -298,35 +287,41 @@ describe('PaymentMethod resolver', () => {
         const THIRD_CHANNEL_TOKEN = 'THIRD_CHANNEL_TOKEN';
 
         beforeAll(async () => {
-            await adminClient.query<CreateChannel.Mutation, CreateChannel.Variables>(CREATE_CHANNEL, {
-                input: {
-                    code: 'second-channel',
-                    token: SECOND_CHANNEL_TOKEN,
-                    defaultLanguageCode: LanguageCode.en,
-                    currencyCode: CurrencyCode.GBP,
-                    pricesIncludeTax: true,
-                    defaultShippingZoneId: 'T_1',
-                    defaultTaxZoneId: 'T_1',
+            await adminClient.query<Codegen.CreateChannelMutation, Codegen.CreateChannelMutationVariables>(
+                CREATE_CHANNEL,
+                {
+                    input: {
+                        code: 'second-channel',
+                        token: SECOND_CHANNEL_TOKEN,
+                        defaultLanguageCode: LanguageCode.en,
+                        currencyCode: CurrencyCode.GBP,
+                        pricesIncludeTax: true,
+                        defaultShippingZoneId: 'T_1',
+                        defaultTaxZoneId: 'T_1',
+                    },
                 },
-            });
-            await adminClient.query<CreateChannel.Mutation, CreateChannel.Variables>(CREATE_CHANNEL, {
-                input: {
-                    code: 'third-channel',
-                    token: THIRD_CHANNEL_TOKEN,
-                    defaultLanguageCode: LanguageCode.en,
-                    currencyCode: CurrencyCode.GBP,
-                    pricesIncludeTax: true,
-                    defaultShippingZoneId: 'T_1',
-                    defaultTaxZoneId: 'T_1',
+            );
+            await adminClient.query<Codegen.CreateChannelMutation, Codegen.CreateChannelMutationVariables>(
+                CREATE_CHANNEL,
+                {
+                    input: {
+                        code: 'third-channel',
+                        token: THIRD_CHANNEL_TOKEN,
+                        defaultLanguageCode: LanguageCode.en,
+                        currencyCode: CurrencyCode.GBP,
+                        pricesIncludeTax: true,
+                        defaultShippingZoneId: 'T_1',
+                        defaultTaxZoneId: 'T_1',
+                    },
                 },
-            });
+            );
         });
 
         it('creates a PaymentMethod in channel2', async () => {
             adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
             const { createPaymentMethod } = await adminClient.query<
-                CreatePaymentMethod.Mutation,
-                CreatePaymentMethod.Variables
+                Codegen.CreatePaymentMethodMutation,
+                Codegen.CreatePaymentMethodMutationVariables
             >(CREATE_PAYMENT_METHOD, {
                 input: {
                     code: 'channel-2-method',
@@ -345,7 +340,7 @@ describe('PaymentMethod resolver', () => {
 
         it('method is listed in channel2', async () => {
             adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
-            const { paymentMethods } = await adminClient.query<GetPaymentMethodList.Query>(
+            const { paymentMethods } = await adminClient.query<Codegen.GetPaymentMethodListQuery>(
                 GET_PAYMENT_METHOD_LIST,
             );
 
@@ -355,7 +350,7 @@ describe('PaymentMethod resolver', () => {
 
         it('method is not listed in channel3', async () => {
             adminClient.setChannelToken(THIRD_CHANNEL_TOKEN);
-            const { paymentMethods } = await adminClient.query<GetPaymentMethodList.Query>(
+            const { paymentMethods } = await adminClient.query<Codegen.GetPaymentMethodListQuery>(
                 GET_PAYMENT_METHOD_LIST,
             );
 
@@ -364,7 +359,7 @@ describe('PaymentMethod resolver', () => {
 
         it('method is listed in default channel', async () => {
             adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
-            const { paymentMethods } = await adminClient.query<GetPaymentMethodList.Query>(
+            const { paymentMethods } = await adminClient.query<Codegen.GetPaymentMethodListQuery>(
                 GET_PAYMENT_METHOD_LIST,
             );
 
@@ -379,38 +374,36 @@ describe('PaymentMethod resolver', () => {
 
         it('delete from channel', async () => {
             adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
-            const { paymentMethods } = await adminClient.query<GetPaymentMethodList.Query>(
+            const { paymentMethods } = await adminClient.query<Codegen.GetPaymentMethodListQuery>(
                 GET_PAYMENT_METHOD_LIST,
             );
 
             expect(paymentMethods.totalItems).toBe(1);
 
             const { deletePaymentMethod } = await adminClient.query<
-                DeletePaymentMethod.Mutation,
-                DeletePaymentMethod.Variables
+                Codegen.DeletePaymentMethodMutation,
+                Codegen.DeletePaymentMethodMutationVariables
             >(DELETE_PAYMENT_METHOD, {
                 id: paymentMethods.items[0].id,
             });
 
             expect(deletePaymentMethod.result).toBe(DeletionResult.DELETED);
 
-            const { paymentMethods: checkChannel } = await adminClient.query<GetPaymentMethodList.Query>(
-                GET_PAYMENT_METHOD_LIST,
-            );
+            const { paymentMethods: checkChannel } =
+                await adminClient.query<Codegen.GetPaymentMethodListQuery>(GET_PAYMENT_METHOD_LIST);
             expect(checkChannel.totalItems).toBe(0);
 
             adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
-            const { paymentMethods: checkDefault } = await adminClient.query<GetPaymentMethodList.Query>(
-                GET_PAYMENT_METHOD_LIST,
-            );
+            const { paymentMethods: checkDefault } =
+                await adminClient.query<Codegen.GetPaymentMethodListQuery>(GET_PAYMENT_METHOD_LIST);
             expect(checkDefault.totalItems).toBe(4);
         });
 
         it('delete from default channel', async () => {
             adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
             const { createPaymentMethod } = await adminClient.query<
-                CreatePaymentMethod.Mutation,
-                CreatePaymentMethod.Variables
+                Codegen.CreatePaymentMethodMutation,
+                Codegen.CreatePaymentMethodMutationVariables
             >(CREATE_PAYMENT_METHOD, {
                 input: {
                     code: 'channel-2-method2',
@@ -426,8 +419,8 @@ describe('PaymentMethod resolver', () => {
 
             adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
             const { deletePaymentMethod: delete1 } = await adminClient.query<
-                DeletePaymentMethod.Mutation,
-                DeletePaymentMethod.Variables
+                Codegen.DeletePaymentMethodMutation,
+                Codegen.DeletePaymentMethodMutationVariables
             >(DELETE_PAYMENT_METHOD, {
                 id: createPaymentMethod.id,
             });
@@ -437,14 +430,14 @@ describe('PaymentMethod resolver', () => {
                 'The selected PaymentMethod is assigned to the following Channels: second-channel. Set "force: true" to delete from all Channels.',
             );
 
-            const { paymentMethods: check1 } = await adminClient.query<GetPaymentMethodList.Query>(
+            const { paymentMethods: check1 } = await adminClient.query<Codegen.GetPaymentMethodListQuery>(
                 GET_PAYMENT_METHOD_LIST,
             );
             expect(check1.totalItems).toBe(5);
 
             const { deletePaymentMethod: delete2 } = await adminClient.query<
-                DeletePaymentMethod.Mutation,
-                DeletePaymentMethod.Variables
+                Codegen.DeletePaymentMethodMutation,
+                Codegen.DeletePaymentMethodMutationVariables
             >(DELETE_PAYMENT_METHOD, {
                 id: createPaymentMethod.id,
                 force: true,
@@ -452,7 +445,7 @@ describe('PaymentMethod resolver', () => {
 
             expect(delete2.result).toBe(DeletionResult.DELETED);
 
-            const { paymentMethods: check2 } = await adminClient.query<GetPaymentMethodList.Query>(
+            const { paymentMethods: check2 } = await adminClient.query<Codegen.GetPaymentMethodListQuery>(
                 GET_PAYMENT_METHOD_LIST,
             );
             expect(check2.totalItems).toBe(4);

+ 79 - 66
packages/core/e2e/payment-process.e2e-spec.ts

@@ -20,21 +20,9 @@ import { initialData } from '../../../e2e-common/e2e-initial-data';
 import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
 
 import { ORDER_WITH_LINES_FRAGMENT, PAYMENT_FRAGMENT } from './graphql/fragments';
-import {
-    AddManualPayment2,
-    AdminTransition,
-    ErrorCode,
-    GetOrder,
-    OrderFragment,
-    PaymentFragment,
-    TransitionPaymentToState,
-} from './graphql/generated-e2e-admin-types';
-import {
-    AddItemToOrder,
-    AddPaymentToOrder,
-    GetActiveOrder,
-    TestOrderFragmentFragment,
-} from './graphql/generated-e2e-shop-types';
+import * as Codegen from './graphql/generated-e2e-admin-types';
+import { ErrorCode } from './graphql/generated-e2e-admin-types';
+import * as CodegenShop from './graphql/generated-e2e-shop-types';
 import { ADMIN_TRANSITION_TO_STATE, GET_ORDER } from './graphql/shared-definitions';
 import { ADD_ITEM_TO_ORDER, ADD_PAYMENT, GET_ACTIVE_ORDER } from './graphql/shop-definitions';
 import { proceedToArrangingPayment } from './utils/test-order-utils';
@@ -121,11 +109,12 @@ describe('Payment process', () => {
         }
     }
 
-    const orderGuard: ErrorResultGuard<TestOrderFragmentFragment | OrderFragment> = createErrorResultGuard(
-        input => !!input.total,
-    );
+    const orderGuard: ErrorResultGuard<CodegenShop.TestOrderFragmentFragment | Codegen.OrderFragment> =
+        createErrorResultGuard(input => !!input.total);
 
-    const paymentGuard: ErrorResultGuard<PaymentFragment> = createErrorResultGuard(input => !!input.id);
+    const paymentGuard: ErrorResultGuard<Codegen.PaymentFragment> = createErrorResultGuard(
+        input => !!input.id,
+    );
 
     const { server, adminClient, shopClient } = createTestEnvironment(
         mergeConfig(testConfig(), {
@@ -158,7 +147,10 @@ describe('Payment process', () => {
         await adminClient.asSuperAdmin();
 
         await shopClient.asUserWithCredentials('hayden.zieme12@hotmail.com', 'test');
-        await shopClient.query<AddItemToOrder.Mutation, AddItemToOrder.Variables>(ADD_ITEM_TO_ORDER, {
+        await shopClient.query<
+            CodegenShop.AddItemToOrderMutation,
+            CodegenShop.AddItemToOrderMutationVariables
+        >(ADD_ITEM_TO_ORDER, {
             productVariantId: 'T_1',
             quantity: 1,
         });
@@ -176,8 +168,8 @@ describe('Payment process', () => {
 
     it('creates Payment in custom state', async () => {
         const { addPaymentToOrder } = await shopClient.query<
-            AddPaymentToOrder.Mutation,
-            AddPaymentToOrder.Variables
+            CodegenShop.AddPaymentToOrderMutation,
+            CodegenShop.AddPaymentToOrderMutationVariables
         >(ADD_PAYMENT, {
             input: {
                 method: testPaymentHandler.code,
@@ -189,9 +181,12 @@ describe('Payment process', () => {
 
         orderGuard.assertSuccess(addPaymentToOrder);
 
-        const { order } = await adminClient.query<GetOrder.Query, GetOrder.Variables>(GET_ORDER, {
-            id: orderId,
-        });
+        const { order } = await adminClient.query<Codegen.GetOrderQuery, Codegen.GetOrderQueryVariables>(
+            GET_ORDER,
+            {
+                id: orderId,
+            },
+        );
 
         expect(order?.state).toBe('ArrangingPayment');
         expect(order?.payments?.length).toBe(1);
@@ -206,21 +201,24 @@ describe('Payment process', () => {
     });
 
     it('Payment next states', async () => {
-        const { order } = await adminClient.query<GetOrder.Query, GetOrder.Variables>(GET_ORDER, {
-            id: orderId,
-        });
+        const { order } = await adminClient.query<Codegen.GetOrderQuery, Codegen.GetOrderQueryVariables>(
+            GET_ORDER,
+            {
+                id: orderId,
+            },
+        );
         expect(order?.payments?.[0].nextStates).toEqual(['Settled', 'Declined', 'Cancelled']);
     });
 
     it('transition Order to custom state, custom OrderPlacedStrategy sets as placed', async () => {
-        const { activeOrder: activeOrderPre } = await shopClient.query<GetActiveOrder.Query>(
+        const { activeOrder: activeOrderPre } = await shopClient.query<CodegenShop.GetActiveOrderQuery>(
             GET_ACTIVE_ORDER,
         );
         expect(activeOrderPre).not.toBeNull();
 
         const { transitionOrderToState } = await adminClient.query<
-            AdminTransition.Mutation,
-            AdminTransition.Variables
+            Codegen.AdminTransitionMutation,
+            Codegen.AdminTransitionMutationVariables
         >(ADMIN_TRANSITION_TO_STATE, {
             id: orderId,
             state: 'ValidatingPayment',
@@ -231,7 +229,7 @@ describe('Payment process', () => {
         expect(transitionOrderToState.state).toBe('ValidatingPayment');
         expect(transitionOrderToState?.active).toBe(false);
 
-        const { activeOrder: activeOrderPost } = await shopClient.query<GetActiveOrder.Query>(
+        const { activeOrder: activeOrderPost } = await shopClient.query<CodegenShop.GetActiveOrderQuery>(
             GET_ACTIVE_ORDER,
         );
         expect(activeOrderPost).toBeNull();
@@ -239,8 +237,8 @@ describe('Payment process', () => {
 
     it('transitionPaymentToState succeeds', async () => {
         const { transitionPaymentToState } = await adminClient.query<
-            TransitionPaymentToState.Mutation,
-            TransitionPaymentToState.Variables
+            Codegen.TransitionPaymentToStateMutation,
+            Codegen.TransitionPaymentToStateMutationVariables
         >(TRANSITION_PAYMENT_TO_STATE, {
             id: payment1Id,
             state: 'Settled',
@@ -249,9 +247,12 @@ describe('Payment process', () => {
         paymentGuard.assertSuccess(transitionPaymentToState);
         expect(transitionPaymentToState.state).toBe('Settled');
 
-        const { order } = await adminClient.query<GetOrder.Query, GetOrder.Variables>(GET_ORDER, {
-            id: orderId,
-        });
+        const { order } = await adminClient.query<Codegen.GetOrderQuery, Codegen.GetOrderQueryVariables>(
+            GET_ORDER,
+            {
+                id: orderId,
+            },
+        );
         expect(order?.state).toBe('PaymentSettled');
         expect(settlePaymentSpy).toHaveBeenCalled();
     });
@@ -262,14 +263,17 @@ describe('Payment process', () => {
 
         beforeAll(async () => {
             await shopClient.asUserWithCredentials('hayden.zieme12@hotmail.com', 'test');
-            await shopClient.query<AddItemToOrder.Mutation, AddItemToOrder.Variables>(ADD_ITEM_TO_ORDER, {
+            await shopClient.query<
+                CodegenShop.AddItemToOrderMutation,
+                CodegenShop.AddItemToOrderMutationVariables
+            >(ADD_ITEM_TO_ORDER, {
                 productVariantId: 'T_1',
                 quantity: 1,
             });
             order2Id = (await proceedToArrangingPayment(shopClient)) as string;
             const { addPaymentToOrder } = await shopClient.query<
-                AddPaymentToOrder.Mutation,
-                AddPaymentToOrder.Variables
+                CodegenShop.AddPaymentToOrderMutation,
+                CodegenShop.AddPaymentToOrderMutationVariables
             >(ADD_PAYMENT, {
                 input: {
                     method: testPaymentHandler.code,
@@ -282,19 +286,19 @@ describe('Payment process', () => {
             orderGuard.assertSuccess(addPaymentToOrder);
             payment2Id = addPaymentToOrder!.payments![0].id;
 
-            await adminClient.query<AdminTransition.Mutation, AdminTransition.Variables>(
-                ADMIN_TRANSITION_TO_STATE,
-                {
-                    id: order2Id,
-                    state: 'ValidatingPayment',
-                },
-            );
+            await adminClient.query<
+                Codegen.AdminTransitionMutation,
+                Codegen.AdminTransitionMutationVariables
+            >(ADMIN_TRANSITION_TO_STATE, {
+                id: order2Id,
+                state: 'ValidatingPayment',
+            });
         });
 
         it('attempting to transition payment to settled fails', async () => {
             const { transitionPaymentToState } = await adminClient.query<
-                TransitionPaymentToState.Mutation,
-                TransitionPaymentToState.Variables
+                Codegen.TransitionPaymentToStateMutation,
+                Codegen.TransitionPaymentToStateMutationVariables
             >(TRANSITION_PAYMENT_TO_STATE, {
                 id: payment2Id,
                 state: 'Settled',
@@ -304,16 +308,19 @@ describe('Payment process', () => {
             expect(transitionPaymentToState.errorCode).toBe(ErrorCode.PAYMENT_STATE_TRANSITION_ERROR);
             expect((transitionPaymentToState as any).transitionError).toBe(PAYMENT_ERROR_MESSAGE);
 
-            const { order } = await adminClient.query<GetOrder.Query, GetOrder.Variables>(GET_ORDER, {
-                id: order2Id,
-            });
+            const { order } = await adminClient.query<Codegen.GetOrderQuery, Codegen.GetOrderQueryVariables>(
+                GET_ORDER,
+                {
+                    id: order2Id,
+                },
+            );
             expect(order?.state).toBe('ValidatingPayment');
         });
 
         it('cancel failed payment', async () => {
             const { transitionPaymentToState } = await adminClient.query<
-                TransitionPaymentToState.Mutation,
-                TransitionPaymentToState.Variables
+                Codegen.TransitionPaymentToStateMutation,
+                Codegen.TransitionPaymentToStateMutationVariables
             >(TRANSITION_PAYMENT_TO_STATE, {
                 id: payment2Id,
                 state: 'Cancelled',
@@ -322,16 +329,19 @@ describe('Payment process', () => {
             paymentGuard.assertSuccess(transitionPaymentToState);
             expect(transitionPaymentToState.state).toBe('Cancelled');
 
-            const { order } = await adminClient.query<GetOrder.Query, GetOrder.Variables>(GET_ORDER, {
-                id: order2Id,
-            });
+            const { order } = await adminClient.query<Codegen.GetOrderQuery, Codegen.GetOrderQueryVariables>(
+                GET_ORDER,
+                {
+                    id: order2Id,
+                },
+            );
             expect(order?.state).toBe('ValidatingPayment');
         });
 
         it('manually adds payment', async () => {
             const { transitionOrderToState } = await adminClient.query<
-                AdminTransition.Mutation,
-                AdminTransition.Variables
+                Codegen.AdminTransitionMutation,
+                Codegen.AdminTransitionMutationVariables
             >(ADMIN_TRANSITION_TO_STATE, {
                 id: order2Id,
                 state: 'ArrangingAdditionalPayment',
@@ -340,8 +350,8 @@ describe('Payment process', () => {
             orderGuard.assertSuccess(transitionOrderToState);
 
             const { addManualPaymentToOrder } = await adminClient.query<
-                AddManualPayment2.Mutation,
-                AddManualPayment2.Variables
+                Codegen.AddManualPayment2Mutation,
+                Codegen.AddManualPayment2MutationVariables
             >(ADD_MANUAL_PAYMENT, {
                 input: {
                     orderId: order2Id,
@@ -359,8 +369,8 @@ describe('Payment process', () => {
 
         it('transitions Order to PaymentSettled', async () => {
             const { transitionOrderToState } = await adminClient.query<
-                AdminTransition.Mutation,
-                AdminTransition.Variables
+                Codegen.AdminTransitionMutation,
+                Codegen.AdminTransitionMutationVariables
             >(ADMIN_TRANSITION_TO_STATE, {
                 id: order2Id,
                 state: 'PaymentSettled',
@@ -369,9 +379,12 @@ describe('Payment process', () => {
             orderGuard.assertSuccess(transitionOrderToState);
             expect(transitionOrderToState.state).toBe('PaymentSettled');
 
-            const { order } = await adminClient.query<GetOrder.Query, GetOrder.Variables>(GET_ORDER, {
-                id: order2Id,
-            });
+            const { order } = await adminClient.query<Codegen.GetOrderQuery, Codegen.GetOrderQueryVariables>(
+                GET_ORDER,
+                {
+                    id: order2Id,
+                },
+            );
             const settledPaymentAmount = order?.payments
                 ?.filter(p => p.state === 'Settled')
                 .reduce((sum, p) => sum + p.amount, 0);

+ 108 - 99
packages/core/e2e/product-channel.e2e-spec.ts

@@ -53,61 +53,67 @@ describe('ChannelAware Products and ProductVariants', () => {
         });
         await adminClient.asSuperAdmin();
 
-        await adminClient.query<CreateChannel.Mutation, CreateChannel.Variables>(CREATE_CHANNEL, {
-            input: {
-                code: 'second-channel',
-                token: SECOND_CHANNEL_TOKEN,
-                defaultLanguageCode: LanguageCode.en,
-                currencyCode: CurrencyCode.USD,
-                pricesIncludeTax: true,
-                defaultShippingZoneId: 'T_1',
-                defaultTaxZoneId: 'T_1',
-            },
-        });
-
-        await adminClient.query<CreateChannel.Mutation, CreateChannel.Variables>(CREATE_CHANNEL, {
-            input: {
-                code: 'third-channel',
-                token: THIRD_CHANNEL_TOKEN,
-                defaultLanguageCode: LanguageCode.en,
-                currencyCode: CurrencyCode.USD,
-                pricesIncludeTax: true,
-                defaultShippingZoneId: 'T_1',
-                defaultTaxZoneId: 'T_1',
-            },
-        });
-
-        const { createRole } = await adminClient.query<CreateRole.Mutation, CreateRole.Variables>(
-            CREATE_ROLE,
+        await adminClient.query<Codegen.CreateChannelMutation, Codegen.CreateChannelMutationVariables>(
+            CREATE_CHANNEL,
             {
                 input: {
-                    description: 'second channel admin',
-                    code: 'second-channel-admin',
-                    channelIds: ['T_2'],
-                    permissions: [
-                        Permission.ReadCatalog,
-                        Permission.ReadSettings,
-                        Permission.ReadAdministrator,
-                        Permission.CreateAdministrator,
-                        Permission.UpdateAdministrator,
-                    ],
+                    code: 'second-channel',
+                    token: SECOND_CHANNEL_TOKEN,
+                    defaultLanguageCode: LanguageCode.en,
+                    currencyCode: CurrencyCode.USD,
+                    pricesIncludeTax: true,
+                    defaultShippingZoneId: 'T_1',
+                    defaultTaxZoneId: 'T_1',
                 },
             },
         );
-        secondChannelAdminRole = createRole;
 
-        await adminClient.query<CreateAdministrator.Mutation, CreateAdministrator.Variables>(
-            CREATE_ADMINISTRATOR,
+        await adminClient.query<Codegen.CreateChannelMutation, Codegen.CreateChannelMutationVariables>(
+            CREATE_CHANNEL,
             {
                 input: {
-                    firstName: 'Admin',
-                    lastName: 'Two',
-                    emailAddress: 'admin2@test.com',
-                    password: 'test',
-                    roleIds: [secondChannelAdminRole.id],
+                    code: 'third-channel',
+                    token: THIRD_CHANNEL_TOKEN,
+                    defaultLanguageCode: LanguageCode.en,
+                    currencyCode: CurrencyCode.USD,
+                    pricesIncludeTax: true,
+                    defaultShippingZoneId: 'T_1',
+                    defaultTaxZoneId: 'T_1',
                 },
             },
         );
+
+        const { createRole } = await adminClient.query<
+            Codegen.CreateRoleMutation,
+            Codegen.CreateRoleMutationVariables
+        >(CREATE_ROLE, {
+            input: {
+                description: 'second channel admin',
+                code: 'second-channel-admin',
+                channelIds: ['T_2'],
+                permissions: [
+                    Permission.ReadCatalog,
+                    Permission.ReadSettings,
+                    Permission.ReadAdministrator,
+                    Permission.CreateAdministrator,
+                    Permission.UpdateAdministrator,
+                ],
+            },
+        });
+        secondChannelAdminRole = createRole;
+
+        await adminClient.query<
+            Codegen.CreateAdministratorMutation,
+            Codegen.CreateAdministratorMutationVariables
+        >(CREATE_ADMINISTRATOR, {
+            input: {
+                firstName: 'Admin',
+                lastName: 'Two',
+                emailAddress: 'admin2@test.com',
+                password: 'test',
+                roleIds: [secondChannelAdminRole.id],
+            },
+        });
     }, TEST_SETUP_TIMEOUT_MS);
 
     afterAll(async () => {
@@ -122,8 +128,8 @@ describe('ChannelAware Products and ProductVariants', () => {
             await adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
 
             const { product } = await adminClient.query<
-                GetProductWithVariants.Query,
-                GetProductWithVariants.Variables
+                Codegen.GetProductWithVariantsQuery,
+                Codegen.GetProductWithVariantsQueryVariables
             >(GET_PRODUCT_WITH_VARIANTS, {
                 id: 'T_1',
             });
@@ -134,15 +140,15 @@ describe('ChannelAware Products and ProductVariants', () => {
             'throws if attempting to assign Product to channel to which the admin has no access',
             assertThrowsWithMessage(async () => {
                 await adminClient.asUserWithCredentials('admin2@test.com', 'test');
-                await adminClient.query<AssignProductsToChannel.Mutation, AssignProductsToChannel.Variables>(
-                    ASSIGN_PRODUCT_TO_CHANNEL,
-                    {
-                        input: {
-                            channelId: 'T_3',
-                            productIds: [product1.id],
-                        },
+                await adminClient.query<
+                    Codegen.AssignProductsToChannelMutation,
+                    Codegen.AssignProductsToChannelMutationVariables
+                >(ASSIGN_PRODUCT_TO_CHANNEL, {
+                    input: {
+                        channelId: 'T_3',
+                        productIds: [product1.id],
                     },
-                );
+                });
             }, 'You are not currently authorized to perform this action'),
         );
 
@@ -151,8 +157,8 @@ describe('ChannelAware Products and ProductVariants', () => {
             const PRICE_FACTOR = 0.5;
             await adminClient.asSuperAdmin();
             const { assignProductsToChannel } = await adminClient.query<
-                AssignProductsToChannel.Mutation,
-                AssignProductsToChannel.Variables
+                Codegen.AssignProductsToChannelMutation,
+                Codegen.AssignProductsToChannelMutationVariables
             >(ASSIGN_PRODUCT_TO_CHANNEL, {
                 input: {
                     channelId: 'T_2',
@@ -164,8 +170,8 @@ describe('ChannelAware Products and ProductVariants', () => {
             expect(assignProductsToChannel[0].channels.map(c => c.id).sort()).toEqual(['T_1', 'T_2']);
             await adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
             const { product } = await adminClient.query<
-                GetProductWithVariants.Query,
-                GetProductWithVariants.Variables
+                Codegen.GetProductWithVariantsQuery,
+                Codegen.GetProductWithVariantsQueryVariables
             >(GET_PRODUCT_WITH_VARIANTS, {
                 id: product1.id,
             });
@@ -182,8 +188,8 @@ describe('ChannelAware Products and ProductVariants', () => {
         it('ProductVariant.channels includes all Channels from default Channel', async () => {
             adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
             const { product } = await adminClient.query<
-                GetProductWithVariants.Query,
-                GetProductWithVariants.Variables
+                Codegen.GetProductWithVariantsQuery,
+                Codegen.GetProductWithVariantsQueryVariables
             >(GET_PRODUCT_WITH_VARIANTS, {
                 id: product1.id,
             });
@@ -194,8 +200,8 @@ describe('ChannelAware Products and ProductVariants', () => {
         it('ProductVariant.channels includes only current Channel from non-default Channel', async () => {
             adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
             const { product } = await adminClient.query<
-                GetProductWithVariants.Query,
-                GetProductWithVariants.Variables
+                Codegen.GetProductWithVariantsQuery,
+                Codegen.GetProductWithVariantsQueryVariables
             >(GET_PRODUCT_WITH_VARIANTS, {
                 id: product1.id,
             });
@@ -206,8 +212,8 @@ describe('ChannelAware Products and ProductVariants', () => {
         it('does not assign Product to same channel twice', async () => {
             adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
             const { assignProductsToChannel } = await adminClient.query<
-                AssignProductsToChannel.Mutation,
-                AssignProductsToChannel.Variables
+                Codegen.AssignProductsToChannelMutation,
+                Codegen.AssignProductsToChannelMutationVariables
             >(ASSIGN_PRODUCT_TO_CHANNEL, {
                 input: {
                     channelId: 'T_2',
@@ -222,8 +228,8 @@ describe('ChannelAware Products and ProductVariants', () => {
             'throws if attempting to remove Product from default Channel',
             assertThrowsWithMessage(async () => {
                 await adminClient.query<
-                    RemoveProductsFromChannel.Mutation,
-                    RemoveProductsFromChannel.Variables
+                    Codegen.RemoveProductsFromChannelMutation,
+                    Codegen.RemoveProductsFromChannelMutationVariables
                 >(REMOVE_PRODUCT_FROM_CHANNEL, {
                     input: {
                         productIds: [product1.id],
@@ -237,8 +243,8 @@ describe('ChannelAware Products and ProductVariants', () => {
             await adminClient.asSuperAdmin();
             await adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
             const { removeProductsFromChannel } = await adminClient.query<
-                RemoveProductsFromChannel.Mutation,
-                RemoveProductsFromChannel.Variables
+                Codegen.RemoveProductsFromChannelMutation,
+                Codegen.RemoveProductsFromChannelMutationVariables
             >(REMOVE_PRODUCT_FROM_CHANNEL, {
                 input: {
                     productIds: [product1.id],
@@ -258,8 +264,8 @@ describe('ChannelAware Products and ProductVariants', () => {
             await adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
 
             const { product } = await adminClient.query<
-                GetProductWithVariants.Query,
-                GetProductWithVariants.Variables
+                Codegen.GetProductWithVariantsQuery,
+                Codegen.GetProductWithVariantsQueryVariables
             >(GET_PRODUCT_WITH_VARIANTS, {
                 id: 'T_2',
             });
@@ -271,8 +277,8 @@ describe('ChannelAware Products and ProductVariants', () => {
             assertThrowsWithMessage(async () => {
                 await adminClient.asUserWithCredentials('admin2@test.com', 'test');
                 await adminClient.query<
-                    AssignProductVariantsToChannel.Mutation,
-                    AssignProductVariantsToChannel.Variables
+                    Codegen.AssignProductVariantsToChannelMutation,
+                    Codegen.AssignProductVariantsToChannelMutationVariables
                 >(ASSIGN_PRODUCTVARIANT_TO_CHANNEL, {
                     input: {
                         channelId: 'T_3',
@@ -287,8 +293,8 @@ describe('ChannelAware Products and ProductVariants', () => {
             await adminClient.asSuperAdmin();
             await adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
             const { assignProductVariantsToChannel } = await adminClient.query<
-                AssignProductVariantsToChannel.Mutation,
-                AssignProductVariantsToChannel.Variables
+                Codegen.AssignProductVariantsToChannelMutation,
+                Codegen.AssignProductVariantsToChannelMutationVariables
             >(ASSIGN_PRODUCTVARIANT_TO_CHANNEL, {
                 input: {
                     channelId: 'T_3',
@@ -300,8 +306,8 @@ describe('ChannelAware Products and ProductVariants', () => {
             expect(assignProductVariantsToChannel[0].channels.map(c => c.id).sort()).toEqual(['T_1', 'T_3']);
             await adminClient.setChannelToken(THIRD_CHANNEL_TOKEN);
             const { product } = await adminClient.query<
-                GetProductWithVariants.Query,
-                GetProductWithVariants.Variables
+                Codegen.GetProductWithVariantsQuery,
+                Codegen.GetProductWithVariantsQueryVariables
             >(GET_PRODUCT_WITH_VARIANTS, {
                 id: product1.id,
             });
@@ -316,8 +322,8 @@ describe('ChannelAware Products and ProductVariants', () => {
 
             await adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
             const { product: check } = await adminClient.query<
-                GetProductWithVariants.Query,
-                GetProductWithVariants.Variables
+                Codegen.GetProductWithVariantsQuery,
+                Codegen.GetProductWithVariantsQueryVariables
             >(GET_PRODUCT_WITH_VARIANTS, {
                 id: product1.id,
             });
@@ -332,8 +338,8 @@ describe('ChannelAware Products and ProductVariants', () => {
             await adminClient.asSuperAdmin();
             await adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
             const { assignProductVariantsToChannel } = await adminClient.query<
-                AssignProductVariantsToChannel.Mutation,
-                AssignProductVariantsToChannel.Variables
+                Codegen.AssignProductVariantsToChannelMutation,
+                Codegen.AssignProductVariantsToChannelMutationVariables
             >(ASSIGN_PRODUCTVARIANT_TO_CHANNEL, {
                 input: {
                     channelId: 'T_3',
@@ -347,8 +353,8 @@ describe('ChannelAware Products and ProductVariants', () => {
             'throws if attempting to remove ProductVariant from default Channel',
             assertThrowsWithMessage(async () => {
                 await adminClient.query<
-                    RemoveProductVariantsFromChannel.Mutation,
-                    RemoveProductVariantsFromChannel.Variables
+                    Codegen.RemoveProductVariantsFromChannelMutation,
+                    Codegen.RemoveProductVariantsFromChannelMutationVariables
                 >(REMOVE_PRODUCTVARIANT_FROM_CHANNEL, {
                     input: {
                         productVariantIds: [product1.variants[0].id],
@@ -362,8 +368,8 @@ describe('ChannelAware Products and ProductVariants', () => {
             await adminClient.asSuperAdmin();
             await adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
             const { assignProductVariantsToChannel } = await adminClient.query<
-                AssignProductVariantsToChannel.Mutation,
-                AssignProductVariantsToChannel.Variables
+                Codegen.AssignProductVariantsToChannelMutation,
+                Codegen.AssignProductVariantsToChannelMutationVariables
             >(ASSIGN_PRODUCTVARIANT_TO_CHANNEL, {
                 input: {
                     channelId: 'T_3',
@@ -373,8 +379,8 @@ describe('ChannelAware Products and ProductVariants', () => {
             expect(assignProductVariantsToChannel[0].channels.map(c => c.id).sort()).toEqual(['T_1', 'T_3']);
 
             const { removeProductVariantsFromChannel } = await adminClient.query<
-                RemoveProductVariantsFromChannel.Mutation,
-                RemoveProductVariantsFromChannel.Variables
+                Codegen.RemoveProductVariantsFromChannelMutation,
+                Codegen.RemoveProductVariantsFromChannelMutationVariables
             >(REMOVE_PRODUCTVARIANT_FROM_CHANNEL, {
                 input: {
                     productVariantIds: [product1.variants[1].id],
@@ -384,8 +390,8 @@ describe('ChannelAware Products and ProductVariants', () => {
             expect(removeProductVariantsFromChannel[0].channels.map(c => c.id)).toEqual(['T_1']);
 
             const { product } = await adminClient.query<
-                GetProductWithVariants.Query,
-                GetProductWithVariants.Variables
+                Codegen.GetProductWithVariantsQuery,
+                Codegen.GetProductWithVariantsQueryVariables
             >(GET_PRODUCT_WITH_VARIANTS, {
                 id: product1.id,
             });
@@ -396,8 +402,8 @@ describe('ChannelAware Products and ProductVariants', () => {
             await adminClient.asSuperAdmin();
             await adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
             const { removeProductVariantsFromChannel } = await adminClient.query<
-                RemoveProductVariantsFromChannel.Mutation,
-                RemoveProductVariantsFromChannel.Variables
+                Codegen.RemoveProductVariantsFromChannelMutation,
+                Codegen.RemoveProductVariantsFromChannelMutationVariables
             >(REMOVE_PRODUCTVARIANT_FROM_CHANNEL, {
                 input: {
                     productVariantIds: [product1.variants[0].id],
@@ -408,8 +414,8 @@ describe('ChannelAware Products and ProductVariants', () => {
             expect(removeProductVariantsFromChannel[0].channels.map(c => c.id)).toEqual(['T_1']);
 
             const { product } = await adminClient.query<
-                GetProductWithVariants.Query,
-                GetProductWithVariants.Variables
+                Codegen.GetProductWithVariantsQuery,
+                Codegen.GetProductWithVariantsQueryVariables
             >(GET_PRODUCT_WITH_VARIANTS, {
                 id: product1.id,
             });
@@ -425,8 +431,8 @@ describe('ChannelAware Products and ProductVariants', () => {
             adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
 
             const { createProduct } = await adminClient.query<
-                CreateProduct.Mutation,
-                CreateProduct.Variables
+                Codegen.CreateProductMutation,
+                Codegen.CreateProductMutationVariables
             >(CREATE_PRODUCT, {
                 input: {
                     translations: [
@@ -440,8 +446,8 @@ describe('ChannelAware Products and ProductVariants', () => {
                 },
             });
             const { createProductVariants } = await adminClient.query<
-                CreateProductVariants.Mutation,
-                CreateProductVariants.Variables
+                Codegen.CreateProductVariantsMutation,
+                Codegen.CreateProductVariantsMutationVariables
             >(CREATE_PRODUCT_VARIANTS, {
                 input: [
                     {
@@ -463,8 +469,8 @@ describe('ChannelAware Products and ProductVariants', () => {
             adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
 
             const { product } = await adminClient.query<
-                GetProductWithVariants.Query,
-                GetProductWithVariants.Variables
+                Codegen.GetProductWithVariantsQuery,
+                Codegen.GetProductWithVariantsQueryVariables
             >(GET_PRODUCT_WITH_VARIANTS, {
                 id: createProduct.id,
             });
@@ -480,7 +486,10 @@ describe('ChannelAware Products and ProductVariants', () => {
             'throws if attempting to update a Product which is not assigned to that Channel',
             assertThrowsWithMessage(async () => {
                 adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
-                await adminClient.query<UpdateProduct.Mutation, UpdateProduct.Variables>(UPDATE_PRODUCT, {
+                await adminClient.query<
+                    Codegen.UpdateProductMutation,
+                    Codegen.UpdateProductMutationVariables
+                >(UPDATE_PRODUCT, {
                     input: {
                         id: 'T_2',
                         translations: [{ languageCode: LanguageCode.en, name: 'xyz' }],

+ 14 - 20
packages/core/e2e/product-option.e2e-spec.ts

@@ -7,14 +7,8 @@ import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-conf
 import { omit } from '../../common/lib/omit';
 
 import { PRODUCT_OPTION_GROUP_FRAGMENT } from './graphql/fragments';
-import {
-    CreateProductOption,
-    CreateProductOptionGroup,
-    LanguageCode,
-    ProductOptionGroupFragment,
-    UpdateProductOption,
-    UpdateProductOptionGroup,
-} from './graphql/generated-e2e-admin-types';
+import * as Codegen from './graphql/generated-e2e-admin-types';
+import { LanguageCode } from './graphql/generated-e2e-admin-types';
 import { CREATE_PRODUCT_OPTION_GROUP } from './graphql/shared-definitions';
 import { assertThrowsWithMessage } from './utils/assert-throws-with-message';
 
@@ -22,8 +16,8 @@ import { assertThrowsWithMessage } from './utils/assert-throws-with-message';
 
 describe('ProductOption resolver', () => {
     const { server, adminClient } = createTestEnvironment(testConfig());
-    let sizeGroup: ProductOptionGroupFragment;
-    let mediumOption: CreateProductOption.CreateProductOption;
+    let sizeGroup: Codegen.ProductOptionGroupFragment;
+    let mediumOption: Codegen.CreateProductOptionMutation['createProductOption'];
 
     beforeAll(async () => {
         await server.init({
@@ -40,8 +34,8 @@ describe('ProductOption resolver', () => {
 
     it('createProductOptionGroup', async () => {
         const { createProductOptionGroup } = await adminClient.query<
-            CreateProductOptionGroup.Mutation,
-            CreateProductOptionGroup.Variables
+            Codegen.CreateProductOptionGroupMutation,
+            Codegen.CreateProductOptionGroupMutationVariables
         >(CREATE_PRODUCT_OPTION_GROUP, {
             input: {
                 code: 'size',
@@ -78,8 +72,8 @@ describe('ProductOption resolver', () => {
 
     it('updateProductOptionGroup', async () => {
         const { updateProductOptionGroup } = await adminClient.query<
-            UpdateProductOptionGroup.Mutation,
-            UpdateProductOptionGroup.Variables
+            Codegen.UpdateProductOptionGroupMutation,
+            Codegen.UpdateProductOptionGroupMutationVariables
         >(UPDATE_PRODUCT_OPTION_GROUP, {
             input: {
                 id: sizeGroup.id,
@@ -96,8 +90,8 @@ describe('ProductOption resolver', () => {
         'createProductOption throws with invalid productOptionGroupId',
         assertThrowsWithMessage(async () => {
             const { createProductOption } = await adminClient.query<
-                CreateProductOption.Mutation,
-                CreateProductOption.Variables
+                Codegen.CreateProductOptionMutation,
+                Codegen.CreateProductOptionMutationVariables
             >(CREATE_PRODUCT_OPTION, {
                 input: {
                     productOptionGroupId: 'T_999',
@@ -113,8 +107,8 @@ describe('ProductOption resolver', () => {
 
     it('createProductOption', async () => {
         const { createProductOption } = await adminClient.query<
-            CreateProductOption.Mutation,
-            CreateProductOption.Variables
+            Codegen.CreateProductOptionMutation,
+            Codegen.CreateProductOptionMutationVariables
         >(CREATE_PRODUCT_OPTION, {
             input: {
                 productOptionGroupId: sizeGroup.id,
@@ -137,8 +131,8 @@ describe('ProductOption resolver', () => {
 
     it('updateProductOption', async () => {
         const { updateProductOption } = await adminClient.query<
-            UpdateProductOption.Mutation,
-            UpdateProductOption.Variables
+            Codegen.UpdateProductOptionMutation,
+            Codegen.UpdateProductOptionMutationVariables
         >(UPDATE_PRODUCT_OPTION, {
             input: {
                 id: 'T_7',

Plik diff jest za duży
+ 326 - 349
packages/core/e2e/product.e2e-spec.ts


+ 71 - 81
packages/core/e2e/promotion.e2e-spec.ts

@@ -13,24 +13,8 @@ import { initialData } from '../../../e2e-common/e2e-initial-data';
 import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
 
 import { PROMOTION_FRAGMENT } from './graphql/fragments';
-import {
-    AssignPromotionToChannel,
-    ChannelFragment,
-    CreateChannel,
-    CreatePromotion,
-    CurrencyCode,
-    DeletePromotion,
-    DeletionResult,
-    ErrorCode,
-    GetAdjustmentOperations,
-    GetPromotion,
-    GetPromotionList,
-    LanguageCode,
-    Promotion,
-    PromotionFragment,
-    RemovePromotionFromChannel,
-    UpdatePromotion,
-} from './graphql/generated-e2e-admin-types';
+import * as Codegen from './graphql/generated-e2e-admin-types';
+import { CurrencyCode, DeletionResult, ErrorCode, LanguageCode } from './graphql/generated-e2e-admin-types';
 import {
     ASSIGN_PROMOTIONS_TO_CHANNEL,
     CREATE_CHANNEL,
@@ -54,7 +38,7 @@ describe('Promotion resolver', () => {
         },
     });
 
-    const snapshotProps: Array<keyof Promotion.Fragment> = [
+    const snapshotProps: Array<keyof Codegen.PromotionFragment> = [
         'name',
         'actions',
         'conditions',
@@ -63,9 +47,9 @@ describe('Promotion resolver', () => {
         'startsAt',
         'endsAt',
     ];
-    let promotion: Promotion.Fragment;
+    let promotion: Codegen.PromotionFragment;
 
-    const promotionGuard: ErrorResultGuard<PromotionFragment> = createErrorResultGuard(
+    const promotionGuard: ErrorResultGuard<Codegen.PromotionFragment> = createErrorResultGuard(
         input => !!input.couponCode,
     );
 
@@ -84,8 +68,8 @@ describe('Promotion resolver', () => {
 
     it('createPromotion', async () => {
         const { createPromotion } = await adminClient.query<
-            CreatePromotion.Mutation,
-            CreatePromotion.Variables
+            Codegen.CreatePromotionMutation,
+            Codegen.CreatePromotionMutationVariables
         >(CREATE_PROMOTION, {
             input: {
                 name: 'test promotion',
@@ -120,8 +104,8 @@ describe('Promotion resolver', () => {
 
     it('createPromotion return error result with empty conditions and no couponCode', async () => {
         const { createPromotion } = await adminClient.query<
-            CreatePromotion.Mutation,
-            CreatePromotion.Variables
+            Codegen.CreatePromotionMutation,
+            Codegen.CreatePromotionMutationVariables
         >(CREATE_PROMOTION, {
             input: {
                 name: 'bad promotion',
@@ -150,8 +134,8 @@ describe('Promotion resolver', () => {
 
     it('updatePromotion', async () => {
         const { updatePromotion } = await adminClient.query<
-            UpdatePromotion.Mutation,
-            UpdatePromotion.Variables
+            Codegen.UpdatePromotionMutation,
+            Codegen.UpdatePromotionMutationVariables
         >(UPDATE_PROMOTION, {
             input: {
                 id: promotion.id,
@@ -177,8 +161,8 @@ describe('Promotion resolver', () => {
 
     it('updatePromotion return error result with empty conditions and no couponCode', async () => {
         const { updatePromotion } = await adminClient.query<
-            UpdatePromotion.Mutation,
-            UpdatePromotion.Variables
+            Codegen.UpdatePromotionMutation,
+            Codegen.UpdatePromotionMutationVariables
         >(UPDATE_PROMOTION, {
             input: {
                 id: promotion.id,
@@ -195,18 +179,21 @@ describe('Promotion resolver', () => {
     });
 
     it('promotion', async () => {
-        const result = await adminClient.query<GetPromotion.Query, GetPromotion.Variables>(GET_PROMOTION, {
-            id: promotion.id,
-        });
+        const result = await adminClient.query<Codegen.GetPromotionQuery, Codegen.GetPromotionQueryVariables>(
+            GET_PROMOTION,
+            {
+                id: promotion.id,
+            },
+        );
 
         expect(result.promotion!.name).toBe(promotion.name);
     });
 
     it('promotions', async () => {
-        const result = await adminClient.query<GetPromotionList.Query, GetPromotionList.Variables>(
-            GET_PROMOTION_LIST,
-            {},
-        );
+        const result = await adminClient.query<
+            Codegen.GetPromotionListQuery,
+            Codegen.GetPromotionListQueryVariables
+        >(GET_PROMOTION_LIST, {});
 
         expect(result.promotions.totalItems).toBe(1);
         expect(result.promotions.items[0].name).toBe('test promotion');
@@ -214,8 +201,8 @@ describe('Promotion resolver', () => {
 
     it('adjustmentOperations', async () => {
         const result = await adminClient.query<
-            GetAdjustmentOperations.Query,
-            GetAdjustmentOperations.Variables
+            Codegen.GetAdjustmentOperationsQuery,
+            Codegen.GetAdjustmentOperationsQueryVariables
         >(GET_ADJUSTMENT_OPERATIONS);
 
         expect(result.promotionActions).toMatchSnapshot();
@@ -224,11 +211,11 @@ describe('Promotion resolver', () => {
 
     describe('channels', () => {
         const SECOND_CHANNEL_TOKEN = 'SECOND_CHANNEL_TOKEN';
-        let secondChannel: ChannelFragment;
+        let secondChannel: Codegen.ChannelFragment;
         beforeAll(async () => {
             const { createChannel } = await adminClient.query<
-                CreateChannel.Mutation,
-                CreateChannel.Variables
+                Codegen.CreateChannelMutation,
+                Codegen.CreateChannelMutationVariables
             >(CREATE_CHANNEL, {
                 input: {
                     code: 'second-channel',
@@ -245,7 +232,7 @@ describe('Promotion resolver', () => {
 
         it('does not list Promotions not in active channel', async () => {
             adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
-            const { promotions } = await adminClient.query<GetPromotionList.Query>(GET_PROMOTION_LIST);
+            const { promotions } = await adminClient.query<Codegen.GetPromotionListQuery>(GET_PROMOTION_LIST);
 
             expect(promotions.totalItems).toBe(0);
             expect(promotions.items).toEqual([]);
@@ -253,12 +240,12 @@ describe('Promotion resolver', () => {
 
         it('does not return Promotion not in active channel', async () => {
             adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
-            const { promotion: result } = await adminClient.query<GetPromotion.Query, GetPromotion.Variables>(
-                GET_PROMOTION,
-                {
-                    id: promotion.id,
-                },
-            );
+            const { promotion: result } = await adminClient.query<
+                Codegen.GetPromotionQuery,
+                Codegen.GetPromotionQueryVariables
+            >(GET_PROMOTION, {
+                id: promotion.id,
+            });
 
             expect(result).toBeNull();
         });
@@ -266,8 +253,8 @@ describe('Promotion resolver', () => {
         it('assignPromotionsToChannel', async () => {
             adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
             const { assignPromotionsToChannel } = await adminClient.query<
-                AssignPromotionToChannel.Mutation,
-                AssignPromotionToChannel.Variables
+                Codegen.AssignPromotionToChannelMutation,
+                Codegen.AssignPromotionToChannelMutationVariables
             >(ASSIGN_PROMOTIONS_TO_CHANNEL, {
                 input: {
                     channelId: secondChannel.id,
@@ -278,15 +265,15 @@ describe('Promotion resolver', () => {
             expect(assignPromotionsToChannel).toEqual([{ id: promotion.id, name: promotion.name }]);
 
             adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
-            const { promotion: result } = await adminClient.query<GetPromotion.Query, GetPromotion.Variables>(
-                GET_PROMOTION,
-                {
-                    id: promotion.id,
-                },
-            );
+            const { promotion: result } = await adminClient.query<
+                Codegen.GetPromotionQuery,
+                Codegen.GetPromotionQueryVariables
+            >(GET_PROMOTION, {
+                id: promotion.id,
+            });
             expect(result?.id).toBe(promotion.id);
 
-            const { promotions } = await adminClient.query<GetPromotionList.Query>(GET_PROMOTION_LIST);
+            const { promotions } = await adminClient.query<Codegen.GetPromotionListQuery>(GET_PROMOTION_LIST);
             expect(promotions.totalItems).toBe(1);
             expect(promotions.items.map(pick(['id']))).toEqual([{ id: promotion.id }]);
         });
@@ -294,8 +281,8 @@ describe('Promotion resolver', () => {
         it('removePromotionsFromChannel', async () => {
             adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
             const { removePromotionsFromChannel } = await adminClient.query<
-                RemovePromotionFromChannel.Mutation,
-                RemovePromotionFromChannel.Variables
+                Codegen.RemovePromotionFromChannelMutation,
+                Codegen.RemovePromotionFromChannelMutationVariables
             >(REMOVE_PROMOTIONS_FROM_CHANNEL, {
                 input: {
                     channelId: secondChannel.id,
@@ -306,52 +293,52 @@ describe('Promotion resolver', () => {
             expect(removePromotionsFromChannel).toEqual([{ id: promotion.id, name: promotion.name }]);
 
             adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
-            const { promotion: result } = await adminClient.query<GetPromotion.Query, GetPromotion.Variables>(
-                GET_PROMOTION,
-                {
-                    id: promotion.id,
-                },
-            );
+            const { promotion: result } = await adminClient.query<
+                Codegen.GetPromotionQuery,
+                Codegen.GetPromotionQueryVariables
+            >(GET_PROMOTION, {
+                id: promotion.id,
+            });
             expect(result).toBeNull();
 
-            const { promotions } = await adminClient.query<GetPromotionList.Query>(GET_PROMOTION_LIST);
+            const { promotions } = await adminClient.query<Codegen.GetPromotionListQuery>(GET_PROMOTION_LIST);
             expect(promotions.totalItems).toBe(0);
         });
     });
 
     describe('deletion', () => {
-        let allPromotions: GetPromotionList.Items[];
-        let promotionToDelete: GetPromotionList.Items;
+        let allPromotions: Codegen.GetPromotionListQuery['promotions']['items'];
+        let promotionToDelete: Codegen.GetPromotionListQuery['promotions']['items'][number];
 
         beforeAll(async () => {
             adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
-            const result = await adminClient.query<GetPromotionList.Query>(GET_PROMOTION_LIST);
+            const result = await adminClient.query<Codegen.GetPromotionListQuery>(GET_PROMOTION_LIST);
             allPromotions = result.promotions.items;
         });
 
         it('deletes a promotion', async () => {
             promotionToDelete = allPromotions[0];
-            const result = await adminClient.query<DeletePromotion.Mutation, DeletePromotion.Variables>(
-                DELETE_PROMOTION,
-                { id: promotionToDelete.id },
-            );
+            const result = await adminClient.query<
+                Codegen.DeletePromotionMutation,
+                Codegen.DeletePromotionMutationVariables
+            >(DELETE_PROMOTION, { id: promotionToDelete.id });
 
             expect(result.deletePromotion).toEqual({ result: DeletionResult.DELETED });
         });
 
         it('cannot get a deleted promotion', async () => {
-            const result = await adminClient.query<GetPromotion.Query, GetPromotion.Variables>(
-                GET_PROMOTION,
-                {
-                    id: promotionToDelete.id,
-                },
-            );
+            const result = await adminClient.query<
+                Codegen.GetPromotionQuery,
+                Codegen.GetPromotionQueryVariables
+            >(GET_PROMOTION, {
+                id: promotionToDelete.id,
+            });
 
             expect(result.promotion).toBe(null);
         });
 
         it('deleted promotion omitted from list', async () => {
-            const result = await adminClient.query<GetPromotionList.Query>(GET_PROMOTION_LIST);
+            const result = await adminClient.query<Codegen.GetPromotionListQuery>(GET_PROMOTION_LIST);
 
             expect(result.promotions.items.length).toBe(allPromotions.length - 1);
             expect(result.promotions.items.map(c => c.id).includes(promotionToDelete.id)).toBe(false);
@@ -361,7 +348,10 @@ describe('Promotion resolver', () => {
             'updatePromotion throws for deleted promotion',
             assertThrowsWithMessage(
                 () =>
-                    adminClient.query<UpdatePromotion.Mutation, UpdatePromotion.Variables>(UPDATE_PROMOTION, {
+                    adminClient.query<
+                        Codegen.UpdatePromotionMutation,
+                        Codegen.UpdatePromotionMutationVariables
+                    >(UPDATE_PROMOTION, {
                         input: {
                             id: promotionToDelete.id,
                             enabled: false,

+ 139 - 104
packages/core/e2e/role.e2e-spec.ts

@@ -12,28 +12,16 @@ import { initialData } from '../../../e2e-common/e2e-initial-data';
 import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
 
 import { ROLE_FRAGMENT } from './graphql/fragments';
-import {
-    ChannelFragment,
-    CreateChannel,
-    CreateRole,
-    CurrencyCode,
-    DeleteRole,
-    DeletionResult,
-    GetRole,
-    GetRoles,
-    LanguageCode,
-    Permission,
-    Role,
-    UpdateRole,
-} from './graphql/generated-e2e-admin-types';
+import * as Codegen from './graphql/generated-e2e-admin-types';
+import { CurrencyCode, DeletionResult, LanguageCode, Permission } from './graphql/generated-e2e-admin-types';
 import { CREATE_CHANNEL, CREATE_ROLE, UPDATE_ROLE } from './graphql/shared-definitions';
 import { assertThrowsWithMessage } from './utils/assert-throws-with-message';
 import { sortById } from './utils/test-order-utils';
 
 describe('Role resolver', () => {
     const { server, adminClient } = createTestEnvironment(testConfig());
-    let createdRole: Role.Fragment;
-    let defaultRoles: Role.Fragment[];
+    let createdRole: Codegen.RoleFragment;
+    let defaultRoles: Codegen.RoleFragment[];
 
     beforeAll(async () => {
         await server.init({
@@ -49,7 +37,9 @@ describe('Role resolver', () => {
     });
 
     it('roles', async () => {
-        const result = await adminClient.query<GetRoles.Query, GetRoles.Variables>(GET_ROLES);
+        const result = await adminClient.query<Codegen.GetRolesQuery, Codegen.GetRolesQueryVariables>(
+            GET_ROLES,
+        );
 
         defaultRoles = result.roles.items;
         expect(result.roles.items.length).toBe(2);
@@ -58,13 +48,16 @@ describe('Role resolver', () => {
 
     it('createRole with invalid permission', async () => {
         try {
-            await adminClient.query<CreateRole.Mutation, CreateRole.Variables>(CREATE_ROLE, {
-                input: {
-                    code: 'test',
-                    description: 'test role',
-                    permissions: ['ReadCatalogx' as any],
+            await adminClient.query<Codegen.CreateRoleMutation, Codegen.CreateRoleMutationVariables>(
+                CREATE_ROLE,
+                {
+                    input: {
+                        code: 'test',
+                        description: 'test role',
+                        permissions: ['ReadCatalogx' as any],
+                    },
                 },
-            });
+            );
             fail('Should have thrown');
         } catch (e: any) {
             expect(e.response.errors[0]?.extensions.code).toBe('BAD_USER_INPUT');
@@ -72,16 +65,16 @@ describe('Role resolver', () => {
     });
 
     it('createRole with no permissions includes Authenticated', async () => {
-        const { createRole } = await adminClient.query<CreateRole.Mutation, CreateRole.Variables>(
-            CREATE_ROLE,
-            {
-                input: {
-                    code: 'test',
-                    description: 'test role',
-                    permissions: [],
-                },
+        const { createRole } = await adminClient.query<
+            Codegen.CreateRoleMutation,
+            Codegen.CreateRoleMutationVariables
+        >(CREATE_ROLE, {
+            input: {
+                code: 'test',
+                description: 'test role',
+                permissions: [],
             },
-        );
+        });
 
         expect(omit(createRole, ['channels'])).toEqual({
             code: 'test',
@@ -92,16 +85,16 @@ describe('Role resolver', () => {
     });
 
     it('createRole deduplicates permissions', async () => {
-        const { createRole } = await adminClient.query<CreateRole.Mutation, CreateRole.Variables>(
-            CREATE_ROLE,
-            {
-                input: {
-                    code: 'test2',
-                    description: 'test role2',
-                    permissions: [Permission.ReadSettings, Permission.ReadSettings],
-                },
+        const { createRole } = await adminClient.query<
+            Codegen.CreateRoleMutation,
+            Codegen.CreateRoleMutationVariables
+        >(CREATE_ROLE, {
+            input: {
+                code: 'test2',
+                description: 'test role2',
+                permissions: [Permission.ReadSettings, Permission.ReadSettings],
             },
-        );
+        });
 
         expect(omit(createRole, ['channels'])).toEqual({
             code: 'test2',
@@ -112,7 +105,10 @@ describe('Role resolver', () => {
     });
 
     it('createRole with permissions', async () => {
-        const result = await adminClient.query<CreateRole.Mutation, CreateRole.Variables>(CREATE_ROLE, {
+        const result = await adminClient.query<
+            Codegen.CreateRoleMutation,
+            Codegen.CreateRoleMutationVariables
+        >(CREATE_ROLE, {
             input: {
                 code: 'test',
                 description: 'test role',
@@ -137,15 +133,21 @@ describe('Role resolver', () => {
     });
 
     it('role', async () => {
-        const result = await adminClient.query<GetRole.Query, GetRole.Variables>(GET_ROLE, {
-            id: createdRole.id,
-        });
+        const result = await adminClient.query<Codegen.GetRoleQuery, Codegen.GetRoleQueryVariables>(
+            GET_ROLE,
+            {
+                id: createdRole.id,
+            },
+        );
         expect(result.role).toEqual(createdRole);
     });
 
     describe('updateRole', () => {
         it('updates role', async () => {
-            const result = await adminClient.query<UpdateRole.Mutation, UpdateRole.Variables>(UPDATE_ROLE, {
+            const result = await adminClient.query<
+                Codegen.UpdateRoleMutation,
+                Codegen.UpdateRoleMutationVariables
+            >(UPDATE_ROLE, {
                 input: {
                     id: createdRole.id,
                     code: 'test-modified',
@@ -172,7 +174,10 @@ describe('Role resolver', () => {
         });
 
         it('works with partial input', async () => {
-            const result = await adminClient.query<UpdateRole.Mutation, UpdateRole.Variables>(UPDATE_ROLE, {
+            const result = await adminClient.query<
+                Codegen.UpdateRoleMutation,
+                Codegen.UpdateRoleMutationVariables
+            >(UPDATE_ROLE, {
                 input: {
                     id: createdRole.id,
                     code: 'test-modified-again',
@@ -190,7 +195,10 @@ describe('Role resolver', () => {
         });
 
         it('deduplicates permissions', async () => {
-            const result = await adminClient.query<UpdateRole.Mutation, UpdateRole.Variables>(UPDATE_ROLE, {
+            const result = await adminClient.query<
+                Codegen.UpdateRoleMutation,
+                Codegen.UpdateRoleMutationVariables
+            >(UPDATE_ROLE, {
                 input: {
                     id: createdRole.id,
                     permissions: [
@@ -211,36 +219,45 @@ describe('Role resolver', () => {
         it(
             'does not allow setting non-assignable permissions - Owner',
             assertThrowsWithMessage(async () => {
-                await adminClient.query<UpdateRole.Mutation, UpdateRole.Variables>(UPDATE_ROLE, {
-                    input: {
-                        id: createdRole.id,
-                        permissions: [Permission.Owner],
+                await adminClient.query<Codegen.UpdateRoleMutation, Codegen.UpdateRoleMutationVariables>(
+                    UPDATE_ROLE,
+                    {
+                        input: {
+                            id: createdRole.id,
+                            permissions: [Permission.Owner],
+                        },
                     },
-                });
+                );
             }, 'The permission "Owner" may not be assigned'),
         );
 
         it(
             'does not allow setting non-assignable permissions - Public',
             assertThrowsWithMessage(async () => {
-                await adminClient.query<UpdateRole.Mutation, UpdateRole.Variables>(UPDATE_ROLE, {
-                    input: {
-                        id: createdRole.id,
-                        permissions: [Permission.Public],
+                await adminClient.query<Codegen.UpdateRoleMutation, Codegen.UpdateRoleMutationVariables>(
+                    UPDATE_ROLE,
+                    {
+                        input: {
+                            id: createdRole.id,
+                            permissions: [Permission.Public],
+                        },
                     },
-                });
+                );
             }, 'The permission "Public" may not be assigned'),
         );
 
         it(
             'does not allow setting SuperAdmin permission',
             assertThrowsWithMessage(async () => {
-                await adminClient.query<UpdateRole.Mutation, UpdateRole.Variables>(UPDATE_ROLE, {
-                    input: {
-                        id: createdRole.id,
-                        permissions: [Permission.SuperAdmin],
+                await adminClient.query<Codegen.UpdateRoleMutation, Codegen.UpdateRoleMutationVariables>(
+                    UPDATE_ROLE,
+                    {
+                        input: {
+                            id: createdRole.id,
+                            permissions: [Permission.SuperAdmin],
+                        },
                     },
-                });
+                );
             }, 'The permission "SuperAdmin" may not be assigned'),
         );
 
@@ -252,14 +269,17 @@ describe('Role resolver', () => {
                     fail(`Could not find SuperAdmin role`);
                     return;
                 }
-                return adminClient.query<UpdateRole.Mutation, UpdateRole.Variables>(UPDATE_ROLE, {
-                    input: {
-                        id: superAdminRole.id,
-                        code: 'superadmin-modified',
-                        description: 'superadmin modified',
-                        permissions: [Permission.Authenticated],
+                return adminClient.query<Codegen.UpdateRoleMutation, Codegen.UpdateRoleMutationVariables>(
+                    UPDATE_ROLE,
+                    {
+                        input: {
+                            id: superAdminRole.id,
+                            code: 'superadmin-modified',
+                            description: 'superadmin modified',
+                            permissions: [Permission.Authenticated],
+                        },
                     },
-                });
+                );
             }, `The role '${SUPER_ADMIN_ROLE_CODE}' cannot be modified`),
         );
 
@@ -271,14 +291,17 @@ describe('Role resolver', () => {
                     fail(`Could not find Customer role`);
                     return;
                 }
-                return adminClient.query<UpdateRole.Mutation, UpdateRole.Variables>(UPDATE_ROLE, {
-                    input: {
-                        id: customerRole.id,
-                        code: 'customer-modified',
-                        description: 'customer modified',
-                        permissions: [Permission.Authenticated, Permission.DeleteAdministrator],
+                return adminClient.query<Codegen.UpdateRoleMutation, Codegen.UpdateRoleMutationVariables>(
+                    UPDATE_ROLE,
+                    {
+                        input: {
+                            id: customerRole.id,
+                            code: 'customer-modified',
+                            description: 'customer modified',
+                            permissions: [Permission.Authenticated, Permission.DeleteAdministrator],
+                        },
                     },
-                });
+                );
             }, `The role '${CUSTOMER_ROLE_CODE}' cannot be modified`),
         );
     });
@@ -291,9 +314,12 @@ describe('Role resolver', () => {
                 fail(`Could not find Customer role`);
                 return;
             }
-            return adminClient.query<DeleteRole.Mutation, DeleteRole.Variables>(DELETE_ROLE, {
-                id: customerRole.id,
-            });
+            return adminClient.query<Codegen.DeleteRoleMutation, Codegen.DeleteRoleMutationVariables>(
+                DELETE_ROLE,
+                {
+                    id: customerRole.id,
+                },
+            );
         }, `The role '${CUSTOMER_ROLE_CODE}' cannot be deleted`),
     );
 
@@ -305,36 +331,42 @@ describe('Role resolver', () => {
                 fail(`Could not find Customer role`);
                 return;
             }
-            return adminClient.query<DeleteRole.Mutation, DeleteRole.Variables>(DELETE_ROLE, {
-                id: superAdminRole.id,
-            });
+            return adminClient.query<Codegen.DeleteRoleMutation, Codegen.DeleteRoleMutationVariables>(
+                DELETE_ROLE,
+                {
+                    id: superAdminRole.id,
+                },
+            );
         }, `The role '${SUPER_ADMIN_ROLE_CODE}' cannot be deleted`),
     );
 
     it('deleteRole deletes a role', async () => {
-        const { deleteRole } = await adminClient.query<DeleteRole.Mutation, DeleteRole.Variables>(
-            DELETE_ROLE,
+        const { deleteRole } = await adminClient.query<
+            Codegen.DeleteRoleMutation,
+            Codegen.DeleteRoleMutationVariables
+        >(DELETE_ROLE, {
+            id: createdRole.id,
+        });
+
+        expect(deleteRole.result).toBe(DeletionResult.DELETED);
+
+        const { role } = await adminClient.query<Codegen.GetRoleQuery, Codegen.GetRoleQueryVariables>(
+            GET_ROLE,
             {
                 id: createdRole.id,
             },
         );
-
-        expect(deleteRole.result).toBe(DeletionResult.DELETED);
-
-        const { role } = await adminClient.query<GetRole.Query, GetRole.Variables>(GET_ROLE, {
-            id: createdRole.id,
-        });
         expect(role).toBeNull();
     });
 
     describe('multi-channel', () => {
-        let secondChannel: ChannelFragment;
-        let multiChannelRole: CreateRole.CreateRole;
+        let secondChannel: Codegen.ChannelFragment;
+        let multiChannelRole: Codegen.CreateRoleMutation['createRole'];
 
         beforeAll(async () => {
             const { createChannel } = await adminClient.query<
-                CreateChannel.Mutation,
-                CreateChannel.Variables
+                Codegen.CreateChannelMutation,
+                Codegen.CreateChannelMutationVariables
             >(CREATE_CHANNEL, {
                 input: {
                     code: 'second-channel',
@@ -351,7 +383,10 @@ describe('Role resolver', () => {
         });
 
         it('createRole with specified channel', async () => {
-            const result = await adminClient.query<CreateRole.Mutation, CreateRole.Variables>(CREATE_ROLE, {
+            const result = await adminClient.query<
+                Codegen.CreateRoleMutation,
+                Codegen.CreateRoleMutationVariables
+            >(CREATE_ROLE, {
                 input: {
                     code: 'multi-test',
                     description: 'multi channel test role',
@@ -377,15 +412,15 @@ describe('Role resolver', () => {
         });
 
         it('updateRole with specified channel', async () => {
-            const { updateRole } = await adminClient.query<UpdateRole.Mutation, UpdateRole.Variables>(
-                UPDATE_ROLE,
-                {
-                    input: {
-                        id: multiChannelRole.id,
-                        channelIds: ['T_1', 'T_2'],
-                    },
+            const { updateRole } = await adminClient.query<
+                Codegen.UpdateRoleMutation,
+                Codegen.UpdateRoleMutationVariables
+            >(UPDATE_ROLE, {
+                input: {
+                    id: multiChannelRole.id,
+                    channelIds: ['T_1', 'T_2'],
                 },
-            );
+            });
 
             expect(updateRole.channels.sort(sortById)).toEqual([
                 {

+ 10 - 6
packages/core/e2e/session-management.e2e-spec.ts

@@ -8,7 +8,11 @@ import { initialData } from '../../../e2e-common/e2e-initial-data';
 import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
 import { SUPER_ADMIN_USER_IDENTIFIER, SUPER_ADMIN_USER_PASSWORD } from '../../common/src/shared-constants';
 
-import { AttemptLogin, Me } from './graphql/generated-e2e-admin-types';
+import {
+    AttemptLoginMutation,
+    AttemptLoginMutationVariables,
+    MeQuery,
+} from './graphql/generated-e2e-admin-types';
 import { ATTEMPT_LOGIN, ME } from './graphql/shared-definitions';
 
 const testSessionCache = new Map<string, CachedSession>();
@@ -67,7 +71,7 @@ describe('Session caching', () => {
         expect(setSpy.mock.calls.length).toBe(0);
         expect(testSessionCache.size).toBe(0);
 
-        await adminClient.query<AttemptLogin.Mutation, AttemptLogin.Variables>(ATTEMPT_LOGIN, {
+        await adminClient.query<AttemptLoginMutation, AttemptLoginMutationVariables>(ATTEMPT_LOGIN, {
             username: SUPER_ADMIN_USER_IDENTIFIER,
             password: SUPER_ADMIN_USER_PASSWORD,
         });
@@ -78,7 +82,7 @@ describe('Session caching', () => {
 
     it('takes user data from cache on next request', async () => {
         getSpy.mockClear();
-        const { me } = await adminClient.query<Me.Query>(ME);
+        const { me } = await adminClient.query<MeQuery>(ME);
 
         expect(getSpy.mock.calls.length).toBe(1);
     });
@@ -86,15 +90,15 @@ describe('Session caching', () => {
     it('sets fresh data after TTL expires', async () => {
         setSpy.mockClear();
 
-        await adminClient.query<Me.Query>(ME);
+        await adminClient.query<MeQuery>(ME);
         expect(setSpy.mock.calls.length).toBe(0);
 
-        await adminClient.query<Me.Query>(ME);
+        await adminClient.query<MeQuery>(ME);
         expect(setSpy.mock.calls.length).toBe(0);
 
         await pause(2000);
 
-        await adminClient.query<Me.Query>(ME);
+        await adminClient.query<MeQuery>(ME);
         expect(setSpy.mock.calls.length).toBe(1);
     });
 

+ 119 - 126
packages/core/e2e/shipping-method-eligibility.e2e-spec.ts

@@ -11,23 +11,9 @@ import path from 'path';
 import { initialData } from '../../../e2e-common/e2e-initial-data';
 import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
 
-import {
-    CreateShippingMethod,
-    LanguageCode,
-    ShippingMethodFragment,
-} from './graphql/generated-e2e-admin-types';
-import {
-    AddItemToOrder,
-    AdjustItemQuantity,
-    ErrorCode,
-    GetActiveOrder,
-    GetShippingMethods,
-    RemoveItemFromOrder,
-    SetShippingAddress,
-    SetShippingMethod,
-    TestOrderFragmentFragment,
-    UpdatedOrderFragment,
-} from './graphql/generated-e2e-shop-types';
+import * as Codegen from './graphql/generated-e2e-admin-types';
+import * as CodegenShop from './graphql/generated-e2e-shop-types';
+import { ErrorCode, LanguageCode } from './graphql/generated-e2e-shop-types';
 import { CREATE_SHIPPING_METHOD } from './graphql/shared-definitions';
 import {
     ADD_ITEM_TO_ORDER,
@@ -97,12 +83,13 @@ describe('ShippingMethod eligibility', () => {
         },
     });
 
-    const orderGuard: ErrorResultGuard<UpdatedOrderFragment | TestOrderFragmentFragment> =
-        createErrorResultGuard(input => !!input.lines);
+    const orderGuard: ErrorResultGuard<
+        CodegenShop.UpdatedOrderFragment | CodegenShop.TestOrderFragmentFragment
+    > = createErrorResultGuard(input => !!input.lines);
 
-    let singleLineShippingMethod: ShippingMethodFragment;
-    let multiLineShippingMethod: ShippingMethodFragment;
-    let optimizedShippingMethod: ShippingMethodFragment;
+    let singleLineShippingMethod: Codegen.ShippingMethodFragment;
+    let multiLineShippingMethod: Codegen.ShippingMethodFragment;
+    let optimizedShippingMethod: Codegen.ShippingMethodFragment;
 
     beforeAll(async () => {
         await server.init({
@@ -116,8 +103,8 @@ describe('ShippingMethod eligibility', () => {
         await adminClient.asSuperAdmin();
 
         const result1 = await adminClient.query<
-            CreateShippingMethod.Mutation,
-            CreateShippingMethod.Variables
+            Codegen.CreateShippingMethodMutation,
+            Codegen.CreateShippingMethodMutationVariables
         >(CREATE_SHIPPING_METHOD, {
             input: {
                 code: 'single-line',
@@ -138,8 +125,8 @@ describe('ShippingMethod eligibility', () => {
         singleLineShippingMethod = result1.createShippingMethod;
 
         const result2 = await adminClient.query<
-            CreateShippingMethod.Mutation,
-            CreateShippingMethod.Variables
+            Codegen.CreateShippingMethodMutation,
+            Codegen.CreateShippingMethodMutationVariables
         >(CREATE_SHIPPING_METHOD, {
             input: {
                 code: 'multi-line',
@@ -160,8 +147,8 @@ describe('ShippingMethod eligibility', () => {
         multiLineShippingMethod = result2.createShippingMethod;
 
         const result3 = await adminClient.query<
-            CreateShippingMethod.Mutation,
-            CreateShippingMethod.Variables
+            Codegen.CreateShippingMethodMutation,
+            Codegen.CreateShippingMethodMutationVariables
         >(CREATE_SHIPPING_METHOD, {
             input: {
                 code: 'optimized',
@@ -187,7 +174,7 @@ describe('ShippingMethod eligibility', () => {
     });
 
     describe('default behavior', () => {
-        let order: UpdatedOrderFragment;
+        let order: CodegenShop.UpdatedOrderFragment;
 
         it('Does not run checkers before a ShippingMethod is assigned to Order', async () => {
             check1Spy.mockClear();
@@ -196,8 +183,8 @@ describe('ShippingMethod eligibility', () => {
             await shopClient.asUserWithCredentials('hayden.zieme12@hotmail.com', 'test');
 
             const { addItemToOrder } = await shopClient.query<
-                AddItemToOrder.Mutation,
-                AddItemToOrder.Variables
+                CodegenShop.AddItemToOrderMutation,
+                CodegenShop.AddItemToOrderMutationVariables
             >(ADD_ITEM_TO_ORDER, {
                 quantity: 1,
                 productVariantId: 'T_1',
@@ -207,13 +194,13 @@ describe('ShippingMethod eligibility', () => {
             expect(check1Spy).not.toHaveBeenCalled();
             expect(check2Spy).not.toHaveBeenCalled();
 
-            await shopClient.query<AdjustItemQuantity.Mutation, AdjustItemQuantity.Variables>(
-                ADJUST_ITEM_QUANTITY,
-                {
-                    quantity: 2,
-                    orderLineId: addItemToOrder.lines[0].id,
-                },
-            );
+            await shopClient.query<
+                CodegenShop.AdjustItemQuantityMutation,
+                CodegenShop.AdjustItemQuantityMutationVariables
+            >(ADJUST_ITEM_QUANTITY, {
+                quantity: 2,
+                orderLineId: addItemToOrder.lines[0].id,
+            });
 
             expect(check1Spy).not.toHaveBeenCalled();
             expect(check2Spy).not.toHaveBeenCalled();
@@ -225,7 +212,7 @@ describe('ShippingMethod eligibility', () => {
             check1Spy.mockClear();
             check2Spy.mockClear();
 
-            const { eligibleShippingMethods } = await shopClient.query<GetShippingMethods.Query>(
+            const { eligibleShippingMethods } = await shopClient.query<CodegenShop.GetShippingMethodsQuery>(
                 GET_ELIGIBLE_SHIPPING_METHODS,
             );
 
@@ -237,36 +224,36 @@ describe('ShippingMethod eligibility', () => {
             check1Spy.mockClear();
             check2Spy.mockClear();
 
-            await shopClient.query<SetShippingMethod.Mutation, SetShippingMethod.Variables>(
-                SET_SHIPPING_METHOD,
-                {
-                    id: singleLineShippingMethod.id,
-                },
-            );
+            await shopClient.query<
+                CodegenShop.SetShippingMethodMutation,
+                CodegenShop.SetShippingMethodMutationVariables
+            >(SET_SHIPPING_METHOD, {
+                id: singleLineShippingMethod.id,
+            });
 
             // A check is done when assigning the method to ensure it
             // is eligible, and again when calculating order adjustments
             expect(check1Spy).toHaveBeenCalledTimes(2);
             expect(check2Spy).not.toHaveBeenCalled();
 
-            await shopClient.query<AdjustItemQuantity.Mutation, AdjustItemQuantity.Variables>(
-                ADJUST_ITEM_QUANTITY,
-                {
-                    quantity: 3,
-                    orderLineId: order.lines[0].id,
-                },
-            );
+            await shopClient.query<
+                CodegenShop.AdjustItemQuantityMutation,
+                CodegenShop.AdjustItemQuantityMutationVariables
+            >(ADJUST_ITEM_QUANTITY, {
+                quantity: 3,
+                orderLineId: order.lines[0].id,
+            });
 
             expect(check1Spy).toHaveBeenCalledTimes(3);
             expect(check2Spy).not.toHaveBeenCalled();
 
-            await shopClient.query<AdjustItemQuantity.Mutation, AdjustItemQuantity.Variables>(
-                ADJUST_ITEM_QUANTITY,
-                {
-                    quantity: 4,
-                    orderLineId: order.lines[0].id,
-                },
-            );
+            await shopClient.query<
+                CodegenShop.AdjustItemQuantityMutation,
+                CodegenShop.AdjustItemQuantityMutationVariables
+            >(ADJUST_ITEM_QUANTITY, {
+                quantity: 4,
+                orderLineId: order.lines[0].id,
+            });
 
             expect(check1Spy).toHaveBeenCalledTimes(4);
             expect(check2Spy).not.toHaveBeenCalled();
@@ -274,8 +261,8 @@ describe('ShippingMethod eligibility', () => {
 
         it('Prevents ineligible method from being assigned', async () => {
             const { setOrderShippingMethod } = await shopClient.query<
-                SetShippingMethod.Mutation,
-                SetShippingMethod.Variables
+                CodegenShop.SetShippingMethodMutation,
+                CodegenShop.SetShippingMethodMutationVariables
             >(SET_SHIPPING_METHOD, {
                 id: multiLineShippingMethod.id,
             });
@@ -295,8 +282,8 @@ describe('ShippingMethod eligibility', () => {
             // Adding a second OrderLine will make the singleLineShippingMethod
             // ineligible
             const { addItemToOrder } = await shopClient.query<
-                AddItemToOrder.Mutation,
-                AddItemToOrder.Variables
+                CodegenShop.AddItemToOrderMutation,
+                CodegenShop.AddItemToOrderMutationVariables
             >(ADD_ITEM_TO_ORDER, {
                 quantity: 1,
                 productVariantId: 'T_2',
@@ -308,17 +295,17 @@ describe('ShippingMethod eligibility', () => {
             // Checked once when looking for a fallback
             expect(check2Spy).toHaveBeenCalledTimes(1);
 
-            const { activeOrder } = await shopClient.query<GetActiveOrder.Query>(GET_ACTIVE_ORDER);
+            const { activeOrder } = await shopClient.query<CodegenShop.GetActiveOrderQuery>(GET_ACTIVE_ORDER);
             // multiLineShippingMethod assigned as a fallback
             expect(activeOrder?.shippingLines?.[0]?.shippingMethod?.id).toBe(multiLineShippingMethod.id);
 
-            await shopClient.query<AdjustItemQuantity.Mutation, AdjustItemQuantity.Variables>(
-                ADJUST_ITEM_QUANTITY,
-                {
-                    quantity: 2,
-                    orderLineId: addItemToOrder.lines[1].id,
-                },
-            );
+            await shopClient.query<
+                CodegenShop.AdjustItemQuantityMutation,
+                CodegenShop.AdjustItemQuantityMutationVariables
+            >(ADJUST_ITEM_QUANTITY, {
+                quantity: 2,
+                orderLineId: addItemToOrder.lines[1].id,
+            });
 
             // No longer called as singleLineShippingMethod not assigned
             expect(check1Spy).toHaveBeenCalledTimes(1);
@@ -327,8 +314,8 @@ describe('ShippingMethod eligibility', () => {
 
             // Remove the second OrderLine and make multiLineShippingMethod ineligible
             const { removeOrderLine } = await shopClient.query<
-                RemoveItemFromOrder.Mutation,
-                RemoveItemFromOrder.Variables
+                CodegenShop.RemoveItemFromOrderMutation,
+                CodegenShop.RemoveItemFromOrderMutationVariables
             >(REMOVE_ITEM_FROM_ORDER, {
                 orderLineId: addItemToOrder.lines[1].id,
             });
@@ -345,21 +332,27 @@ describe('ShippingMethod eligibility', () => {
     });
 
     describe('optimization via shouldRunCheck function', () => {
-        let order: UpdatedOrderFragment;
+        let order: CodegenShop.UpdatedOrderFragment;
 
         beforeAll(async () => {
             await shopClient.asAnonymousUser();
-            await shopClient.query<AddItemToOrder.Mutation, AddItemToOrder.Variables>(ADD_ITEM_TO_ORDER, {
+            await shopClient.query<
+                CodegenShop.AddItemToOrderMutation,
+                CodegenShop.AddItemToOrderMutationVariables
+            >(ADD_ITEM_TO_ORDER, {
                 quantity: 1,
                 productVariantId: 'T_1',
             });
-            await shopClient.query<AddItemToOrder.Mutation, AddItemToOrder.Variables>(ADD_ITEM_TO_ORDER, {
+            await shopClient.query<
+                CodegenShop.AddItemToOrderMutation,
+                CodegenShop.AddItemToOrderMutationVariables
+            >(ADD_ITEM_TO_ORDER, {
                 quantity: 1,
                 productVariantId: 'T_2',
             });
             const { addItemToOrder } = await shopClient.query<
-                AddItemToOrder.Mutation,
-                AddItemToOrder.Variables
+                CodegenShop.AddItemToOrderMutation,
+                CodegenShop.AddItemToOrderMutationVariables
             >(ADD_ITEM_TO_ORDER, {
                 quantity: 1,
                 productVariantId: 'T_3',
@@ -367,22 +360,22 @@ describe('ShippingMethod eligibility', () => {
             orderGuard.assertSuccess(addItemToOrder);
             order = addItemToOrder;
 
-            await shopClient.query<SetShippingAddress.Mutation, SetShippingAddress.Variables>(
-                SET_SHIPPING_ADDRESS,
-                {
-                    input: {
-                        streetLine1: '42 Test Street',
-                        city: 'Doncaster',
-                        postalCode: 'DN1 4EE',
-                        countryCode: 'GB',
-                    },
+            await shopClient.query<
+                CodegenShop.SetShippingAddressMutation,
+                CodegenShop.SetShippingAddressMutationVariables
+            >(SET_SHIPPING_ADDRESS, {
+                input: {
+                    streetLine1: '42 Test Street',
+                    city: 'Doncaster',
+                    postalCode: 'DN1 4EE',
+                    countryCode: 'GB',
                 },
-            );
+            });
         });
 
         it('runs check on getEligibleShippingMethods', async () => {
             check3Spy.mockClear();
-            const { eligibleShippingMethods } = await shopClient.query<GetShippingMethods.Query>(
+            const { eligibleShippingMethods } = await shopClient.query<CodegenShop.GetShippingMethodsQuery>(
                 GET_ELIGIBLE_SHIPPING_METHODS,
             );
 
@@ -391,25 +384,25 @@ describe('ShippingMethod eligibility', () => {
 
         it('does not re-run check on setting shipping method', async () => {
             check3Spy.mockClear();
-            await shopClient.query<SetShippingMethod.Mutation, SetShippingMethod.Variables>(
-                SET_SHIPPING_METHOD,
-                {
-                    id: optimizedShippingMethod.id,
-                },
-            );
+            await shopClient.query<
+                CodegenShop.SetShippingMethodMutation,
+                CodegenShop.SetShippingMethodMutationVariables
+            >(SET_SHIPPING_METHOD, {
+                id: optimizedShippingMethod.id,
+            });
             expect(check3Spy).toHaveBeenCalledTimes(0);
         });
 
         it('does not re-run check when changing cart contents', async () => {
             check3Spy.mockClear();
 
-            await shopClient.query<AdjustItemQuantity.Mutation, AdjustItemQuantity.Variables>(
-                ADJUST_ITEM_QUANTITY,
-                {
-                    quantity: 3,
-                    orderLineId: order.lines[0].id,
-                },
-            );
+            await shopClient.query<
+                CodegenShop.AdjustItemQuantityMutation,
+                CodegenShop.AdjustItemQuantityMutationVariables
+            >(ADJUST_ITEM_QUANTITY, {
+                quantity: 3,
+                orderLineId: order.lines[0].id,
+            });
 
             expect(check3Spy).toHaveBeenCalledTimes(0);
         });
@@ -418,37 +411,37 @@ describe('ShippingMethod eligibility', () => {
             check3Spy.mockClear();
             // Update the shipping address, causing the `shouldRunCheck` function
             // to trigger a check
-            await shopClient.query<SetShippingAddress.Mutation, SetShippingAddress.Variables>(
-                SET_SHIPPING_ADDRESS,
-                {
-                    input: {
-                        streetLine1: '43 Test Street', // This line changed
-                        city: 'Doncaster',
-                        postalCode: 'DN1 4EE',
-                        countryCode: 'GB',
-                    },
+            await shopClient.query<
+                CodegenShop.SetShippingAddressMutation,
+                CodegenShop.SetShippingAddressMutationVariables
+            >(SET_SHIPPING_ADDRESS, {
+                input: {
+                    streetLine1: '43 Test Street', // This line changed
+                    city: 'Doncaster',
+                    postalCode: 'DN1 4EE',
+                    countryCode: 'GB',
                 },
-            );
+            });
 
-            await shopClient.query<AdjustItemQuantity.Mutation, AdjustItemQuantity.Variables>(
-                ADJUST_ITEM_QUANTITY,
-                {
-                    quantity: 2,
-                    orderLineId: order.lines[0].id,
-                },
-            );
+            await shopClient.query<
+                CodegenShop.AdjustItemQuantityMutation,
+                CodegenShop.AdjustItemQuantityMutationVariables
+            >(ADJUST_ITEM_QUANTITY, {
+                quantity: 2,
+                orderLineId: order.lines[0].id,
+            });
 
             expect(check3Spy).toHaveBeenCalledTimes(1);
 
             // Does not check a second time though, since the shipping address
             // is now the same as on the last check.
-            await shopClient.query<AdjustItemQuantity.Mutation, AdjustItemQuantity.Variables>(
-                ADJUST_ITEM_QUANTITY,
-                {
-                    quantity: 3,
-                    orderLineId: order.lines[0].id,
-                },
-            );
+            await shopClient.query<
+                CodegenShop.AdjustItemQuantityMutation,
+                CodegenShop.AdjustItemQuantityMutationVariables
+            >(ADJUST_ITEM_QUANTITY, {
+                quantity: 3,
+                orderLineId: order.lines[0].id,
+            });
 
             expect(check3Spy).toHaveBeenCalledTimes(1);
         });

+ 23 - 30
packages/core/e2e/shipping-method.e2e-spec.ts

@@ -13,19 +13,8 @@ import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-conf
 import { manualFulfillmentHandler } from '../src/config/fulfillment/manual-fulfillment-handler';
 
 import { SHIPPING_METHOD_FRAGMENT } from './graphql/fragments';
-import {
-    CreateShippingMethod,
-    DeleteShippingMethod,
-    DeletionResult,
-    GetCalculators,
-    GetEligibilityCheckers,
-    GetShippingMethod,
-    GetShippingMethodList,
-    LanguageCode,
-    TestEligibleMethods,
-    TestShippingMethod,
-    UpdateShippingMethod,
-} from './graphql/generated-e2e-admin-types';
+import * as Codegen from './graphql/generated-e2e-admin-types';
+import { DeletionResult, LanguageCode } from './graphql/generated-e2e-admin-types';
 import {
     CREATE_SHIPPING_METHOD,
     DELETE_SHIPPING_METHOD,
@@ -75,7 +64,7 @@ describe('ShippingMethod resolver', () => {
     });
 
     it('shippingEligibilityCheckers', async () => {
-        const { shippingEligibilityCheckers } = await adminClient.query<GetEligibilityCheckers.Query>(
+        const { shippingEligibilityCheckers } = await adminClient.query<Codegen.GetEligibilityCheckersQuery>(
             GET_ELIGIBILITY_CHECKERS,
         );
 
@@ -99,7 +88,7 @@ describe('ShippingMethod resolver', () => {
     });
 
     it('shippingCalculators', async () => {
-        const { shippingCalculators } = await adminClient.query<GetCalculators.Query>(GET_CALCULATORS);
+        const { shippingCalculators } = await adminClient.query<Codegen.GetCalculatorsQuery>(GET_CALCULATORS);
 
         expect(shippingCalculators).toEqual([
             {
@@ -161,7 +150,7 @@ describe('ShippingMethod resolver', () => {
     });
 
     it('shippingMethods', async () => {
-        const { shippingMethods } = await adminClient.query<GetShippingMethodList.Query>(
+        const { shippingMethods } = await adminClient.query<Codegen.GetShippingMethodListQuery>(
             GET_SHIPPING_METHOD_LIST,
         );
         expect(shippingMethods.totalItems).toEqual(2);
@@ -171,8 +160,8 @@ describe('ShippingMethod resolver', () => {
 
     it('shippingMethod', async () => {
         const { shippingMethod } = await adminClient.query<
-            GetShippingMethod.Query,
-            GetShippingMethod.Variables
+            Codegen.GetShippingMethodQuery,
+            Codegen.GetShippingMethodQueryVariables
         >(GET_SHIPPING_METHOD, {
             id: 'T_1',
         });
@@ -181,8 +170,8 @@ describe('ShippingMethod resolver', () => {
 
     it('createShippingMethod', async () => {
         const { createShippingMethod } = await adminClient.query<
-            CreateShippingMethod.Mutation,
-            CreateShippingMethod.Variables
+            Codegen.CreateShippingMethodMutation,
+            Codegen.CreateShippingMethodMutationVariables
         >(CREATE_SHIPPING_METHOD, {
             input: {
                 code: 'new-method',
@@ -227,8 +216,8 @@ describe('ShippingMethod resolver', () => {
 
     it('testShippingMethod', async () => {
         const { testShippingMethod } = await adminClient.query<
-            TestShippingMethod.Query,
-            TestShippingMethod.Variables
+            Codegen.TestShippingMethodQuery,
+            Codegen.TestShippingMethodQueryVariables
         >(TEST_SHIPPING_METHOD, {
             input: {
                 calculator: {
@@ -264,8 +253,8 @@ describe('ShippingMethod resolver', () => {
 
     it('testEligibleShippingMethods', async () => {
         const { testEligibleShippingMethods } = await adminClient.query<
-            TestEligibleMethods.Query,
-            TestEligibleMethods.Variables
+            Codegen.TestEligibleMethodsQuery,
+            Codegen.TestEligibleMethodsQueryVariables
         >(TEST_ELIGIBLE_SHIPPING_METHODS, {
             input: {
                 lines: [{ productVariantId: 'T_1', quantity: 1 }],
@@ -307,8 +296,8 @@ describe('ShippingMethod resolver', () => {
 
     it('updateShippingMethod', async () => {
         const { updateShippingMethod } = await adminClient.query<
-            UpdateShippingMethod.Mutation,
-            UpdateShippingMethod.Variables
+            Codegen.UpdateShippingMethodMutation,
+            Codegen.UpdateShippingMethodMutationVariables
         >(UPDATE_SHIPPING_METHOD, {
             input: {
                 id: 'T_3',
@@ -320,12 +309,14 @@ describe('ShippingMethod resolver', () => {
     });
 
     it('deleteShippingMethod', async () => {
-        const listResult1 = await adminClient.query<GetShippingMethodList.Query>(GET_SHIPPING_METHOD_LIST);
+        const listResult1 = await adminClient.query<Codegen.GetShippingMethodListQuery>(
+            GET_SHIPPING_METHOD_LIST,
+        );
         expect(listResult1.shippingMethods.items.map(i => i.id)).toEqual(['T_1', 'T_2', 'T_3']);
 
         const { deleteShippingMethod } = await adminClient.query<
-            DeleteShippingMethod.Mutation,
-            DeleteShippingMethod.Variables
+            Codegen.DeleteShippingMethodMutation,
+            Codegen.DeleteShippingMethodMutationVariables
         >(DELETE_SHIPPING_METHOD, {
             id: 'T_3',
         });
@@ -335,7 +326,9 @@ describe('ShippingMethod resolver', () => {
             message: null,
         });
 
-        const listResult2 = await adminClient.query<GetShippingMethodList.Query>(GET_SHIPPING_METHOD_LIST);
+        const listResult2 = await adminClient.query<Codegen.GetShippingMethodListQuery>(
+            GET_SHIPPING_METHOD_LIST,
+        );
         expect(listResult2.shippingMethods.items.map(i => i.id)).toEqual(['T_1', 'T_2']);
     });
 });

+ 260 - 251
packages/core/e2e/shop-auth.e2e-spec.ts

@@ -23,26 +23,10 @@ import { initialData } from '../../../e2e-common/e2e-initial-data';
 import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
 import { PasswordValidationError } from '../src/common/error/generated-graphql-shop-errors';
 
-import {
-    CreateAdministrator,
-    CreateRole,
-    GetCustomer,
-    GetCustomerHistory,
-    GetCustomerList,
-    HistoryEntryType,
-    Permission,
-} from './graphql/generated-e2e-admin-types';
-import {
-    CurrentUserShopFragment,
-    GetActiveCustomer,
-    RefreshToken,
-    Register,
-    RequestPasswordReset,
-    RequestUpdateEmailAddress,
-    ResetPassword,
-    UpdateEmailAddress,
-    Verify,
-} from './graphql/generated-e2e-shop-types';
+import * as Codegen from './graphql/generated-e2e-admin-types';
+import { HistoryEntryType, Permission } from './graphql/generated-e2e-admin-types';
+import * as CodegenShop from './graphql/generated-e2e-shop-types';
+import { CurrentUserShopFragment } from './graphql/generated-e2e-shop-types';
 import {
     CREATE_ADMINISTRATOR,
     CREATE_ROLE,
@@ -60,7 +44,6 @@ import {
     UPDATE_EMAIL_ADDRESS,
     VERIFY_EMAIL,
 } from './graphql/shop-definitions';
-import { assertThrowsWithMessage } from './utils/assert-throws-with-message';
 
 let sendEmailFn: jest.Mock;
 
@@ -144,19 +127,19 @@ describe('Shop auth & accounts', () => {
 
         it('does not return error result on email address conflict', async () => {
             // To prevent account enumeration attacks
-            const { customers } = await adminClient.query<GetCustomerList.Query>(GET_CUSTOMER_LIST);
+            const { customers } = await adminClient.query<Codegen.GetCustomerListQuery>(GET_CUSTOMER_LIST);
             const input: RegisterCustomerInput = {
                 firstName: 'Duplicate',
                 lastName: 'Person',
                 phoneNumber: '123456',
                 emailAddress: customers.items[0].emailAddress,
             };
-            const { registerCustomerAccount } = await shopClient.query<Register.Mutation, Register.Variables>(
-                REGISTER_ACCOUNT,
-                {
-                    input,
-                },
-            );
+            const { registerCustomerAccount } = await shopClient.query<
+                CodegenShop.RegisterMutation,
+                CodegenShop.RegisterMutationVariables
+            >(REGISTER_ACCOUNT, {
+                input,
+            });
             successErrorGuard.assertSuccess(registerCustomerAccount);
         });
 
@@ -168,12 +151,12 @@ describe('Shop auth & accounts', () => {
                 phoneNumber: '123456',
                 emailAddress,
             };
-            const { registerCustomerAccount } = await shopClient.query<Register.Mutation, Register.Variables>(
-                REGISTER_ACCOUNT,
-                {
-                    input,
-                },
-            );
+            const { registerCustomerAccount } = await shopClient.query<
+                CodegenShop.RegisterMutation,
+                CodegenShop.RegisterMutationVariables
+            >(REGISTER_ACCOUNT, {
+                input,
+            });
             successErrorGuard.assertSuccess(registerCustomerAccount);
 
             verificationToken = await verificationTokenPromise;
@@ -182,18 +165,18 @@ describe('Shop auth & accounts', () => {
             expect(sendEmailFn).toHaveBeenCalled();
             expect(verificationToken).toBeDefined();
 
-            const { customers } = await adminClient.query<GetCustomerList.Query, GetCustomerList.Variables>(
-                GET_CUSTOMER_LIST,
-                {
-                    options: {
-                        filter: {
-                            emailAddress: {
-                                eq: emailAddress,
-                            },
+            const { customers } = await adminClient.query<
+                Codegen.GetCustomerListQuery,
+                Codegen.GetCustomerListQueryVariables
+            >(GET_CUSTOMER_LIST, {
+                options: {
+                    filter: {
+                        emailAddress: {
+                            eq: emailAddress,
                         },
                     },
                 },
-            );
+            });
 
             expect(
                 pick(customers.items[0], ['firstName', 'lastName', 'emailAddress', 'phoneNumber']),
@@ -211,12 +194,12 @@ describe('Shop auth & accounts', () => {
                 lastName: 'Tester',
                 emailAddress,
             };
-            const { registerCustomerAccount } = await shopClient.query<Register.Mutation, Register.Variables>(
-                REGISTER_ACCOUNT,
-                {
-                    input,
-                },
-            );
+            const { registerCustomerAccount } = await shopClient.query<
+                CodegenShop.RegisterMutation,
+                CodegenShop.RegisterMutationVariables
+            >(REGISTER_ACCOUNT, {
+                input,
+            });
             successErrorGuard.assertSuccess(registerCustomerAccount);
 
             const newVerificationToken = await sendEmail;
@@ -235,8 +218,8 @@ describe('Shop auth & accounts', () => {
                 });
             });
             const { refreshCustomerVerification } = await shopClient.query<
-                RefreshToken.Mutation,
-                RefreshToken.Variables
+                CodegenShop.RefreshTokenMutation,
+                CodegenShop.RefreshTokenMutationVariables
             >(REFRESH_TOKEN, { emailAddress });
             successErrorGuard.assertSuccess(refreshCustomerVerification);
             const newVerificationToken = await sendEmail;
@@ -250,8 +233,8 @@ describe('Shop auth & accounts', () => {
 
         it('refreshCustomerVerification does nothing with an unrecognized emailAddress', async () => {
             const { refreshCustomerVerification } = await shopClient.query<
-                RefreshToken.Mutation,
-                RefreshToken.Variables
+                CodegenShop.RefreshTokenMutation,
+                CodegenShop.RefreshTokenMutationVariables
             >(REFRESH_TOKEN, {
                 emailAddress: 'never-been-registered@test.com',
             });
@@ -268,13 +251,13 @@ describe('Shop auth & accounts', () => {
         });
 
         it('verification fails with wrong token', async () => {
-            const { verifyCustomerAccount } = await shopClient.query<Verify.Mutation, Verify.Variables>(
-                VERIFY_EMAIL,
-                {
-                    password,
-                    token: 'bad-token',
-                },
-            );
+            const { verifyCustomerAccount } = await shopClient.query<
+                CodegenShop.VerifyMutation,
+                CodegenShop.VerifyMutationVariables
+            >(VERIFY_EMAIL, {
+                password,
+                token: 'bad-token',
+            });
             currentUserErrorGuard.assertErrorResult(verifyCustomerAccount);
 
             expect(verifyCustomerAccount.message).toBe(`Verification token not recognized`);
@@ -282,12 +265,12 @@ describe('Shop auth & accounts', () => {
         });
 
         it('verification fails with no password', async () => {
-            const { verifyCustomerAccount } = await shopClient.query<Verify.Mutation, Verify.Variables>(
-                VERIFY_EMAIL,
-                {
-                    token: verificationToken,
-                },
-            );
+            const { verifyCustomerAccount } = await shopClient.query<
+                CodegenShop.VerifyMutation,
+                CodegenShop.VerifyMutationVariables
+            >(VERIFY_EMAIL, {
+                token: verificationToken,
+            });
             currentUserErrorGuard.assertErrorResult(verifyCustomerAccount);
 
             expect(verifyCustomerAccount.message).toBe(`A password must be provided.`);
@@ -295,13 +278,13 @@ describe('Shop auth & accounts', () => {
         });
 
         it('verification fails with invalid password', async () => {
-            const { verifyCustomerAccount } = await shopClient.query<Verify.Mutation, Verify.Variables>(
-                VERIFY_EMAIL,
-                {
-                    token: verificationToken,
-                    password: '2short',
-                },
-            );
+            const { verifyCustomerAccount } = await shopClient.query<
+                CodegenShop.VerifyMutation,
+                CodegenShop.VerifyMutationVariables
+            >(VERIFY_EMAIL, {
+                token: verificationToken,
+                password: '2short',
+            });
             currentUserErrorGuard.assertErrorResult(verifyCustomerAccount);
 
             expect(verifyCustomerAccount.message).toBe(`Password is invalid`);
@@ -312,17 +295,19 @@ describe('Shop auth & accounts', () => {
         });
 
         it('verification succeeds with password and correct token', async () => {
-            const { verifyCustomerAccount } = await shopClient.query<Verify.Mutation, Verify.Variables>(
-                VERIFY_EMAIL,
-                {
-                    password,
-                    token: verificationToken,
-                },
-            );
+            const { verifyCustomerAccount } = await shopClient.query<
+                CodegenShop.VerifyMutation,
+                CodegenShop.VerifyMutationVariables
+            >(VERIFY_EMAIL, {
+                password,
+                token: verificationToken,
+            });
             currentUserErrorGuard.assertSuccess(verifyCustomerAccount);
 
             expect(verifyCustomerAccount.identifier).toBe('test1@test.com');
-            const { activeCustomer } = await shopClient.query<GetActiveCustomer.Query>(GET_ACTIVE_CUSTOMER);
+            const { activeCustomer } = await shopClient.query<CodegenShop.GetActiveCustomerQuery>(
+                GET_ACTIVE_CUSTOMER,
+            );
             newCustomerId = activeCustomer!.id;
         });
 
@@ -332,12 +317,12 @@ describe('Shop auth & accounts', () => {
                 lastName: 'Hacker',
                 emailAddress,
             };
-            const { registerCustomerAccount } = await shopClient.query<Register.Mutation, Register.Variables>(
-                REGISTER_ACCOUNT,
-                {
-                    input,
-                },
-            );
+            const { registerCustomerAccount } = await shopClient.query<
+                CodegenShop.RegisterMutation,
+                CodegenShop.RegisterMutationVariables
+            >(REGISTER_ACCOUNT, {
+                input,
+            });
             successErrorGuard.assertSuccess(registerCustomerAccount);
 
             await waitForSendEmailFn();
@@ -346,13 +331,13 @@ describe('Shop auth & accounts', () => {
         });
 
         it('verification fails if attempted a second time', async () => {
-            const { verifyCustomerAccount } = await shopClient.query<Verify.Mutation, Verify.Variables>(
-                VERIFY_EMAIL,
-                {
-                    password,
-                    token: verificationToken,
-                },
-            );
+            const { verifyCustomerAccount } = await shopClient.query<
+                CodegenShop.VerifyMutation,
+                CodegenShop.VerifyMutationVariables
+            >(VERIFY_EMAIL, {
+                password,
+                token: verificationToken,
+            });
             currentUserErrorGuard.assertErrorResult(verifyCustomerAccount);
 
             expect(verifyCustomerAccount.message).toBe(`Verification token not recognized`);
@@ -361,8 +346,8 @@ describe('Shop auth & accounts', () => {
 
         it('customer history contains entries for registration & verification', async () => {
             const { customer } = await adminClient.query<
-                GetCustomerHistory.Query,
-                GetCustomerHistory.Variables
+                Codegen.GetCustomerHistoryQuery,
+                Codegen.GetCustomerHistoryQueryVariables
             >(GET_CUSTOMER_HISTORY, {
                 id: newCustomerId,
             });
@@ -404,12 +389,12 @@ describe('Shop auth & accounts', () => {
                 emailAddress,
                 password: '12345678',
             };
-            const { registerCustomerAccount } = await shopClient.query<Register.Mutation, Register.Variables>(
-                REGISTER_ACCOUNT,
-                {
-                    input,
-                },
-            );
+            const { registerCustomerAccount } = await shopClient.query<
+                CodegenShop.RegisterMutation,
+                CodegenShop.RegisterMutationVariables
+            >(REGISTER_ACCOUNT, {
+                input,
+            });
             successErrorGuard.assertErrorResult(registerCustomerAccount);
             expect(registerCustomerAccount.errorCode).toBe(ErrorCode.PASSWORD_VALIDATION_ERROR);
             expect(registerCustomerAccount.message).toBe(`Password is invalid`);
@@ -427,12 +412,12 @@ describe('Shop auth & accounts', () => {
                 emailAddress,
                 password,
             };
-            const { registerCustomerAccount } = await shopClient.query<Register.Mutation, Register.Variables>(
-                REGISTER_ACCOUNT,
-                {
-                    input,
-                },
-            );
+            const { registerCustomerAccount } = await shopClient.query<
+                CodegenShop.RegisterMutation,
+                CodegenShop.RegisterMutationVariables
+            >(REGISTER_ACCOUNT, {
+                input,
+            });
             successErrorGuard.assertSuccess(registerCustomerAccount);
 
             verificationToken = await verificationTokenPromise;
@@ -441,18 +426,18 @@ describe('Shop auth & accounts', () => {
             expect(sendEmailFn).toHaveBeenCalled();
             expect(verificationToken).toBeDefined();
 
-            const { customers } = await adminClient.query<GetCustomerList.Query, GetCustomerList.Variables>(
-                GET_CUSTOMER_LIST,
-                {
-                    options: {
-                        filter: {
-                            emailAddress: {
-                                eq: emailAddress,
-                            },
+            const { customers } = await adminClient.query<
+                Codegen.GetCustomerListQuery,
+                Codegen.GetCustomerListQueryVariables
+            >(GET_CUSTOMER_LIST, {
+                options: {
+                    filter: {
+                        emailAddress: {
+                            eq: emailAddress,
                         },
                     },
                 },
-            );
+            });
 
             expect(
                 pick(customers.items[0], ['firstName', 'lastName', 'emailAddress', 'phoneNumber']),
@@ -466,13 +451,13 @@ describe('Shop auth & accounts', () => {
         });
 
         it('verification fails with password', async () => {
-            const { verifyCustomerAccount } = await shopClient.query<Verify.Mutation, Verify.Variables>(
-                VERIFY_EMAIL,
-                {
-                    token: verificationToken,
-                    password: 'new password',
-                },
-            );
+            const { verifyCustomerAccount } = await shopClient.query<
+                CodegenShop.VerifyMutation,
+                CodegenShop.VerifyMutationVariables
+            >(VERIFY_EMAIL, {
+                token: verificationToken,
+                password: 'new password',
+            });
             currentUserErrorGuard.assertErrorResult(verifyCustomerAccount);
 
             expect(verifyCustomerAccount.message).toBe(`A password has already been set during registration`);
@@ -480,25 +465,30 @@ describe('Shop auth & accounts', () => {
         });
 
         it('verification succeeds with no password and correct token', async () => {
-            const { verifyCustomerAccount } = await shopClient.query<Verify.Mutation, Verify.Variables>(
-                VERIFY_EMAIL,
-                {
-                    token: verificationToken,
-                },
-            );
+            const { verifyCustomerAccount } = await shopClient.query<
+                CodegenShop.VerifyMutation,
+                CodegenShop.VerifyMutationVariables
+            >(VERIFY_EMAIL, {
+                token: verificationToken,
+            });
             currentUserErrorGuard.assertSuccess(verifyCustomerAccount);
 
             expect(verifyCustomerAccount.identifier).toBe('test2@test.com');
-            const { activeCustomer } = await shopClient.query<GetActiveCustomer.Query>(GET_ACTIVE_CUSTOMER);
+            const { activeCustomer } = await shopClient.query<CodegenShop.GetActiveCustomerQuery>(
+                GET_ACTIVE_CUSTOMER,
+            );
         });
     });
 
     describe('password reset', () => {
         let passwordResetToken: string;
-        let customer: GetCustomer.Customer;
+        let customer: Codegen.GetCustomerQuery['customer'];
 
         beforeAll(async () => {
-            const result = await adminClient.query<GetCustomer.Query, GetCustomer.Variables>(GET_CUSTOMER, {
+            const result = await adminClient.query<
+                Codegen.GetCustomerQuery,
+                Codegen.GetCustomerQueryVariables
+            >(GET_CUSTOMER, {
                 id: 'T_1',
             });
             customer = result.customer!;
@@ -510,8 +500,8 @@ describe('Shop auth & accounts', () => {
 
         it('requestPasswordReset silently fails with invalid identifier', async () => {
             const { requestPasswordReset } = await shopClient.query<
-                RequestPasswordReset.Mutation,
-                RequestPasswordReset.Variables
+                CodegenShop.RequestPasswordResetMutation,
+                CodegenShop.RequestPasswordResetMutationVariables
             >(REQUEST_PASSWORD_RESET, {
                 identifier: 'invalid-identifier',
             });
@@ -526,10 +516,10 @@ describe('Shop auth & accounts', () => {
         it('requestPasswordReset sends reset token', async () => {
             const passwordResetTokenPromise = getPasswordResetTokenPromise();
             const { requestPasswordReset } = await shopClient.query<
-                RequestPasswordReset.Mutation,
-                RequestPasswordReset.Variables
+                CodegenShop.RequestPasswordResetMutation,
+                CodegenShop.RequestPasswordResetMutationVariables
             >(REQUEST_PASSWORD_RESET, {
-                identifier: customer.emailAddress,
+                identifier: customer!.emailAddress,
             });
             successErrorGuard.assertSuccess(requestPasswordReset);
 
@@ -541,13 +531,13 @@ describe('Shop auth & accounts', () => {
         });
 
         it('resetPassword returns error result with wrong token', async () => {
-            const { resetPassword } = await shopClient.query<ResetPassword.Mutation, ResetPassword.Variables>(
-                RESET_PASSWORD,
-                {
-                    password: 'newPassword',
-                    token: 'bad-token',
-                },
-            );
+            const { resetPassword } = await shopClient.query<
+                CodegenShop.ResetPasswordMutation,
+                CodegenShop.ResetPasswordMutationVariables
+            >(RESET_PASSWORD, {
+                password: 'newPassword',
+                token: 'bad-token',
+            });
             currentUserErrorGuard.assertErrorResult(resetPassword);
 
             expect(resetPassword.message).toBe(`Password reset token not recognized`);
@@ -555,13 +545,13 @@ describe('Shop auth & accounts', () => {
         });
 
         it('resetPassword fails with invalid password', async () => {
-            const { resetPassword } = await shopClient.query<ResetPassword.Mutation, ResetPassword.Variables>(
-                RESET_PASSWORD,
-                {
-                    token: passwordResetToken,
-                    password: '2short',
-                },
-            );
+            const { resetPassword } = await shopClient.query<
+                CodegenShop.ResetPasswordMutation,
+                CodegenShop.ResetPasswordMutationVariables
+            >(RESET_PASSWORD, {
+                token: passwordResetToken,
+                password: '2short',
+            });
             currentUserErrorGuard.assertErrorResult(resetPassword);
 
             expect(resetPassword.message).toBe(`Password is invalid`);
@@ -572,32 +562,32 @@ describe('Shop auth & accounts', () => {
         });
 
         it('resetPassword works with valid token', async () => {
-            const { resetPassword } = await shopClient.query<ResetPassword.Mutation, ResetPassword.Variables>(
-                RESET_PASSWORD,
-                {
-                    token: passwordResetToken,
-                    password: 'newPassword',
-                },
-            );
+            const { resetPassword } = await shopClient.query<
+                CodegenShop.ResetPasswordMutation,
+                CodegenShop.ResetPasswordMutationVariables
+            >(RESET_PASSWORD, {
+                token: passwordResetToken,
+                password: 'newPassword',
+            });
             currentUserErrorGuard.assertSuccess(resetPassword);
 
-            expect(resetPassword.identifier).toBe(customer.emailAddress);
+            expect(resetPassword.identifier).toBe(customer!.emailAddress);
 
-            const loginResult = await shopClient.asUserWithCredentials(customer.emailAddress, 'newPassword');
-            expect(loginResult.identifier).toBe(customer.emailAddress);
+            const loginResult = await shopClient.asUserWithCredentials(customer!.emailAddress, 'newPassword');
+            expect(loginResult.identifier).toBe(customer!.emailAddress);
         });
 
         it('customer history for password reset', async () => {
-            const result = await adminClient.query<GetCustomerHistory.Query, GetCustomerHistory.Variables>(
-                GET_CUSTOMER_HISTORY,
-                {
-                    id: customer.id,
-                    options: {
-                        // skip CUSTOMER_ADDRESS_CREATED entry
-                        skip: 3,
-                    },
+            const result = await adminClient.query<
+                Codegen.GetCustomerHistoryQuery,
+                Codegen.GetCustomerHistoryQueryVariables
+            >(GET_CUSTOMER_HISTORY, {
+                id: customer!.id,
+                options: {
+                    // skip CUSTOMER_ADDRESS_CREATED entry
+                    skip: 3,
                 },
-            );
+            });
 
             expect(result.customer?.history.items.map(pick(['type', 'data']))).toEqual([
                 {
@@ -614,12 +604,15 @@ describe('Shop auth & accounts', () => {
 
     describe('updating emailAddress', () => {
         let emailUpdateToken: string;
-        let customer: GetCustomer.Customer;
+        let customer: Codegen.GetCustomerQuery['customer'];
         const NEW_EMAIL_ADDRESS = 'new@address.com';
         const PASSWORD = 'newPassword';
 
         beforeAll(async () => {
-            const result = await adminClient.query<GetCustomer.Query, GetCustomer.Variables>(GET_CUSTOMER, {
+            const result = await adminClient.query<
+                Codegen.GetCustomerQuery,
+                Codegen.GetCustomerQueryVariables
+            >(GET_CUSTOMER, {
                 id: 'T_1',
             });
             customer = result.customer!;
@@ -633,8 +626,8 @@ describe('Shop auth & accounts', () => {
             try {
                 await shopClient.asAnonymousUser();
                 await shopClient.query<
-                    RequestUpdateEmailAddress.Mutation,
-                    RequestUpdateEmailAddress.Variables
+                    CodegenShop.RequestUpdateEmailAddressMutation,
+                    CodegenShop.RequestUpdateEmailAddressMutationVariables
                 >(REQUEST_UPDATE_EMAIL_ADDRESS, {
                     password: PASSWORD,
                     newEmailAddress: NEW_EMAIL_ADDRESS,
@@ -646,10 +639,10 @@ describe('Shop auth & accounts', () => {
         });
 
         it('return error result if password is incorrect', async () => {
-            await shopClient.asUserWithCredentials(customer.emailAddress, PASSWORD);
+            await shopClient.asUserWithCredentials(customer!.emailAddress, PASSWORD);
             const { requestUpdateCustomerEmailAddress } = await shopClient.query<
-                RequestUpdateEmailAddress.Mutation,
-                RequestUpdateEmailAddress.Variables
+                CodegenShop.RequestUpdateEmailAddressMutation,
+                CodegenShop.RequestUpdateEmailAddressMutationVariables
             >(REQUEST_UPDATE_EMAIL_ADDRESS, {
                 password: 'bad password',
                 newEmailAddress: NEW_EMAIL_ADDRESS,
@@ -661,15 +654,18 @@ describe('Shop auth & accounts', () => {
         });
 
         it('return error result email address already in use', async () => {
-            await shopClient.asUserWithCredentials(customer.emailAddress, PASSWORD);
-            const result = await adminClient.query<GetCustomer.Query, GetCustomer.Variables>(GET_CUSTOMER, {
+            await shopClient.asUserWithCredentials(customer!.emailAddress, PASSWORD);
+            const result = await adminClient.query<
+                Codegen.GetCustomerQuery,
+                Codegen.GetCustomerQueryVariables
+            >(GET_CUSTOMER, {
                 id: 'T_2',
             });
             const otherCustomer = result.customer!;
 
             const { requestUpdateCustomerEmailAddress } = await shopClient.query<
-                RequestUpdateEmailAddress.Mutation,
-                RequestUpdateEmailAddress.Variables
+                CodegenShop.RequestUpdateEmailAddressMutation,
+                CodegenShop.RequestUpdateEmailAddressMutationVariables
             >(REQUEST_UPDATE_EMAIL_ADDRESS, {
                 password: PASSWORD,
                 newEmailAddress: otherCustomer.emailAddress,
@@ -681,16 +677,16 @@ describe('Shop auth & accounts', () => {
         });
 
         it('triggers event with token', async () => {
-            await shopClient.asUserWithCredentials(customer.emailAddress, PASSWORD);
+            await shopClient.asUserWithCredentials(customer!.emailAddress, PASSWORD);
             const emailUpdateTokenPromise = getEmailUpdateTokenPromise();
 
-            await shopClient.query<RequestUpdateEmailAddress.Mutation, RequestUpdateEmailAddress.Variables>(
-                REQUEST_UPDATE_EMAIL_ADDRESS,
-                {
-                    password: PASSWORD,
-                    newEmailAddress: NEW_EMAIL_ADDRESS,
-                },
-            );
+            await shopClient.query<
+                CodegenShop.RequestUpdateEmailAddressMutation,
+                CodegenShop.RequestUpdateEmailAddressMutationVariables
+            >(REQUEST_UPDATE_EMAIL_ADDRESS, {
+                password: PASSWORD,
+                newEmailAddress: NEW_EMAIL_ADDRESS,
+            });
 
             const { identifierChangeToken, pendingIdentifier } = await emailUpdateTokenPromise;
             emailUpdateToken = identifierChangeToken!;
@@ -707,8 +703,8 @@ describe('Shop auth & accounts', () => {
 
         it('return error result for bad token', async () => {
             const { updateCustomerEmailAddress } = await shopClient.query<
-                UpdateEmailAddress.Mutation,
-                UpdateEmailAddress.Variables
+                CodegenShop.UpdateEmailAddressMutation,
+                CodegenShop.UpdateEmailAddressMutationVariables
             >(UPDATE_EMAIL_ADDRESS, { token: 'bad token' });
             successErrorGuard.assertErrorResult(updateCustomerEmailAddress);
 
@@ -720,8 +716,8 @@ describe('Shop auth & accounts', () => {
 
         it('verify the new email address', async () => {
             const { updateCustomerEmailAddress } = await shopClient.query<
-                UpdateEmailAddress.Mutation,
-                UpdateEmailAddress.Variables
+                CodegenShop.UpdateEmailAddressMutation,
+                CodegenShop.UpdateEmailAddressMutationVariables
             >(UPDATE_EMAIL_ADDRESS, { token: emailUpdateToken });
             successErrorGuard.assertSuccess(updateCustomerEmailAddress);
 
@@ -737,27 +733,29 @@ describe('Shop auth & accounts', () => {
 
         it('can login with new email address after verification', async () => {
             await shopClient.asUserWithCredentials(NEW_EMAIL_ADDRESS, PASSWORD);
-            const { activeCustomer } = await shopClient.query<GetActiveCustomer.Query>(GET_ACTIVE_CUSTOMER);
-            expect(activeCustomer!.id).toBe(customer.id);
+            const { activeCustomer } = await shopClient.query<CodegenShop.GetActiveCustomerQuery>(
+                GET_ACTIVE_CUSTOMER,
+            );
+            expect(activeCustomer!.id).toBe(customer!.id);
             expect(activeCustomer!.emailAddress).toBe(NEW_EMAIL_ADDRESS);
         });
 
         it('cannot login with old email address after verification', async () => {
-            const result = await shopClient.asUserWithCredentials(customer.emailAddress, PASSWORD);
+            const result = await shopClient.asUserWithCredentials(customer!.emailAddress, PASSWORD);
 
             expect(result.errorCode).toBe(ErrorCode.INVALID_CREDENTIALS_ERROR);
         });
 
         it('customer history for email update', async () => {
-            const result = await adminClient.query<GetCustomerHistory.Query, GetCustomerHistory.Variables>(
-                GET_CUSTOMER_HISTORY,
-                {
-                    id: customer.id,
-                    options: {
-                        skip: 5,
-                    },
+            const result = await adminClient.query<
+                Codegen.GetCustomerHistoryQuery,
+                Codegen.GetCustomerHistoryQueryVariables
+            >(GET_CUSTOMER_HISTORY, {
+                id: customer!.id,
+                options: {
+                    skip: 5,
                 },
-            );
+            });
 
             expect(result.customer?.history.items.map(pick(['type', 'data']))).toEqual([
                 {
@@ -809,7 +807,10 @@ describe('Shop auth & accounts', () => {
         code: string,
         permissions: Permission[],
     ): Promise<{ identifier: string; password: string }> {
-        const roleResult = await shopClient.query<CreateRole.Mutation, CreateRole.Variables>(CREATE_ROLE, {
+        const roleResult = await shopClient.query<
+            Codegen.CreateRoleMutation,
+            Codegen.CreateRoleMutationVariables
+        >(CREATE_ROLE, {
             input: {
                 code,
                 description: '',
@@ -823,8 +824,8 @@ describe('Shop auth & accounts', () => {
         const password = `test`;
 
         const adminResult = await shopClient.query<
-            CreateAdministrator.Mutation,
-            CreateAdministrator.Variables
+            Codegen.CreateAdministratorMutation,
+            Codegen.CreateAdministratorMutationVariables
         >(CREATE_ADMINISTRATOR, {
             input: {
                 emailAddress: identifier,
@@ -884,12 +885,12 @@ describe('Expiring tokens', () => {
             lastName: 'Wallace',
             emailAddress: 'barry.wallace@test.com',
         };
-        const { registerCustomerAccount } = await shopClient.query<Register.Mutation, Register.Variables>(
-            REGISTER_ACCOUNT,
-            {
-                input,
-            },
-        );
+        const { registerCustomerAccount } = await shopClient.query<
+            CodegenShop.RegisterMutation,
+            CodegenShop.RegisterMutationVariables
+        >(REGISTER_ACCOUNT, {
+            input,
+        });
         successErrorGuard.assertSuccess(registerCustomerAccount);
 
         const verificationToken = await verificationTokenPromise;
@@ -900,13 +901,13 @@ describe('Expiring tokens', () => {
 
         await new Promise(resolve => setTimeout(resolve, 3));
 
-        const { verifyCustomerAccount } = await shopClient.query<Verify.Mutation, Verify.Variables>(
-            VERIFY_EMAIL,
-            {
-                password: 'test',
-                token: verificationToken,
-            },
-        );
+        const { verifyCustomerAccount } = await shopClient.query<
+            CodegenShop.VerifyMutation,
+            CodegenShop.VerifyMutationVariables
+        >(VERIFY_EMAIL, {
+            password: 'test',
+            token: verificationToken,
+        });
         currentUserErrorGuard.assertErrorResult(verifyCustomerAccount);
 
         expect(verifyCustomerAccount.message).toBe(
@@ -916,14 +917,17 @@ describe('Expiring tokens', () => {
     });
 
     it('attempting to reset password after token has expired returns error result', async () => {
-        const { customer } = await adminClient.query<GetCustomer.Query, GetCustomer.Variables>(GET_CUSTOMER, {
+        const { customer } = await adminClient.query<
+            Codegen.GetCustomerQuery,
+            Codegen.GetCustomerQueryVariables
+        >(GET_CUSTOMER, {
             id: 'T_1',
         });
 
         const passwordResetTokenPromise = getPasswordResetTokenPromise();
         const { requestPasswordReset } = await shopClient.query<
-            RequestPasswordReset.Mutation,
-            RequestPasswordReset.Variables
+            CodegenShop.RequestPasswordResetMutation,
+            CodegenShop.RequestPasswordResetMutationVariables
         >(REQUEST_PASSWORD_RESET, {
             identifier: customer!.emailAddress,
         });
@@ -937,13 +941,13 @@ describe('Expiring tokens', () => {
 
         await new Promise(resolve => setTimeout(resolve, 3));
 
-        const { resetPassword } = await shopClient.query<ResetPassword.Mutation, ResetPassword.Variables>(
-            RESET_PASSWORD,
-            {
-                password: 'test',
-                token: passwordResetToken,
-            },
-        );
+        const { resetPassword } = await shopClient.query<
+            CodegenShop.ResetPasswordMutation,
+            CodegenShop.ResetPasswordMutationVariables
+        >(RESET_PASSWORD, {
+            password: 'test',
+            token: passwordResetToken,
+        });
 
         currentUserErrorGuard.assertErrorResult(resetPassword);
 
@@ -985,12 +989,12 @@ describe('Registration without email verification', () => {
             lastName: 'Beardsley',
             emailAddress: userEmailAddress,
         };
-        const { registerCustomerAccount } = await shopClient.query<Register.Mutation, Register.Variables>(
-            REGISTER_ACCOUNT,
-            {
-                input,
-            },
-        );
+        const { registerCustomerAccount } = await shopClient.query<
+            CodegenShop.RegisterMutation,
+            CodegenShop.RegisterMutationVariables
+        >(REGISTER_ACCOUNT, {
+            input,
+        });
         successErrorGuard.assertErrorResult(registerCustomerAccount);
 
         expect(registerCustomerAccount.message).toBe('A password must be provided.');
@@ -1004,12 +1008,12 @@ describe('Registration without email verification', () => {
             emailAddress: userEmailAddress,
             password: 'test',
         };
-        const { registerCustomerAccount } = await shopClient.query<Register.Mutation, Register.Variables>(
-            REGISTER_ACCOUNT,
-            {
-                input,
-            },
-        );
+        const { registerCustomerAccount } = await shopClient.query<
+            CodegenShop.RegisterMutation,
+            CodegenShop.RegisterMutationVariables
+        >(REGISTER_ACCOUNT, {
+            input,
+        });
         successErrorGuard.assertSuccess(registerCustomerAccount);
 
         expect(registerCustomerAccount.success).toBe(true);
@@ -1041,7 +1045,7 @@ describe('Updating email address without email verification', () => {
             },
         }),
     );
-    let customer: GetCustomer.Customer;
+    let customer: Codegen.GetCustomerQuery['customer'];
     const NEW_EMAIL_ADDRESS = 'new@address.com';
 
     beforeAll(async () => {
@@ -1051,9 +1055,12 @@ describe('Updating email address without email verification', () => {
             customerCount: 1,
         });
         await adminClient.asSuperAdmin();
-        const result = await adminClient.query<GetCustomer.Query, GetCustomer.Variables>(GET_CUSTOMER, {
-            id: 'T_1',
-        });
+        const result = await adminClient.query<Codegen.GetCustomerQuery, Codegen.GetCustomerQueryVariables>(
+            GET_CUSTOMER,
+            {
+                id: 'T_1',
+            },
+        );
         customer = result.customer!;
     }, TEST_SETUP_TIMEOUT_MS);
 
@@ -1066,10 +1073,10 @@ describe('Updating email address without email verification', () => {
     });
 
     it('updates email address', async () => {
-        await shopClient.asUserWithCredentials(customer.emailAddress, 'test');
+        await shopClient.asUserWithCredentials(customer!.emailAddress, 'test');
         const { requestUpdateCustomerEmailAddress } = await shopClient.query<
-            RequestUpdateEmailAddress.Mutation,
-            RequestUpdateEmailAddress.Variables
+            CodegenShop.RequestUpdateEmailAddressMutation,
+            CodegenShop.RequestUpdateEmailAddressMutationVariables
         >(REQUEST_UPDATE_EMAIL_ADDRESS, {
             password: 'test',
             newEmailAddress: NEW_EMAIL_ADDRESS,
@@ -1080,7 +1087,9 @@ describe('Updating email address without email verification', () => {
         expect(sendEmailFn).toHaveBeenCalledTimes(1);
         expect(sendEmailFn.mock.calls[0][0] instanceof IdentifierChangeEvent).toBe(true);
 
-        const { activeCustomer } = await shopClient.query<GetActiveCustomer.Query>(GET_ACTIVE_CUSTOMER);
+        const { activeCustomer } = await shopClient.query<CodegenShop.GetActiveCustomerQuery>(
+            GET_ACTIVE_CUSTOMER,
+        );
         expect(activeCustomer!.emailAddress).toBe(NEW_EMAIL_ADDRESS);
     });
 });

+ 136 - 147
packages/core/e2e/shop-catalog.e2e-spec.ts

@@ -7,28 +7,8 @@ import path from 'path';
 import { initialData } from '../../../e2e-common/e2e-initial-data';
 import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
 
-import {
-    CreateCollection,
-    CreateFacet,
-    DisableProduct,
-    FacetWithValues,
-    GetCollection,
-    GetCollectionList,
-    GetCollectionVariants,
-    GetFacetList,
-    GetProduct1,
-    GetProduct2Variants,
-    GetProductCollection,
-    GetProductFacetValues,
-    GetProductSimple,
-    GetProductsTake3,
-    GetProductWithVariants,
-    GetVariantFacetValues,
-    LanguageCode,
-    UpdateCollection,
-    UpdateProduct,
-    UpdateProductVariants,
-} from './graphql/generated-e2e-admin-types';
+import { LanguageCode } from './graphql/generated-e2e-admin-types';
+import * as Codegen from './graphql/generated-e2e-admin-types';
 import {
     CREATE_COLLECTION,
     CREATE_FACET,
@@ -61,33 +41,36 @@ describe('Shop catalog', () => {
     describe('products', () => {
         beforeAll(async () => {
             // disable the first product
-            await adminClient.query<DisableProduct.Mutation, DisableProduct.Variables>(DISABLE_PRODUCT, {
-                id: 'T_1',
-            });
+            await adminClient.query<Codegen.DisableProductMutation, Codegen.DisableProductMutationVariables>(
+                DISABLE_PRODUCT,
+                {
+                    id: 'T_1',
+                },
+            );
 
             const monitorProduct = await adminClient.query<
-                GetProductWithVariants.Query,
-                GetProductWithVariants.Variables
+                Codegen.GetProductWithVariantsQuery,
+                Codegen.GetProductWithVariantsQueryVariables
             >(GET_PRODUCT_WITH_VARIANTS, {
                 id: 'T_2',
             });
             if (monitorProduct.product) {
-                await adminClient.query<UpdateProductVariants.Mutation, UpdateProductVariants.Variables>(
-                    UPDATE_PRODUCT_VARIANTS,
-                    {
-                        input: [
-                            {
-                                id: monitorProduct.product.variants[0].id,
-                                enabled: false,
-                            },
-                        ],
-                    },
-                );
+                await adminClient.query<
+                    Codegen.UpdateProductVariantsMutation,
+                    Codegen.UpdateProductVariantsMutationVariables
+                >(UPDATE_PRODUCT_VARIANTS, {
+                    input: [
+                        {
+                            id: monitorProduct.product.variants[0].id,
+                            enabled: false,
+                        },
+                    ],
+                });
             }
         });
 
         it('products list omits disabled products', async () => {
-            const result = await shopClient.query<GetProductsTake3.Query>(gql`
+            const result = await shopClient.query<Codegen.GetProductsTake3Query>(gql`
                 query GetProductsTake3 {
                     products(options: { take: 3 }) {
                         items {
@@ -101,10 +84,10 @@ describe('Shop catalog', () => {
         });
 
         it('by id', async () => {
-            const { product } = await shopClient.query<GetProductSimple.Query, GetProductSimple.Variables>(
-                GET_PRODUCT_SIMPLE,
-                { id: 'T_2' },
-            );
+            const { product } = await shopClient.query<
+                Codegen.GetProductSimpleQuery,
+                Codegen.GetProductSimpleQueryVariables
+            >(GET_PRODUCT_SIMPLE, { id: 'T_2' });
 
             if (!product) {
                 fail('Product not found');
@@ -114,10 +97,10 @@ describe('Shop catalog', () => {
         });
 
         it('by slug', async () => {
-            const { product } = await shopClient.query<GetProductSimple.Query, GetProductSimple.Variables>(
-                GET_PRODUCT_SIMPLE,
-                { slug: 'curvy-monitor' },
-            );
+            const { product } = await shopClient.query<
+                Codegen.GetProductSimpleQuery,
+                Codegen.GetProductSimpleQueryVariables
+            >(GET_PRODUCT_SIMPLE, { slug: 'curvy-monitor' });
 
             if (!product) {
                 fail('Product not found');
@@ -129,7 +112,7 @@ describe('Shop catalog', () => {
         it(
             'throws if neither id nor slug provided',
             assertThrowsWithMessage(async () => {
-                await shopClient.query<GetProductSimple.Query, GetProductSimple.Variables>(
+                await shopClient.query<Codegen.GetProductSimpleQuery, Codegen.GetProductSimpleQueryVariables>(
                     GET_PRODUCT_SIMPLE,
                     {},
                 );
@@ -137,7 +120,7 @@ describe('Shop catalog', () => {
         );
 
         it('product returns null for disabled product', async () => {
-            const result = await shopClient.query<GetProduct1.Query>(gql`
+            const result = await shopClient.query<Codegen.GetProduct1Query>(gql`
                 query GetProduct1 {
                     product(id: "T_1") {
                         id
@@ -149,7 +132,7 @@ describe('Shop catalog', () => {
         });
 
         it('omits disabled variants from product response', async () => {
-            const result = await shopClient.query<GetProduct2Variants.Query>(gql`
+            const result = await shopClient.query<Codegen.GetProduct2VariantsQuery>(gql`
                 query GetProduct2Variants {
                     product(id: "T_2") {
                         id
@@ -166,51 +149,54 @@ describe('Shop catalog', () => {
     });
 
     describe('facets', () => {
-        let facetValue: FacetWithValues.Values;
+        let facetValue: Codegen.FacetWithValuesFragment;
 
         beforeAll(async () => {
-            const result = await adminClient.query<CreateFacet.Mutation, CreateFacet.Variables>(
-                CREATE_FACET,
-                {
-                    input: {
-                        code: 'profit-margin',
-                        isPrivate: true,
-                        translations: [{ languageCode: LanguageCode.en, name: 'Profit Margin' }],
-                        values: [
-                            {
-                                code: 'massive',
-                                translations: [{ languageCode: LanguageCode.en, name: 'massive' }],
-                            },
-                        ],
-                    },
-                },
-            );
-            facetValue = result.createFacet.values[0];
-
-            await adminClient.query<UpdateProduct.Mutation, UpdateProduct.Variables>(UPDATE_PRODUCT, {
+            const result = await adminClient.query<
+                Codegen.CreateFacetMutation,
+                Codegen.CreateFacetMutationVariables
+            >(CREATE_FACET, {
                 input: {
-                    id: 'T_2',
-                    facetValueIds: [facetValue.id],
+                    code: 'profit-margin',
+                    isPrivate: true,
+                    translations: [{ languageCode: LanguageCode.en, name: 'Profit Margin' }],
+                    values: [
+                        {
+                            code: 'massive',
+                            translations: [{ languageCode: LanguageCode.en, name: 'massive' }],
+                        },
+                    ],
                 },
             });
+            facetValue = result.createFacet.values[0];
 
-            await adminClient.query<UpdateProductVariants.Mutation, UpdateProductVariants.Variables>(
-                UPDATE_PRODUCT_VARIANTS,
+            await adminClient.query<Codegen.UpdateProductMutation, Codegen.UpdateProductMutationVariables>(
+                UPDATE_PRODUCT,
                 {
-                    input: [
-                        {
-                            id: 'T_6',
-                            facetValueIds: [facetValue.id],
-                        },
-                    ],
+                    input: {
+                        id: 'T_2',
+                        facetValueIds: [facetValue.id],
+                    },
                 },
             );
+
+            await adminClient.query<
+                Codegen.UpdateProductVariantsMutation,
+                Codegen.UpdateProductVariantsMutationVariables
+            >(UPDATE_PRODUCT_VARIANTS, {
+                input: [
+                    {
+                        id: 'T_6',
+                        facetValueIds: [facetValue.id],
+                    },
+                ],
+            });
         });
 
         it('omits private Product.facetValues', async () => {
             const result = await shopClient.query<
-                GetProductFacetValues.Query,
-                GetProductFacetValues.Variables
+                Codegen.GetProductFacetValuesQuery,
+                Codegen.GetProductFacetValuesQueryVariables
             >(GET_PRODUCT_FACET_VALUES, {
                 id: 'T_2',
             });
@@ -220,8 +206,8 @@ describe('Shop catalog', () => {
 
         it('omits private ProductVariant.facetValues', async () => {
             const result = await shopClient.query<
-                GetVariantFacetValues.Query,
-                GetVariantFacetValues.Variables
+                Codegen.GetVariantFacetValuesQuery,
+                Codegen.GetVariantFacetValuesQueryVariables
             >(GET_PRODUCT_VARIANT_FACET_VALUES, {
                 id: 'T_2',
             });
@@ -231,36 +217,36 @@ describe('Shop catalog', () => {
     });
 
     describe('collections', () => {
-        let collection: CreateCollection.CreateCollection;
+        let collection: Codegen.CreateCollectionMutation['createCollection'];
 
         async function createNewCollection(name: string, isPrivate: boolean, parentId?: string) {
-            return await adminClient.query<CreateCollection.Mutation, CreateCollection.Variables>(
-                CREATE_COLLECTION,
-                {
-                    input: {
-                        translations: [
-                            {
-                                languageCode: LanguageCode.en,
-                                name,
-                                description: '',
-                                slug: name,
-                            },
-                        ],
-                        isPrivate,
-                        parentId,
-                        filters: [],
-                    },
+            return await adminClient.query<
+                Codegen.CreateCollectionMutation,
+                Codegen.CreateCollectionMutationVariables
+            >(CREATE_COLLECTION, {
+                input: {
+                    translations: [
+                        {
+                            languageCode: LanguageCode.en,
+                            name,
+                            description: '',
+                            slug: name,
+                        },
+                    ],
+                    isPrivate,
+                    parentId,
+                    filters: [],
                 },
-            );
+            });
         }
 
         beforeAll(async () => {
-            const result = await adminClient.query<GetFacetList.Query>(GET_FACET_LIST);
+            const result = await adminClient.query<Codegen.GetFacetListQuery>(GET_FACET_LIST);
             const category = result.facets.items[0];
             const sportsEquipment = category.values.find(v => v.code === 'sports-equipment')!;
             const { createCollection } = await adminClient.query<
-                CreateCollection.Mutation,
-                CreateCollection.Variables
+                Codegen.CreateCollectionMutation,
+                Codegen.CreateCollectionMutationVariables
             >(CREATE_COLLECTION, {
                 input: {
                     filters: [
@@ -294,8 +280,8 @@ describe('Shop catalog', () => {
 
         it('returns collection with variants', async () => {
             const result = await shopClient.query<
-                GetCollectionVariants.Query,
-                GetCollectionVariants.Variables
+                Codegen.GetCollectionVariantsQuery,
+                Codegen.GetCollectionVariantsQueryVariables
             >(GET_COLLECTION_VARIANTS, { id: collection.id });
             expect(result.collection!.productVariants.items).toEqual([
                 { id: 'T_22', name: 'Road Bike' },
@@ -313,21 +299,24 @@ describe('Shop catalog', () => {
 
         it('collection by slug', async () => {
             const result = await shopClient.query<
-                GetCollectionVariants.Query,
-                GetCollectionVariants.Variables
+                Codegen.GetCollectionVariantsQuery,
+                Codegen.GetCollectionVariantsQueryVariables
             >(GET_COLLECTION_VARIANTS, { slug: collection.slug });
             expect(result.collection?.id).toBe(collection.id);
         });
 
         it('omits variants from disabled products', async () => {
-            await adminClient.query<DisableProduct.Mutation, DisableProduct.Variables>(DISABLE_PRODUCT, {
-                id: 'T_17',
-            });
+            await adminClient.query<Codegen.DisableProductMutation, Codegen.DisableProductMutationVariables>(
+                DISABLE_PRODUCT,
+                {
+                    id: 'T_17',
+                },
+            );
             await awaitRunningJobs(adminClient);
 
             const result = await shopClient.query<
-                GetCollectionVariants.Query,
-                GetCollectionVariants.Variables
+                Codegen.GetCollectionVariantsQuery,
+                Codegen.GetCollectionVariantsQueryVariables
             >(GET_COLLECTION_VARIANTS, { id: collection.id });
             expect(result.collection!.productVariants.items).toEqual([
                 { id: 'T_22', name: 'Road Bike' },
@@ -340,17 +329,17 @@ describe('Shop catalog', () => {
         });
 
         it('omits disabled product variants', async () => {
-            await adminClient.query<UpdateProductVariants.Mutation, UpdateProductVariants.Variables>(
-                UPDATE_PRODUCT_VARIANTS,
-                {
-                    input: [{ id: 'T_22', enabled: false }],
-                },
-            );
+            await adminClient.query<
+                Codegen.UpdateProductVariantsMutation,
+                Codegen.UpdateProductVariantsMutationVariables
+            >(UPDATE_PRODUCT_VARIANTS, {
+                input: [{ id: 'T_22', enabled: false }],
+            });
             await awaitRunningJobs(adminClient);
 
             const result = await shopClient.query<
-                GetCollectionVariants.Query,
-                GetCollectionVariants.Variables
+                Codegen.GetCollectionVariantsQuery,
+                Codegen.GetCollectionVariantsQueryVariables
             >(GET_COLLECTION_VARIANTS, { id: collection.id });
             expect(result.collection!.productVariants.items).toEqual([
                 { id: 'T_23', name: 'Skipping Rope' },
@@ -362,7 +351,7 @@ describe('Shop catalog', () => {
         });
 
         it('collection list', async () => {
-            const result = await shopClient.query<GetCollectionList.Query>(GET_COLLECTION_LIST);
+            const result = await shopClient.query<Codegen.GetCollectionListQuery>(GET_COLLECTION_LIST);
 
             expect(result.collections.items).toEqual([
                 { id: 'T_2', name: 'Plants' },
@@ -371,32 +360,32 @@ describe('Shop catalog', () => {
         });
 
         it('omits private collections', async () => {
-            await adminClient.query<UpdateCollection.Mutation, UpdateCollection.Variables>(
-                UPDATE_COLLECTION,
-                {
-                    input: {
-                        id: collection.id,
-                        isPrivate: true,
-                    },
+            await adminClient.query<
+                Codegen.UpdateCollectionMutation,
+                Codegen.UpdateCollectionMutationVariables
+            >(UPDATE_COLLECTION, {
+                input: {
+                    id: collection.id,
+                    isPrivate: true,
                 },
-            );
+            });
             await awaitRunningJobs(adminClient);
-            const result = await shopClient.query<GetCollectionList.Query>(GET_COLLECTION_LIST);
+            const result = await shopClient.query<Codegen.GetCollectionListQuery>(GET_COLLECTION_LIST);
 
             expect(result.collections.items).toEqual([{ id: 'T_2', name: 'Plants' }]);
         });
 
         it('returns null for private collection', async () => {
             const result = await shopClient.query<
-                GetCollectionVariants.Query,
-                GetCollectionVariants.Variables
+                Codegen.GetCollectionVariantsQuery,
+                Codegen.GetCollectionVariantsQueryVariables
             >(GET_COLLECTION_VARIANTS, { id: collection.id });
 
             expect(result.collection).toBeNull();
         });
 
         it('product.collections list omits private collections', async () => {
-            const result = await shopClient.query<GetProductCollection.Query>(gql`
+            const result = await shopClient.query<Codegen.GetProductCollectionQuery>(gql`
                 query GetProductCollection {
                     product(id: "T_12") {
                         collections {
@@ -414,12 +403,12 @@ describe('Shop catalog', () => {
             const { createCollection: parent } = await createNewCollection('public-parent', false);
             const { createCollection: child } = await createNewCollection('private-child', true, parent.id);
 
-            const result = await shopClient.query<GetCollection.Query, GetCollection.Variables>(
-                GET_COLLECTION_SHOP,
-                {
-                    id: parent.id,
-                },
-            );
+            const result = await shopClient.query<
+                Codegen.GetCollectionQuery,
+                Codegen.GetCollectionQueryVariables
+            >(GET_COLLECTION_SHOP, {
+                id: parent.id,
+            });
 
             expect(result.collection?.children).toEqual([]);
         });
@@ -428,12 +417,12 @@ describe('Shop catalog', () => {
             const { createCollection: parent } = await createNewCollection('private-parent', true);
             const { createCollection: child } = await createNewCollection('public-child', false, parent.id);
 
-            const result = await shopClient.query<GetCollection.Query, GetCollection.Variables>(
-                GET_COLLECTION_SHOP,
-                {
-                    id: child.id,
-                },
-            );
+            const result = await shopClient.query<
+                Codegen.GetCollectionQuery,
+                Codegen.GetCollectionQueryVariables
+            >(GET_COLLECTION_SHOP, {
+                id: child.id,
+            });
 
             expect(result.collection?.parent).toBeNull();
         });

+ 92 - 89
packages/core/e2e/shop-customer.e2e-spec.ts

@@ -3,29 +3,14 @@ import { pick } from '@vendure/common/lib/pick';
 import { createErrorResultGuard, createTestEnvironment, ErrorResultGuard } from '@vendure/testing';
 import gql from 'graphql-tag';
 import path from 'path';
-import { skip } from 'rxjs/operators';
 
 import { initialData } from '../../../e2e-common/e2e-initial-data';
 import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
 
-import {
-    AttemptLogin,
-    GetCustomer,
-    GetCustomerHistory,
-    GetCustomerIds,
-    HistoryEntryType,
-} from './graphql/generated-e2e-admin-types';
-import {
-    CreateAddressInput,
-    CreateAddressShop,
-    DeleteAddressShop,
-    ErrorCode,
-    UpdateAddressInput,
-    UpdateAddressShop,
-    UpdateCustomer,
-    UpdateCustomerInput,
-    UpdatePassword,
-} from './graphql/generated-e2e-shop-types';
+import * as Codegen from './graphql/generated-e2e-admin-types';
+import { HistoryEntryType } from './graphql/generated-e2e-admin-types';
+import * as CodegenShop from './graphql/generated-e2e-shop-types';
+import { CreateAddressInput, ErrorCode, UpdateAddressInput } from './graphql/generated-e2e-shop-types';
 import { ATTEMPT_LOGIN, GET_CUSTOMER, GET_CUSTOMER_HISTORY } from './graphql/shared-definitions';
 import {
     CREATE_ADDRESS,
@@ -38,7 +23,7 @@ import { assertThrowsWithMessage } from './utils/assert-throws-with-message';
 
 describe('Shop customers', () => {
     const { server, adminClient, shopClient } = createTestEnvironment(testConfig());
-    let customer: GetCustomer.Customer;
+    let customer: NonNullable<Codegen.GetCustomerQuery['customer']>;
 
     const successErrorGuard: ErrorResultGuard<{ success: boolean }> = createErrorResultGuard(
         input => input.success != null,
@@ -53,7 +38,7 @@ describe('Shop customers', () => {
         await adminClient.asSuperAdmin();
 
         // Fetch the first Customer and store it as the `customer` variable.
-        const { customers } = await adminClient.query<GetCustomerIds.Query>(gql`
+        const { customers } = await adminClient.query<Codegen.GetCustomerIdsQuery>(gql`
             query GetCustomerIds {
                 customers {
                     items {
@@ -62,9 +47,12 @@ describe('Shop customers', () => {
                 }
             }
         `);
-        const result = await adminClient.query<GetCustomer.Query, GetCustomer.Variables>(GET_CUSTOMER, {
-            id: customers.items[0].id,
-        });
+        const result = await adminClient.query<Codegen.GetCustomerQuery, Codegen.GetCustomerQueryVariables>(
+            GET_CUSTOMER,
+            {
+                id: customers.items[0].id,
+            },
+        );
         customer = result.customer!;
     }, TEST_SETUP_TIMEOUT_MS);
 
@@ -75,10 +63,13 @@ describe('Shop customers', () => {
     it(
         'updateCustomer throws if not logged in',
         assertThrowsWithMessage(async () => {
-            const input: UpdateCustomerInput = {
+            const input: CodegenShop.UpdateCustomerInput = {
                 firstName: 'xyz',
             };
-            await shopClient.query<UpdateCustomer.Mutation, UpdateCustomer.Variables>(UPDATE_CUSTOMER, {
+            await shopClient.query<
+                CodegenShop.UpdateCustomerMutation,
+                CodegenShop.UpdateCustomerMutationVariables
+            >(UPDATE_CUSTOMER, {
                 input,
             });
         }, 'You are not currently authorized to perform this action'),
@@ -91,7 +82,10 @@ describe('Shop customers', () => {
                 streetLine1: '1 Test Street',
                 countryCode: 'GB',
             };
-            await shopClient.query<CreateAddressShop.Mutation, CreateAddressShop.Variables>(CREATE_ADDRESS, {
+            await shopClient.query<
+                CodegenShop.CreateAddressShopMutation,
+                CodegenShop.CreateAddressShopMutationVariables
+            >(CREATE_ADDRESS, {
                 input,
             });
         }, 'You are not currently authorized to perform this action'),
@@ -104,7 +98,10 @@ describe('Shop customers', () => {
                 id: 'T_1',
                 streetLine1: 'zxc',
             };
-            await shopClient.query<UpdateAddressShop.Mutation, UpdateAddressShop.Variables>(UPDATE_ADDRESS, {
+            await shopClient.query<
+                CodegenShop.UpdateAddressShopMutation,
+                CodegenShop.UpdateAddressShopMutationVariables
+            >(UPDATE_ADDRESS, {
                 input,
             });
         }, 'You are not currently authorized to perform this action'),
@@ -113,7 +110,10 @@ describe('Shop customers', () => {
     it(
         'deleteCustomerAddress throws if not logged in',
         assertThrowsWithMessage(async () => {
-            await shopClient.query<DeleteAddressShop.Mutation, DeleteAddressShop.Variables>(DELETE_ADDRESS, {
+            await shopClient.query<
+                CodegenShop.DeleteAddressShopMutation,
+                CodegenShop.DeleteAddressShopMutationVariables
+            >(DELETE_ADDRESS, {
                 id: 'T_1',
             });
         }, 'You are not currently authorized to perform this action'),
@@ -123,36 +123,39 @@ describe('Shop customers', () => {
         let addressId: string;
 
         beforeAll(async () => {
-            await shopClient.query<AttemptLogin.Mutation, AttemptLogin.Variables>(ATTEMPT_LOGIN, {
-                username: customer.emailAddress,
-                password: 'test',
-                rememberMe: false,
-            });
+            await shopClient.query<Codegen.AttemptLoginMutation, Codegen.AttemptLoginMutationVariables>(
+                ATTEMPT_LOGIN,
+                {
+                    username: customer.emailAddress,
+                    password: 'test',
+                    rememberMe: false,
+                },
+            );
         });
 
         it('updateCustomer works', async () => {
-            const input: UpdateCustomerInput = {
+            const input: CodegenShop.UpdateCustomerInput = {
                 firstName: 'xyz',
             };
-            const result = await shopClient.query<UpdateCustomer.Mutation, UpdateCustomer.Variables>(
-                UPDATE_CUSTOMER,
-                { input },
-            );
+            const result = await shopClient.query<
+                CodegenShop.UpdateCustomerMutation,
+                CodegenShop.UpdateCustomerMutationVariables
+            >(UPDATE_CUSTOMER, { input });
 
             expect(result.updateCustomer.firstName).toBe('xyz');
         });
 
         it('customer history for CUSTOMER_DETAIL_UPDATED', async () => {
-            const result = await adminClient.query<GetCustomerHistory.Query, GetCustomerHistory.Variables>(
-                GET_CUSTOMER_HISTORY,
-                {
-                    id: customer.id,
-                    options: {
-                        // skip populated CUSTOMER_ADDRESS_CREATED entry
-                        skip: 3,
-                    },
+            const result = await adminClient.query<
+                Codegen.GetCustomerHistoryQuery,
+                Codegen.GetCustomerHistoryQueryVariables
+            >(GET_CUSTOMER_HISTORY, {
+                id: customer.id,
+                options: {
+                    // skip populated CUSTOMER_ADDRESS_CREATED entry
+                    skip: 3,
                 },
-            );
+            });
 
             expect(result.customer?.history.items.map(pick(['type', 'data']))).toEqual([
                 {
@@ -170,8 +173,8 @@ describe('Shop customers', () => {
                 countryCode: 'GB',
             };
             const { createCustomerAddress } = await shopClient.query<
-                CreateAddressShop.Mutation,
-                CreateAddressShop.Variables
+                CodegenShop.CreateAddressShopMutation,
+                CodegenShop.CreateAddressShopMutationVariables
             >(CREATE_ADDRESS, { input });
 
             expect(createCustomerAddress).toEqual({
@@ -185,16 +188,16 @@ describe('Shop customers', () => {
         });
 
         it('customer history for CUSTOMER_ADDRESS_CREATED', async () => {
-            const result = await adminClient.query<GetCustomerHistory.Query, GetCustomerHistory.Variables>(
-                GET_CUSTOMER_HISTORY,
-                {
-                    id: customer.id,
-                    options: {
-                        // skip populated CUSTOMER_ADDRESS_CREATED, CUSTOMER_DETAIL_UPDATED entries
-                        skip: 4,
-                    },
+            const result = await adminClient.query<
+                Codegen.GetCustomerHistoryQuery,
+                Codegen.GetCustomerHistoryQueryVariables
+            >(GET_CUSTOMER_HISTORY, {
+                id: customer.id,
+                options: {
+                    // skip populated CUSTOMER_ADDRESS_CREATED, CUSTOMER_DETAIL_UPDATED entries
+                    skip: 4,
                 },
-            );
+            });
 
             expect(result.customer?.history.items.map(pick(['type', 'data']))).toEqual([
                 {
@@ -212,20 +215,20 @@ describe('Shop customers', () => {
                 streetLine1: '5 Test Street',
                 countryCode: 'AT',
             };
-            const result = await shopClient.query<UpdateAddressShop.Mutation, UpdateAddressShop.Variables>(
-                UPDATE_ADDRESS,
-                { input },
-            );
+            const result = await shopClient.query<
+                CodegenShop.UpdateAddressShopMutation,
+                CodegenShop.UpdateAddressShopMutationVariables
+            >(UPDATE_ADDRESS, { input });
 
             expect(result.updateCustomerAddress.streetLine1).toEqual('5 Test Street');
             expect(result.updateCustomerAddress.country.code).toEqual('AT');
         });
 
         it('customer history for CUSTOMER_ADDRESS_UPDATED', async () => {
-            const result = await adminClient.query<GetCustomerHistory.Query, GetCustomerHistory.Variables>(
-                GET_CUSTOMER_HISTORY,
-                { id: customer.id, options: { skip: 5 } },
-            );
+            const result = await adminClient.query<
+                Codegen.GetCustomerHistoryQuery,
+                Codegen.GetCustomerHistoryQueryVariables
+            >(GET_CUSTOMER_HISTORY, { id: customer.id, options: { skip: 5 } });
 
             expect(result.customer?.history.items.map(pick(['type', 'data']))).toEqual([
                 {
@@ -249,27 +252,27 @@ describe('Shop customers', () => {
                     id: 'T_2',
                     streetLine1: '1 Test Street',
                 };
-                await shopClient.query<UpdateAddressShop.Mutation, UpdateAddressShop.Variables>(
-                    UPDATE_ADDRESS,
-                    { input },
-                );
+                await shopClient.query<
+                    CodegenShop.UpdateAddressShopMutation,
+                    CodegenShop.UpdateAddressShopMutationVariables
+                >(UPDATE_ADDRESS, { input });
             }, 'You are not currently authorized to perform this action'),
         );
 
         it('deleteCustomerAddress works', async () => {
             const { deleteCustomerAddress } = await shopClient.query<
-                DeleteAddressShop.Mutation,
-                DeleteAddressShop.Variables
+                CodegenShop.DeleteAddressShopMutation,
+                CodegenShop.DeleteAddressShopMutationVariables
             >(DELETE_ADDRESS, { id: 'T_3' });
 
             expect(deleteCustomerAddress.success).toBe(true);
         });
 
         it('customer history for CUSTOMER_ADDRESS_DELETED', async () => {
-            const result = await adminClient.query<GetCustomerHistory.Query, GetCustomerHistory.Variables>(
-                GET_CUSTOMER_HISTORY,
-                { id: customer.id, options: { skip: 6 } },
-            );
+            const result = await adminClient.query<
+                Codegen.GetCustomerHistoryQuery,
+                Codegen.GetCustomerHistoryQueryVariables
+            >(GET_CUSTOMER_HISTORY, { id: customer!.id, options: { skip: 6 } });
 
             expect(result.customer?.history.items.map(pick(['type', 'data']))).toEqual([
                 {
@@ -284,17 +287,17 @@ describe('Shop customers', () => {
         it(
             'deleteCustomerAddress fails for address not owned by Customer',
             assertThrowsWithMessage(async () => {
-                await shopClient.query<DeleteAddressShop.Mutation, DeleteAddressShop.Variables>(
-                    DELETE_ADDRESS,
-                    { id: 'T_2' },
-                );
+                await shopClient.query<
+                    CodegenShop.DeleteAddressShopMutation,
+                    CodegenShop.DeleteAddressShopMutationVariables
+                >(DELETE_ADDRESS, { id: 'T_2' });
             }, 'You are not currently authorized to perform this action'),
         );
 
         it('updatePassword return error result with incorrect current password', async () => {
             const { updateCustomerPassword } = await shopClient.query<
-                UpdatePassword.Mutation,
-                UpdatePassword.Variables
+                CodegenShop.UpdatePasswordMutation,
+                CodegenShop.UpdatePasswordMutationVariables
             >(UPDATE_PASSWORD, {
                 old: 'wrong',
                 new: 'test2',
@@ -307,8 +310,8 @@ describe('Shop customers', () => {
 
         it('updatePassword works', async () => {
             const { updateCustomerPassword } = await shopClient.query<
-                UpdatePassword.Mutation,
-                UpdatePassword.Variables
+                CodegenShop.UpdatePasswordMutation,
+                CodegenShop.UpdatePasswordMutationVariables
             >(UPDATE_PASSWORD, { old: 'test', new: 'test2' });
             successErrorGuard.assertSuccess(updateCustomerPassword);
 
@@ -320,10 +323,10 @@ describe('Shop customers', () => {
         });
 
         it('customer history for CUSTOMER_PASSWORD_UPDATED', async () => {
-            const result = await adminClient.query<GetCustomerHistory.Query, GetCustomerHistory.Variables>(
-                GET_CUSTOMER_HISTORY,
-                { id: customer.id, options: { skip: 7 } },
-            );
+            const result = await adminClient.query<
+                Codegen.GetCustomerHistoryQuery,
+                Codegen.GetCustomerHistoryQueryVariables
+            >(GET_CUSTOMER_HISTORY, { id: customer.id, options: { skip: 7 } });
 
             expect(result.customer?.history.items.map(pick(['type', 'data']))).toEqual([
                 {

Plik diff jest za duży
+ 219 - 236
packages/core/e2e/shop-order.e2e-spec.ts


Plik diff jest za duży
+ 341 - 322
packages/core/e2e/stock-control.e2e-spec.ts


+ 19 - 6
packages/core/e2e/tag.e2e-spec.ts

@@ -5,7 +5,7 @@ import { initialData } from '../../../e2e-common/e2e-initial-data';
 import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
 import { createTestEnvironment } from '../../testing/lib/create-test-environment';
 
-import { CreateTag, GetTag, GetTagList, UpdateTag } from './graphql/generated-e2e-admin-types';
+import * as Codegen from './graphql/generated-e2e-admin-types';
 
 describe('Tag resolver', () => {
     const { server, adminClient } = createTestEnvironment(testConfig());
@@ -24,7 +24,10 @@ describe('Tag resolver', () => {
     });
 
     it('create', async () => {
-        const { createTag } = await adminClient.query<CreateTag.Mutation, CreateTag.Variables>(CREATE_TAG, {
+        const { createTag } = await adminClient.query<
+            Codegen.CreateTagMutation,
+            Codegen.CreateTagMutationVariables
+        >(CREATE_TAG, {
             input: { value: 'tag1' },
         });
 
@@ -35,7 +38,10 @@ describe('Tag resolver', () => {
     });
 
     it('create with existing value returns existing tag', async () => {
-        const { createTag } = await adminClient.query<CreateTag.Mutation, CreateTag.Variables>(CREATE_TAG, {
+        const { createTag } = await adminClient.query<
+            Codegen.CreateTagMutation,
+            Codegen.CreateTagMutationVariables
+        >(CREATE_TAG, {
             input: { value: 'tag1' },
         });
 
@@ -46,7 +52,10 @@ describe('Tag resolver', () => {
     });
 
     it('update', async () => {
-        const { updateTag } = await adminClient.query<UpdateTag.Mutation, UpdateTag.Variables>(UPDATE_TAG, {
+        const { updateTag } = await adminClient.query<
+            Codegen.UpdateTagMutation,
+            Codegen.UpdateTagMutationVariables
+        >(UPDATE_TAG, {
             input: { id: 'T_1', value: 'tag1-updated' },
         });
 
@@ -57,7 +66,9 @@ describe('Tag resolver', () => {
     });
 
     it('tag', async () => {
-        const { tag } = await adminClient.query<GetTag.Query, GetTag.Variables>(GET_TAG, { id: 'T_1' });
+        const { tag } = await adminClient.query<Codegen.GetTagQuery, Codegen.GetTagQueryVariables>(GET_TAG, {
+            id: 'T_1',
+        });
 
         expect(tag).toEqual({
             id: 'T_1',
@@ -66,7 +77,9 @@ describe('Tag resolver', () => {
     });
 
     it('tags', async () => {
-        const { tags } = await adminClient.query<GetTagList.Query, GetTagList.Variables>(GET_TAG_LIST);
+        const { tags } = await adminClient.query<Codegen.GetTagListQuery, Codegen.GetTagListQueryVariables>(
+            GET_TAG_LIST,
+        );
 
         expect(tags).toEqual({
             items: [

+ 35 - 35
packages/core/e2e/tax-category.e2e-spec.ts

@@ -5,14 +5,8 @@ import path from 'path';
 import { initialData } from '../../../e2e-common/e2e-initial-data';
 import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
 
-import {
-    CreateTaxCategory,
-    DeleteTaxCategory,
-    DeletionResult,
-    GetTaxCategory,
-    GetTaxCategoryList,
-    UpdateTaxCategory,
-} from './graphql/generated-e2e-admin-types';
+import { DeletionResult } from './graphql/generated-e2e-admin-types';
+import * as Codegen from './graphql/generated-e2e-admin-types';
 import { sortById } from './utils/test-order-utils';
 
 describe('TaxCategory resolver', () => {
@@ -32,7 +26,9 @@ describe('TaxCategory resolver', () => {
     });
 
     it('taxCategories', async () => {
-        const { taxCategories } = await adminClient.query<GetTaxCategoryList.Query>(GET_TAX_CATEGORY_LIST);
+        const { taxCategories } = await adminClient.query<Codegen.GetTaxCategoryListQuery>(
+            GET_TAX_CATEGORY_LIST,
+        );
 
         expect(taxCategories.sort(sortById)).toEqual([
             { id: 'T_1', name: 'Standard Tax', isDefault: false },
@@ -42,12 +38,12 @@ describe('TaxCategory resolver', () => {
     });
 
     it('taxCategory', async () => {
-        const { taxCategory } = await adminClient.query<GetTaxCategory.Query, GetTaxCategory.Variables>(
-            GET_TAX_CATEGORY,
-            {
-                id: 'T_2',
-            },
-        );
+        const { taxCategory } = await adminClient.query<
+            Codegen.GetTaxCategoryQuery,
+            Codegen.GetTaxCategoryQueryVariables
+        >(GET_TAX_CATEGORY, {
+            id: 'T_2',
+        });
 
         expect(taxCategory).toEqual({
             id: 'T_2',
@@ -58,8 +54,8 @@ describe('TaxCategory resolver', () => {
 
     it('createTaxCategory', async () => {
         const { createTaxCategory } = await adminClient.query<
-            CreateTaxCategory.Mutation,
-            CreateTaxCategory.Variables
+            Codegen.CreateTaxCategoryMutation,
+            Codegen.CreateTaxCategoryMutationVariables
         >(CREATE_TAX_CATEGORY, {
             input: {
                 name: 'New Category',
@@ -75,8 +71,8 @@ describe('TaxCategory resolver', () => {
 
     it('updateCategory', async () => {
         const { updateTaxCategory } = await adminClient.query<
-            UpdateTaxCategory.Mutation,
-            UpdateTaxCategory.Variables
+            Codegen.UpdateTaxCategoryMutation,
+            Codegen.UpdateTaxCategoryMutationVariables
         >(UPDATE_TAX_CATEGORY, {
             input: {
                 id: 'T_4',
@@ -93,8 +89,8 @@ describe('TaxCategory resolver', () => {
 
     it('set default', async () => {
         const { updateTaxCategory } = await adminClient.query<
-            UpdateTaxCategory.Mutation,
-            UpdateTaxCategory.Variables
+            Codegen.UpdateTaxCategoryMutation,
+            Codegen.UpdateTaxCategoryMutationVariables
         >(UPDATE_TAX_CATEGORY, {
             input: {
                 id: 'T_2',
@@ -108,7 +104,9 @@ describe('TaxCategory resolver', () => {
             isDefault: true,
         });
 
-        const { taxCategories } = await adminClient.query<GetTaxCategoryList.Query>(GET_TAX_CATEGORY_LIST);
+        const { taxCategories } = await adminClient.query<Codegen.GetTaxCategoryListQuery>(
+            GET_TAX_CATEGORY_LIST,
+        );
         expect(taxCategories.sort(sortById)).toEqual([
             { id: 'T_1', name: 'Standard Tax', isDefault: false },
             { id: 'T_2', name: 'Reduced Tax', isDefault: true },
@@ -119,8 +117,8 @@ describe('TaxCategory resolver', () => {
 
     it('set a different default', async () => {
         const { updateTaxCategory } = await adminClient.query<
-            UpdateTaxCategory.Mutation,
-            UpdateTaxCategory.Variables
+            Codegen.UpdateTaxCategoryMutation,
+            Codegen.UpdateTaxCategoryMutationVariables
         >(UPDATE_TAX_CATEGORY, {
             input: {
                 id: 'T_1',
@@ -134,7 +132,9 @@ describe('TaxCategory resolver', () => {
             isDefault: true,
         });
 
-        const { taxCategories } = await adminClient.query<GetTaxCategoryList.Query>(GET_TAX_CATEGORY_LIST);
+        const { taxCategories } = await adminClient.query<Codegen.GetTaxCategoryListQuery>(
+            GET_TAX_CATEGORY_LIST,
+        );
         expect(taxCategories.sort(sortById)).toEqual([
             { id: 'T_1', name: 'Standard Tax', isDefault: true },
             { id: 'T_2', name: 'Reduced Tax', isDefault: false },
@@ -146,8 +146,8 @@ describe('TaxCategory resolver', () => {
     describe('deletion', () => {
         it('cannot delete if used by a TaxRate', async () => {
             const { deleteTaxCategory } = await adminClient.query<
-                DeleteTaxCategory.Mutation,
-                DeleteTaxCategory.Variables
+                Codegen.DeleteTaxCategoryMutation,
+                Codegen.DeleteTaxCategoryMutationVariables
             >(DELETE_TAX_CATEGORY, {
                 id: 'T_2',
             });
@@ -160,8 +160,8 @@ describe('TaxCategory resolver', () => {
 
         it('can delete if not used by TaxRate', async () => {
             const { deleteTaxCategory } = await adminClient.query<
-                DeleteTaxCategory.Mutation,
-                DeleteTaxCategory.Variables
+                Codegen.DeleteTaxCategoryMutation,
+                Codegen.DeleteTaxCategoryMutationVariables
             >(DELETE_TAX_CATEGORY, {
                 id: 'T_4',
             });
@@ -169,12 +169,12 @@ describe('TaxCategory resolver', () => {
             expect(deleteTaxCategory.result).toBe(DeletionResult.DELETED);
             expect(deleteTaxCategory.message).toBeNull();
 
-            const { taxCategory } = await adminClient.query<GetTaxCategory.Query, GetTaxCategory.Variables>(
-                GET_TAX_CATEGORY,
-                {
-                    id: 'T_4',
-                },
-            );
+            const { taxCategory } = await adminClient.query<
+                Codegen.GetTaxCategoryQuery,
+                Codegen.GetTaxCategoryQueryVariables
+            >(GET_TAX_CATEGORY, {
+                id: 'T_4',
+            });
 
             expect(taxCategory).toBeNull();
         });

+ 33 - 36
packages/core/e2e/tax-rate.e2e-spec.ts

@@ -8,14 +8,8 @@ import { initialData } from '../../../e2e-common/e2e-initial-data';
 import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
 
 import { TAX_RATE_FRAGMENT } from './graphql/fragments';
-import {
-    CreateTaxRate,
-    DeleteTaxRate,
-    DeletionResult,
-    GetTaxRate,
-    GetTaxRates,
-    UpdateTaxRate,
-} from './graphql/generated-e2e-admin-types';
+import * as Codegen from './graphql/generated-e2e-admin-types';
+import { DeletionResult } from './graphql/generated-e2e-admin-types';
 import { GET_TAX_RATES_LIST, UPDATE_TAX_RATE } from './graphql/shared-definitions';
 
 describe('TaxRate resolver', () => {
@@ -35,13 +29,16 @@ describe('TaxRate resolver', () => {
     });
 
     it('taxRates list', async () => {
-        const { taxRates } = await adminClient.query<GetTaxRates.Query>(GET_TAX_RATES_LIST);
+        const { taxRates } = await adminClient.query<Codegen.GetTaxRatesQuery>(GET_TAX_RATES_LIST);
 
         expect(taxRates.totalItems).toBe(15);
     });
 
     it('taxRate', async () => {
-        const { taxRate } = await adminClient.query<GetTaxRate.Query, GetTaxRate.Variables>(GET_TAX_RATE, {
+        const { taxRate } = await adminClient.query<
+            Codegen.GetTaxRateQuery,
+            Codegen.GetTaxRateQueryVariables
+        >(GET_TAX_RATE, {
             id: 'T_1',
         });
 
@@ -56,49 +53,49 @@ describe('TaxRate resolver', () => {
     });
 
     it('createTaxRate', async () => {
-        const { createTaxRate } = await adminClient.query<CreateTaxRate.Mutation, CreateTaxRate.Variables>(
-            CREATE_TAX_RATE,
-            {
-                input: {
-                    name: 'My Tax Rate',
-                    categoryId: 'T_1',
-                    zoneId: 'T_1',
-                    enabled: true,
-                    value: 17.5,
-                },
+        const { createTaxRate } = await adminClient.query<
+            Codegen.CreateTaxRateMutation,
+            Codegen.CreateTaxRateMutationVariables
+        >(CREATE_TAX_RATE, {
+            input: {
+                name: 'My Tax Rate',
+                categoryId: 'T_1',
+                zoneId: 'T_1',
+                enabled: true,
+                value: 17.5,
             },
-        );
+        });
 
         expect(createTaxRate.name).toBe('My Tax Rate');
         expect(createTaxRate.value).toBe(17.5);
     });
 
     it('updateTaxRate', async () => {
-        const { updateTaxRate } = await adminClient.query<UpdateTaxRate.Mutation, UpdateTaxRate.Variables>(
-            UPDATE_TAX_RATE,
-            {
-                input: {
-                    id: 'T_1',
-                    value: 17.5,
-                },
+        const { updateTaxRate } = await adminClient.query<
+            Codegen.UpdateTaxRateMutation,
+            Codegen.UpdateTaxRateMutationVariables
+        >(UPDATE_TAX_RATE, {
+            input: {
+                id: 'T_1',
+                value: 17.5,
             },
-        );
+        });
 
         expect(updateTaxRate.value).toBe(17.5);
     });
 
     it('deleteTaxRate', async () => {
-        const { deleteTaxRate } = await adminClient.query<DeleteTaxRate.Mutation, DeleteTaxRate.Variables>(
-            DELETE_TAX_RATE,
-            {
-                id: 'T_3',
-            },
-        );
+        const { deleteTaxRate } = await adminClient.query<
+            Codegen.DeleteTaxRateMutation,
+            Codegen.DeleteTaxRateMutationVariables
+        >(DELETE_TAX_RATE, {
+            id: 'T_3',
+        });
 
         expect(deleteTaxRate.result).toBe(DeletionResult.DELETED);
         expect(deleteTaxRate.message).toBeNull();
 
-        const { taxRates } = await adminClient.query<GetTaxRates.Query>(GET_TAX_RATES_LIST);
+        const { taxRates } = await adminClient.query<Codegen.GetTaxRatesQuery>(GET_TAX_RATES_LIST);
         expect(taxRates.items.find(x => x.id === 'T_3')).toBeUndefined();
     });
 });

+ 9 - 9
packages/core/e2e/utils/await-running-jobs.ts

@@ -19,18 +19,18 @@ export async function awaitRunningJobs(
     // e.g. event debouncing is used before triggering the job.
     await new Promise(resolve => setTimeout(resolve, delay));
     do {
-        const { jobs } = await adminClient.query<GetRunningJobs.Query, GetRunningJobs.Variables>(
-            GET_RUNNING_JOBS,
-            {
-                options: {
-                    filter: {
-                        isSettled: {
-                            eq: false,
-                        },
+        const { jobs } = await adminClient.query<
+            Codegen.GetRunningJobsQuery,
+            Codegen.GetRunningJobsQueryVariables
+        >(GET_RUNNING_JOBS, {
+            options: {
+                filter: {
+                    isSettled: {
+                        eq: false,
                     },
                 },
             },
-        );
+        });
         runningJobs = jobs.totalItems;
         timedOut = timeout < +new Date() - startTime;
     } while (runningJobs > 0 && !timedOut);

+ 23 - 23
packages/core/e2e/utils/test-order-utils.ts

@@ -3,14 +3,8 @@ import { ID } from '@vendure/common/lib/shared-types';
 import { PaymentMethodHandler } from '@vendure/core';
 import { SimpleGraphQLClient } from '@vendure/testing';
 
-import {
-    AddPaymentToOrder,
-    GetShippingMethods,
-    SetShippingAddress,
-    SetShippingMethod,
-    TestOrderFragmentFragment,
-    TransitionToState,
-} from '../graphql/generated-e2e-shop-types';
+import * as CodegenShop from '../graphql/generated-e2e-shop-types';
+import { TestOrderFragmentFragment } from '../graphql/generated-e2e-shop-types';
 import {
     ADD_PAYMENT,
     GET_ELIGIBLE_SHIPPING_METHODS,
@@ -20,7 +14,10 @@ import {
 } from '../graphql/shop-definitions';
 
 export async function proceedToArrangingPayment(shopClient: SimpleGraphQLClient): Promise<ID> {
-    await shopClient.query<SetShippingAddress.Mutation, SetShippingAddress.Variables>(SET_SHIPPING_ADDRESS, {
+    await shopClient.query<
+        CodegenShop.SetShippingAddressMutation,
+        CodegenShop.SetShippingAddressMutationVariables
+    >(SET_SHIPPING_ADDRESS, {
         input: {
             fullName: 'name',
             streetLine1: '12 the street',
@@ -30,17 +27,20 @@ export async function proceedToArrangingPayment(shopClient: SimpleGraphQLClient)
         },
     });
 
-    const { eligibleShippingMethods } = await shopClient.query<GetShippingMethods.Query>(
+    const { eligibleShippingMethods } = await shopClient.query<CodegenShop.GetShippingMethodsQuery>(
         GET_ELIGIBLE_SHIPPING_METHODS,
     );
 
-    await shopClient.query<SetShippingMethod.Mutation, SetShippingMethod.Variables>(SET_SHIPPING_METHOD, {
+    await shopClient.query<
+        CodegenShop.SetShippingMethodMutation,
+        CodegenShop.SetShippingMethodMutationVariables
+    >(SET_SHIPPING_METHOD, {
         id: eligibleShippingMethods[1].id,
     });
 
     const { transitionOrderToState } = await shopClient.query<
-        TransitionToState.Mutation,
-        TransitionToState.Variables
+        CodegenShop.TransitionToStateMutation,
+        CodegenShop.TransitionToStateMutationVariables
     >(TRANSITION_TO_STATE, { state: 'ArrangingPayment' });
 
     return (transitionOrderToState as TestOrderFragmentFragment)!.id;
@@ -49,18 +49,18 @@ export async function proceedToArrangingPayment(shopClient: SimpleGraphQLClient)
 export async function addPaymentToOrder(
     shopClient: SimpleGraphQLClient,
     handler: PaymentMethodHandler,
-): Promise<NonNullable<AddPaymentToOrder.Mutation['addPaymentToOrder']>> {
-    const result = await shopClient.query<AddPaymentToOrder.Mutation, AddPaymentToOrder.Variables>(
-        ADD_PAYMENT,
-        {
-            input: {
-                method: handler.code,
-                metadata: {
-                    baz: 'quux',
-                },
+): Promise<NonNullable<CodegenShop.AddPaymentToOrderMutation['addPaymentToOrder']>> {
+    const result = await shopClient.query<
+        CodegenShop.AddPaymentToOrderMutation,
+        CodegenShop.AddPaymentToOrderMutationVariables
+    >(ADD_PAYMENT, {
+        input: {
+            method: handler.code,
+            metadata: {
+                baz: 'quux',
             },
         },
-    );
+    });
     const order = result.addPaymentToOrder!;
     return order as any;
 }

+ 65 - 48
packages/core/e2e/zone.e2e-spec.ts

@@ -6,25 +6,15 @@ import { initialData } from '../../../e2e-common/e2e-initial-data';
 import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
 
 import { ZONE_FRAGMENT } from './graphql/fragments';
-import {
-    AddMembersToZone,
-    CreateZone,
-    DeleteZone,
-    DeletionResult,
-    GetCountryList,
-    GetZone,
-    GetZones,
-    RemoveMembersFromZone,
-    UpdateChannel,
-    UpdateZone,
-} from './graphql/generated-e2e-admin-types';
+import * as Codegen from './graphql/generated-e2e-admin-types';
+import { DeletionResult } from './graphql/generated-e2e-admin-types';
 import { GET_COUNTRY_LIST, UPDATE_CHANNEL } from './graphql/shared-definitions';
 
 // tslint:disable:no-non-null-assertion
 
 describe('Zone resolver', () => {
     const { server, adminClient } = createTestEnvironment(testConfig());
-    let countries: GetCountryList.Items[];
+    let countries: Codegen.GetCountryListQuery['countries']['items'];
     let zones: Array<{ id: string; name: string }>;
     let oceania: { id: string; name: string };
     let pangaea: { id: string; name: string; members: any[] };
@@ -37,7 +27,7 @@ describe('Zone resolver', () => {
         });
         await adminClient.asSuperAdmin();
 
-        const result = await adminClient.query<GetCountryList.Query>(GET_COUNTRY_LIST, {});
+        const result = await adminClient.query<Codegen.GetCountryListQuery>(GET_COUNTRY_LIST, {});
         countries = result.countries.items;
     }, TEST_SETUP_TIMEOUT_MS);
 
@@ -46,22 +36,28 @@ describe('Zone resolver', () => {
     });
 
     it('zones', async () => {
-        const result = await adminClient.query<GetZones.Query>(GET_ZONE_LIST);
+        const result = await adminClient.query<Codegen.GetZonesQuery>(GET_ZONE_LIST);
         expect(result.zones.length).toBe(5);
         zones = result.zones;
         oceania = zones[0];
     });
 
     it('zone', async () => {
-        const result = await adminClient.query<GetZone.Query, GetZone.Variables>(GET_ZONE, {
-            id: oceania.id,
-        });
+        const result = await adminClient.query<Codegen.GetZoneQuery, Codegen.GetZoneQueryVariables>(
+            GET_ZONE,
+            {
+                id: oceania.id,
+            },
+        );
 
         expect(result.zone!.name).toBe('Oceania');
     });
 
     it('updateZone', async () => {
-        const result = await adminClient.query<UpdateZone.Mutation, UpdateZone.Variables>(UPDATE_ZONE, {
+        const result = await adminClient.query<
+            Codegen.UpdateZoneMutation,
+            Codegen.UpdateZoneMutationVariables
+        >(UPDATE_ZONE, {
             input: {
                 id: oceania.id,
                 name: 'oceania2',
@@ -72,7 +68,10 @@ describe('Zone resolver', () => {
     });
 
     it('createZone', async () => {
-        const result = await adminClient.query<CreateZone.Mutation, CreateZone.Variables>(CREATE_ZONE, {
+        const result = await adminClient.query<
+            Codegen.CreateZoneMutation,
+            Codegen.CreateZoneMutationVariables
+        >(CREATE_ZONE, {
             input: {
                 name: 'Pangaea',
                 memberIds: [countries[0].id, countries[1].id],
@@ -85,13 +84,13 @@ describe('Zone resolver', () => {
     });
 
     it('addMembersToZone', async () => {
-        const result = await adminClient.query<AddMembersToZone.Mutation, AddMembersToZone.Variables>(
-            ADD_MEMBERS_TO_ZONE,
-            {
-                zoneId: oceania.id,
-                memberIds: [countries[2].id, countries[3].id],
-            },
-        );
+        const result = await adminClient.query<
+            Codegen.AddMembersToZoneMutation,
+            Codegen.AddMembersToZoneMutationVariables
+        >(ADD_MEMBERS_TO_ZONE, {
+            zoneId: oceania.id,
+            memberIds: [countries[2].id, countries[3].id],
+        });
 
         expect(!!result.addMembersToZone.members.find(m => m.name === countries[2].name)).toBe(true);
         expect(!!result.addMembersToZone.members.find(m => m.name === countries[3].name)).toBe(true);
@@ -99,8 +98,8 @@ describe('Zone resolver', () => {
 
     it('removeMembersFromZone', async () => {
         const result = await adminClient.query<
-            RemoveMembersFromZone.Mutation,
-            RemoveMembersFromZone.Variables
+            Codegen.RemoveMembersFromZoneMutation,
+            Codegen.RemoveMembersFromZoneMutationVariables
         >(REMOVE_MEMBERS_FROM_ZONE, {
             zoneId: oceania.id,
             memberIds: [countries[0].id, countries[2].id],
@@ -113,7 +112,10 @@ describe('Zone resolver', () => {
 
     describe('deletion', () => {
         it('deletes Zone not used in any TaxRate', async () => {
-            const result1 = await adminClient.query<DeleteZone.Mutation, DeleteZone.Variables>(DELETE_ZONE, {
+            const result1 = await adminClient.query<
+                Codegen.DeleteZoneMutation,
+                Codegen.DeleteZoneMutationVariables
+            >(DELETE_ZONE, {
                 id: pangaea.id,
             });
 
@@ -122,12 +124,15 @@ describe('Zone resolver', () => {
                 message: '',
             });
 
-            const result2 = await adminClient.query<GetZones.Query>(GET_ZONE_LIST);
+            const result2 = await adminClient.query<Codegen.GetZonesQuery>(GET_ZONE_LIST);
             expect(result2.zones.find(c => c.id === pangaea.id)).toBeUndefined();
         });
 
         it('does not delete Zone that is used in one or more TaxRates', async () => {
-            const result1 = await adminClient.query<DeleteZone.Mutation, DeleteZone.Variables>(DELETE_ZONE, {
+            const result1 = await adminClient.query<
+                Codegen.DeleteZoneMutation,
+                Codegen.DeleteZoneMutationVariables
+            >(DELETE_ZONE, {
                 id: oceania.id,
             });
 
@@ -138,19 +143,25 @@ describe('Zone resolver', () => {
                     'TaxRates: Standard Tax Oceania, Reduced Tax Oceania, Zero Tax Oceania',
             });
 
-            const result2 = await adminClient.query<GetZones.Query>(GET_ZONE_LIST);
+            const result2 = await adminClient.query<Codegen.GetZonesQuery>(GET_ZONE_LIST);
             expect(result2.zones.find(c => c.id === oceania.id)).not.toBeUndefined();
         });
 
         it('does not delete Zone that is used as a Channel defaultTaxZone', async () => {
-            await adminClient.query<UpdateChannel.Mutation, UpdateChannel.Variables>(UPDATE_CHANNEL, {
-                input: {
-                    id: 'T_1',
-                    defaultTaxZoneId: oceania.id,
+            await adminClient.query<Codegen.UpdateChannelMutation, Codegen.UpdateChannelMutationVariables>(
+                UPDATE_CHANNEL,
+                {
+                    input: {
+                        id: 'T_1',
+                        defaultTaxZoneId: oceania.id,
+                    },
                 },
-            });
+            );
 
-            const result1 = await adminClient.query<DeleteZone.Mutation, DeleteZone.Variables>(DELETE_ZONE, {
+            const result1 = await adminClient.query<
+                Codegen.DeleteZoneMutation,
+                Codegen.DeleteZoneMutationVariables
+            >(DELETE_ZONE, {
                 id: oceania.id,
             });
 
@@ -161,20 +172,26 @@ describe('Zone resolver', () => {
                     '__default_channel__',
             });
 
-            const result2 = await adminClient.query<GetZones.Query>(GET_ZONE_LIST);
+            const result2 = await adminClient.query<Codegen.GetZonesQuery>(GET_ZONE_LIST);
             expect(result2.zones.find(c => c.id === oceania.id)).not.toBeUndefined();
         });
 
         it('does not delete Zone that is used as a Channel defaultShippingZone', async () => {
-            await adminClient.query<UpdateChannel.Mutation, UpdateChannel.Variables>(UPDATE_CHANNEL, {
-                input: {
-                    id: 'T_1',
-                    defaultTaxZoneId: 'T_1',
-                    defaultShippingZoneId: oceania.id,
+            await adminClient.query<Codegen.UpdateChannelMutation, Codegen.UpdateChannelMutationVariables>(
+                UPDATE_CHANNEL,
+                {
+                    input: {
+                        id: 'T_1',
+                        defaultTaxZoneId: 'T_1',
+                        defaultShippingZoneId: oceania.id,
+                    },
                 },
-            });
+            );
 
-            const result1 = await adminClient.query<DeleteZone.Mutation, DeleteZone.Variables>(DELETE_ZONE, {
+            const result1 = await adminClient.query<
+                Codegen.DeleteZoneMutation,
+                Codegen.DeleteZoneMutationVariables
+            >(DELETE_ZONE, {
                 id: oceania.id,
             });
 
@@ -185,7 +202,7 @@ describe('Zone resolver', () => {
                     '__default_channel__',
             });
 
-            const result2 = await adminClient.query<GetZones.Query>(GET_ZONE_LIST);
+            const result2 = await adminClient.query<Codegen.GetZonesQuery>(GET_ZONE_LIST);
             expect(result2.zones.find(c => c.id === oceania.id)).not.toBeUndefined();
         });
     });

+ 4 - 4
packages/core/src/api/resolvers/admin/global-settings.resolver.ts

@@ -85,10 +85,10 @@ export class GlobalSettingsResolver {
                 c => !availableLanguages.includes(c.defaultLanguageCode),
             );
             if (unavailableDefaults.length) {
-                return new ChannelDefaultLanguageError(
-                    unavailableDefaults.map(c => c.defaultLanguageCode).join(', '),
-                    unavailableDefaults.map(c => c.code).join(', '),
-                );
+                return new ChannelDefaultLanguageError({
+                    language: unavailableDefaults.map(c => c.defaultLanguageCode).join(', '),
+                    channelCode: unavailableDefaults.map(c => c.code).join(', '),
+                });
             }
         }
         return this.globalSettingsService.updateSettings(ctx, args.input);

+ 1 - 1
packages/core/src/api/resolvers/base/base-auth.resolver.ts

@@ -118,7 +118,7 @@ export class BaseAuthResolver {
         if (apiType && apiType === 'admin') {
             const administrator = await this.administratorService.findOneByUserId(ctx, session.user.id);
             if (!administrator) {
-                return new InvalidCredentialsError('');
+                return new InvalidCredentialsError({ authenticationError: '' });
             }
         }
         setSessionToken({

+ 96 - 32
packages/core/src/common/error/generated-graphql-admin-errors.ts

@@ -15,17 +15,19 @@ export type Scalars = {
 export class ErrorResult {
   readonly __typename: string;
   readonly errorCode: string;
-message: Scalars['String'];
+  readonly message: Scalars['String'];
 }
 
 export class AlreadyRefundedError extends ErrorResult {
   readonly __typename = 'AlreadyRefundedError';
   readonly errorCode = 'ALREADY_REFUNDED_ERROR' as any;
   readonly message = 'ALREADY_REFUNDED_ERROR';
+  readonly refundId: Scalars['ID'];
   constructor(
-    public refundId: Scalars['ID'],
+    input: { refundId: Scalars['ID'] }
   ) {
     super();
+    this.refundId = input.refundId
   }
 }
 
@@ -33,10 +35,12 @@ export class CancelActiveOrderError extends ErrorResult {
   readonly __typename = 'CancelActiveOrderError';
   readonly errorCode = 'CANCEL_ACTIVE_ORDER_ERROR' as any;
   readonly message = 'CANCEL_ACTIVE_ORDER_ERROR';
+  readonly orderState: Scalars['String'];
   constructor(
-    public orderState: Scalars['String'],
+    input: { orderState: Scalars['String'] }
   ) {
     super();
+    this.orderState = input.orderState
   }
 }
 
@@ -44,11 +48,14 @@ export class ChannelDefaultLanguageError extends ErrorResult {
   readonly __typename = 'ChannelDefaultLanguageError';
   readonly errorCode = 'CHANNEL_DEFAULT_LANGUAGE_ERROR' as any;
   readonly message = 'CHANNEL_DEFAULT_LANGUAGE_ERROR';
+  readonly channelCode: Scalars['String'];
+  readonly language: Scalars['String'];
   constructor(
-    public channelCode: Scalars['String'],
-    public language: Scalars['String'],
+    input: { channelCode: Scalars['String'], language: Scalars['String'] }
   ) {
     super();
+    this.channelCode = input.channelCode
+    this.language = input.language
   }
 }
 
@@ -56,10 +63,12 @@ export class CreateFulfillmentError extends ErrorResult {
   readonly __typename = 'CreateFulfillmentError';
   readonly errorCode = 'CREATE_FULFILLMENT_ERROR' as any;
   readonly message = 'CREATE_FULFILLMENT_ERROR';
+  readonly fulfillmentHandlerError: Scalars['String'];
   constructor(
-    public fulfillmentHandlerError: Scalars['String'],
+    input: { fulfillmentHandlerError: Scalars['String'] }
   ) {
     super();
+    this.fulfillmentHandlerError = input.fulfillmentHandlerError
   }
 }
 
@@ -68,6 +77,7 @@ export class EmailAddressConflictError extends ErrorResult {
   readonly errorCode = 'EMAIL_ADDRESS_CONFLICT_ERROR' as any;
   readonly message = 'EMAIL_ADDRESS_CONFLICT_ERROR';
   constructor(
+
   ) {
     super();
   }
@@ -78,6 +88,7 @@ export class EmptyOrderLineSelectionError extends ErrorResult {
   readonly errorCode = 'EMPTY_ORDER_LINE_SELECTION_ERROR' as any;
   readonly message = 'EMPTY_ORDER_LINE_SELECTION_ERROR';
   constructor(
+
   ) {
     super();
   }
@@ -87,12 +98,16 @@ export class FulfillmentStateTransitionError extends ErrorResult {
   readonly __typename = 'FulfillmentStateTransitionError';
   readonly errorCode = 'FULFILLMENT_STATE_TRANSITION_ERROR' as any;
   readonly message = 'FULFILLMENT_STATE_TRANSITION_ERROR';
+  readonly fromState: Scalars['String'];
+  readonly toState: Scalars['String'];
+  readonly transitionError: Scalars['String'];
   constructor(
-    public fromState: Scalars['String'],
-    public toState: Scalars['String'],
-    public transitionError: Scalars['String'],
+    input: { fromState: Scalars['String'], toState: Scalars['String'], transitionError: Scalars['String'] }
   ) {
     super();
+    this.fromState = input.fromState
+    this.toState = input.toState
+    this.transitionError = input.transitionError
   }
 }
 
@@ -100,11 +115,14 @@ export class InsufficientStockError extends ErrorResult {
   readonly __typename = 'InsufficientStockError';
   readonly errorCode = 'INSUFFICIENT_STOCK_ERROR' as any;
   readonly message = 'INSUFFICIENT_STOCK_ERROR';
+  readonly order: any;
+  readonly quantityAvailable: Scalars['Int'];
   constructor(
-    public order: any,
-    public quantityAvailable: Scalars['Int'],
+    input: { order: any, quantityAvailable: Scalars['Int'] }
   ) {
     super();
+    this.order = input.order
+    this.quantityAvailable = input.quantityAvailable
   }
 }
 
@@ -112,12 +130,16 @@ export class InsufficientStockOnHandError extends ErrorResult {
   readonly __typename = 'InsufficientStockOnHandError';
   readonly errorCode = 'INSUFFICIENT_STOCK_ON_HAND_ERROR' as any;
   readonly message = 'INSUFFICIENT_STOCK_ON_HAND_ERROR';
+  readonly productVariantId: Scalars['ID'];
+  readonly productVariantName: Scalars['String'];
+  readonly stockOnHand: Scalars['Int'];
   constructor(
-    public productVariantId: Scalars['ID'],
-    public productVariantName: Scalars['String'],
-    public stockOnHand: Scalars['Int'],
+    input: { productVariantId: Scalars['ID'], productVariantName: Scalars['String'], stockOnHand: Scalars['Int'] }
   ) {
     super();
+    this.productVariantId = input.productVariantId
+    this.productVariantName = input.productVariantName
+    this.stockOnHand = input.stockOnHand
   }
 }
 
@@ -125,10 +147,12 @@ export class InvalidCredentialsError extends ErrorResult {
   readonly __typename = 'InvalidCredentialsError';
   readonly errorCode = 'INVALID_CREDENTIALS_ERROR' as any;
   readonly message = 'INVALID_CREDENTIALS_ERROR';
+  readonly authenticationError: Scalars['String'];
   constructor(
-    public authenticationError: Scalars['String'],
+    input: { authenticationError: Scalars['String'] }
   ) {
     super();
+    this.authenticationError = input.authenticationError
   }
 }
 
@@ -137,6 +161,7 @@ export class InvalidFulfillmentHandlerError extends ErrorResult {
   readonly errorCode = 'INVALID_FULFILLMENT_HANDLER_ERROR' as any;
   readonly message = 'INVALID_FULFILLMENT_HANDLER_ERROR';
   constructor(
+
   ) {
     super();
   }
@@ -147,6 +172,7 @@ export class ItemsAlreadyFulfilledError extends ErrorResult {
   readonly errorCode = 'ITEMS_ALREADY_FULFILLED_ERROR' as any;
   readonly message = 'ITEMS_ALREADY_FULFILLED_ERROR';
   constructor(
+
   ) {
     super();
   }
@@ -156,10 +182,12 @@ export class LanguageNotAvailableError extends ErrorResult {
   readonly __typename = 'LanguageNotAvailableError';
   readonly errorCode = 'LANGUAGE_NOT_AVAILABLE_ERROR' as any;
   readonly message = 'LANGUAGE_NOT_AVAILABLE_ERROR';
+  readonly languageCode: Scalars['String'];
   constructor(
-    public languageCode: Scalars['String'],
+    input: { languageCode: Scalars['String'] }
   ) {
     super();
+    this.languageCode = input.languageCode
   }
 }
 
@@ -168,6 +196,7 @@ export class ManualPaymentStateError extends ErrorResult {
   readonly errorCode = 'MANUAL_PAYMENT_STATE_ERROR' as any;
   readonly message = 'MANUAL_PAYMENT_STATE_ERROR';
   constructor(
+
   ) {
     super();
   }
@@ -177,11 +206,14 @@ export class MimeTypeError extends ErrorResult {
   readonly __typename = 'MimeTypeError';
   readonly errorCode = 'MIME_TYPE_ERROR' as any;
   readonly message = 'MIME_TYPE_ERROR';
+  readonly fileName: Scalars['String'];
+  readonly mimeType: Scalars['String'];
   constructor(
-    public fileName: Scalars['String'],
-    public mimeType: Scalars['String'],
+    input: { fileName: Scalars['String'], mimeType: Scalars['String'] }
   ) {
     super();
+    this.fileName = input.fileName
+    this.mimeType = input.mimeType
   }
 }
 
@@ -190,6 +222,7 @@ export class MissingConditionsError extends ErrorResult {
   readonly errorCode = 'MISSING_CONDITIONS_ERROR' as any;
   readonly message = 'MISSING_CONDITIONS_ERROR';
   constructor(
+
   ) {
     super();
   }
@@ -200,6 +233,7 @@ export class MultipleOrderError extends ErrorResult {
   readonly errorCode = 'MULTIPLE_ORDER_ERROR' as any;
   readonly message = 'MULTIPLE_ORDER_ERROR';
   constructor(
+
   ) {
     super();
   }
@@ -210,6 +244,7 @@ export class NativeAuthStrategyError extends ErrorResult {
   readonly errorCode = 'NATIVE_AUTH_STRATEGY_ERROR' as any;
   readonly message = 'NATIVE_AUTH_STRATEGY_ERROR';
   constructor(
+
   ) {
     super();
   }
@@ -220,6 +255,7 @@ export class NegativeQuantityError extends ErrorResult {
   readonly errorCode = 'NEGATIVE_QUANTITY_ERROR' as any;
   readonly message = 'NEGATIVE_QUANTITY_ERROR';
   constructor(
+
   ) {
     super();
   }
@@ -230,6 +266,7 @@ export class NoChangesSpecifiedError extends ErrorResult {
   readonly errorCode = 'NO_CHANGES_SPECIFIED_ERROR' as any;
   readonly message = 'NO_CHANGES_SPECIFIED_ERROR';
   constructor(
+
   ) {
     super();
   }
@@ -240,6 +277,7 @@ export class NothingToRefundError extends ErrorResult {
   readonly errorCode = 'NOTHING_TO_REFUND_ERROR' as any;
   readonly message = 'NOTHING_TO_REFUND_ERROR';
   constructor(
+
   ) {
     super();
   }
@@ -249,10 +287,12 @@ export class OrderLimitError extends ErrorResult {
   readonly __typename = 'OrderLimitError';
   readonly errorCode = 'ORDER_LIMIT_ERROR' as any;
   readonly message = 'ORDER_LIMIT_ERROR';
+  readonly maxItems: Scalars['Int'];
   constructor(
-    public maxItems: Scalars['Int'],
+    input: { maxItems: Scalars['Int'] }
   ) {
     super();
+    this.maxItems = input.maxItems
   }
 }
 
@@ -261,6 +301,7 @@ export class OrderModificationStateError extends ErrorResult {
   readonly errorCode = 'ORDER_MODIFICATION_STATE_ERROR' as any;
   readonly message = 'ORDER_MODIFICATION_STATE_ERROR';
   constructor(
+
   ) {
     super();
   }
@@ -270,12 +311,16 @@ export class OrderStateTransitionError extends ErrorResult {
   readonly __typename = 'OrderStateTransitionError';
   readonly errorCode = 'ORDER_STATE_TRANSITION_ERROR' as any;
   readonly message = 'ORDER_STATE_TRANSITION_ERROR';
+  readonly fromState: Scalars['String'];
+  readonly toState: Scalars['String'];
+  readonly transitionError: Scalars['String'];
   constructor(
-    public fromState: Scalars['String'],
-    public toState: Scalars['String'],
-    public transitionError: Scalars['String'],
+    input: { fromState: Scalars['String'], toState: Scalars['String'], transitionError: Scalars['String'] }
   ) {
     super();
+    this.fromState = input.fromState
+    this.toState = input.toState
+    this.transitionError = input.transitionError
   }
 }
 
@@ -284,6 +329,7 @@ export class PaymentMethodMissingError extends ErrorResult {
   readonly errorCode = 'PAYMENT_METHOD_MISSING_ERROR' as any;
   readonly message = 'PAYMENT_METHOD_MISSING_ERROR';
   constructor(
+
   ) {
     super();
   }
@@ -294,6 +340,7 @@ export class PaymentOrderMismatchError extends ErrorResult {
   readonly errorCode = 'PAYMENT_ORDER_MISMATCH_ERROR' as any;
   readonly message = 'PAYMENT_ORDER_MISMATCH_ERROR';
   constructor(
+
   ) {
     super();
   }
@@ -303,12 +350,16 @@ export class PaymentStateTransitionError extends ErrorResult {
   readonly __typename = 'PaymentStateTransitionError';
   readonly errorCode = 'PAYMENT_STATE_TRANSITION_ERROR' as any;
   readonly message = 'PAYMENT_STATE_TRANSITION_ERROR';
+  readonly fromState: Scalars['String'];
+  readonly toState: Scalars['String'];
+  readonly transitionError: Scalars['String'];
   constructor(
-    public fromState: Scalars['String'],
-    public toState: Scalars['String'],
-    public transitionError: Scalars['String'],
+    input: { fromState: Scalars['String'], toState: Scalars['String'], transitionError: Scalars['String'] }
   ) {
     super();
+    this.fromState = input.fromState
+    this.toState = input.toState
+    this.transitionError = input.transitionError
   }
 }
 
@@ -316,11 +367,14 @@ export class ProductOptionInUseError extends ErrorResult {
   readonly __typename = 'ProductOptionInUseError';
   readonly errorCode = 'PRODUCT_OPTION_IN_USE_ERROR' as any;
   readonly message = 'PRODUCT_OPTION_IN_USE_ERROR';
+  readonly optionGroupCode: Scalars['String'];
+  readonly productVariantCount: Scalars['Int'];
   constructor(
-    public optionGroupCode: Scalars['String'],
-    public productVariantCount: Scalars['Int'],
+    input: { optionGroupCode: Scalars['String'], productVariantCount: Scalars['Int'] }
   ) {
     super();
+    this.optionGroupCode = input.optionGroupCode
+    this.productVariantCount = input.productVariantCount
   }
 }
 
@@ -329,6 +383,7 @@ export class QuantityTooGreatError extends ErrorResult {
   readonly errorCode = 'QUANTITY_TOO_GREAT_ERROR' as any;
   readonly message = 'QUANTITY_TOO_GREAT_ERROR';
   constructor(
+
   ) {
     super();
   }
@@ -338,10 +393,12 @@ export class RefundOrderStateError extends ErrorResult {
   readonly __typename = 'RefundOrderStateError';
   readonly errorCode = 'REFUND_ORDER_STATE_ERROR' as any;
   readonly message = 'REFUND_ORDER_STATE_ERROR';
+  readonly orderState: Scalars['String'];
   constructor(
-    public orderState: Scalars['String'],
+    input: { orderState: Scalars['String'] }
   ) {
     super();
+    this.orderState = input.orderState
   }
 }
 
@@ -350,6 +407,7 @@ export class RefundPaymentIdMissingError extends ErrorResult {
   readonly errorCode = 'REFUND_PAYMENT_ID_MISSING_ERROR' as any;
   readonly message = 'REFUND_PAYMENT_ID_MISSING_ERROR';
   constructor(
+
   ) {
     super();
   }
@@ -359,12 +417,16 @@ export class RefundStateTransitionError extends ErrorResult {
   readonly __typename = 'RefundStateTransitionError';
   readonly errorCode = 'REFUND_STATE_TRANSITION_ERROR' as any;
   readonly message = 'REFUND_STATE_TRANSITION_ERROR';
+  readonly fromState: Scalars['String'];
+  readonly toState: Scalars['String'];
+  readonly transitionError: Scalars['String'];
   constructor(
-    public fromState: Scalars['String'],
-    public toState: Scalars['String'],
-    public transitionError: Scalars['String'],
+    input: { fromState: Scalars['String'], toState: Scalars['String'], transitionError: Scalars['String'] }
   ) {
     super();
+    this.fromState = input.fromState
+    this.toState = input.toState
+    this.transitionError = input.transitionError
   }
 }
 
@@ -372,10 +434,12 @@ export class SettlePaymentError extends ErrorResult {
   readonly __typename = 'SettlePaymentError';
   readonly errorCode = 'SETTLE_PAYMENT_ERROR' as any;
   readonly message = 'SETTLE_PAYMENT_ERROR';
+  readonly paymentErrorMessage: Scalars['String'];
   constructor(
-    public paymentErrorMessage: Scalars['String'],
+    input: { paymentErrorMessage: Scalars['String'] }
   ) {
     super();
+    this.paymentErrorMessage = input.paymentErrorMessage
   }
 }
 

+ 59 - 16
packages/core/src/common/error/generated-graphql-shop-errors.ts

@@ -15,7 +15,7 @@ export type Scalars = {
 export class ErrorResult {
   readonly __typename: string;
   readonly errorCode: string;
-message: Scalars['String'];
+  readonly message: Scalars['String'];
 }
 
 export class AlreadyLoggedInError extends ErrorResult {
@@ -23,6 +23,7 @@ export class AlreadyLoggedInError extends ErrorResult {
   readonly errorCode = 'ALREADY_LOGGED_IN_ERROR' as any;
   readonly message = 'ALREADY_LOGGED_IN_ERROR';
   constructor(
+
   ) {
     super();
   }
@@ -32,10 +33,12 @@ export class CouponCodeExpiredError extends ErrorResult {
   readonly __typename = 'CouponCodeExpiredError';
   readonly errorCode = 'COUPON_CODE_EXPIRED_ERROR' as any;
   readonly message = 'COUPON_CODE_EXPIRED_ERROR';
+  readonly couponCode: Scalars['String'];
   constructor(
-    public couponCode: Scalars['String'],
+    input: { couponCode: Scalars['String'] }
   ) {
     super();
+    this.couponCode = input.couponCode
   }
 }
 
@@ -43,10 +46,12 @@ export class CouponCodeInvalidError extends ErrorResult {
   readonly __typename = 'CouponCodeInvalidError';
   readonly errorCode = 'COUPON_CODE_INVALID_ERROR' as any;
   readonly message = 'COUPON_CODE_INVALID_ERROR';
+  readonly couponCode: Scalars['String'];
   constructor(
-    public couponCode: Scalars['String'],
+    input: { couponCode: Scalars['String'] }
   ) {
     super();
+    this.couponCode = input.couponCode
   }
 }
 
@@ -54,11 +59,14 @@ export class CouponCodeLimitError extends ErrorResult {
   readonly __typename = 'CouponCodeLimitError';
   readonly errorCode = 'COUPON_CODE_LIMIT_ERROR' as any;
   readonly message = 'COUPON_CODE_LIMIT_ERROR';
+  readonly couponCode: Scalars['String'];
+  readonly limit: Scalars['Int'];
   constructor(
-    public couponCode: Scalars['String'],
-    public limit: Scalars['Int'],
+    input: { couponCode: Scalars['String'], limit: Scalars['Int'] }
   ) {
     super();
+    this.couponCode = input.couponCode
+    this.limit = input.limit
   }
 }
 
@@ -67,6 +75,7 @@ export class EmailAddressConflictError extends ErrorResult {
   readonly errorCode = 'EMAIL_ADDRESS_CONFLICT_ERROR' as any;
   readonly message = 'EMAIL_ADDRESS_CONFLICT_ERROR';
   constructor(
+
   ) {
     super();
   }
@@ -77,6 +86,7 @@ export class IdentifierChangeTokenExpiredError extends ErrorResult {
   readonly errorCode = 'IDENTIFIER_CHANGE_TOKEN_EXPIRED_ERROR' as any;
   readonly message = 'IDENTIFIER_CHANGE_TOKEN_EXPIRED_ERROR';
   constructor(
+
   ) {
     super();
   }
@@ -87,6 +97,7 @@ export class IdentifierChangeTokenInvalidError extends ErrorResult {
   readonly errorCode = 'IDENTIFIER_CHANGE_TOKEN_INVALID_ERROR' as any;
   readonly message = 'IDENTIFIER_CHANGE_TOKEN_INVALID_ERROR';
   constructor(
+
   ) {
     super();
   }
@@ -96,10 +107,12 @@ export class IneligiblePaymentMethodError extends ErrorResult {
   readonly __typename = 'IneligiblePaymentMethodError';
   readonly errorCode = 'INELIGIBLE_PAYMENT_METHOD_ERROR' as any;
   readonly message = 'INELIGIBLE_PAYMENT_METHOD_ERROR';
+  readonly eligibilityCheckerMessage: any;
   constructor(
-    public eligibilityCheckerMessage: any,
+    input: { eligibilityCheckerMessage: any }
   ) {
     super();
+    this.eligibilityCheckerMessage = input.eligibilityCheckerMessage
   }
 }
 
@@ -108,6 +121,7 @@ export class IneligibleShippingMethodError extends ErrorResult {
   readonly errorCode = 'INELIGIBLE_SHIPPING_METHOD_ERROR' as any;
   readonly message = 'INELIGIBLE_SHIPPING_METHOD_ERROR';
   constructor(
+
   ) {
     super();
   }
@@ -117,11 +131,14 @@ export class InsufficientStockError extends ErrorResult {
   readonly __typename = 'InsufficientStockError';
   readonly errorCode = 'INSUFFICIENT_STOCK_ERROR' as any;
   readonly message = 'INSUFFICIENT_STOCK_ERROR';
+  readonly order: any;
+  readonly quantityAvailable: Scalars['Int'];
   constructor(
-    public order: any,
-    public quantityAvailable: Scalars['Int'],
+    input: { order: any, quantityAvailable: Scalars['Int'] }
   ) {
     super();
+    this.order = input.order
+    this.quantityAvailable = input.quantityAvailable
   }
 }
 
@@ -129,10 +146,12 @@ export class InvalidCredentialsError extends ErrorResult {
   readonly __typename = 'InvalidCredentialsError';
   readonly errorCode = 'INVALID_CREDENTIALS_ERROR' as any;
   readonly message = 'INVALID_CREDENTIALS_ERROR';
+  readonly authenticationError: Scalars['String'];
   constructor(
-    public authenticationError: Scalars['String'],
+    input: { authenticationError: Scalars['String'] }
   ) {
     super();
+    this.authenticationError = input.authenticationError
   }
 }
 
@@ -141,6 +160,7 @@ export class MissingPasswordError extends ErrorResult {
   readonly errorCode = 'MISSING_PASSWORD_ERROR' as any;
   readonly message = 'MISSING_PASSWORD_ERROR';
   constructor(
+
   ) {
     super();
   }
@@ -151,6 +171,7 @@ export class NativeAuthStrategyError extends ErrorResult {
   readonly errorCode = 'NATIVE_AUTH_STRATEGY_ERROR' as any;
   readonly message = 'NATIVE_AUTH_STRATEGY_ERROR';
   constructor(
+
   ) {
     super();
   }
@@ -161,6 +182,7 @@ export class NegativeQuantityError extends ErrorResult {
   readonly errorCode = 'NEGATIVE_QUANTITY_ERROR' as any;
   readonly message = 'NEGATIVE_QUANTITY_ERROR';
   constructor(
+
   ) {
     super();
   }
@@ -171,6 +193,7 @@ export class NoActiveOrderError extends ErrorResult {
   readonly errorCode = 'NO_ACTIVE_ORDER_ERROR' as any;
   readonly message = 'NO_ACTIVE_ORDER_ERROR';
   constructor(
+
   ) {
     super();
   }
@@ -181,6 +204,7 @@ export class NotVerifiedError extends ErrorResult {
   readonly errorCode = 'NOT_VERIFIED_ERROR' as any;
   readonly message = 'NOT_VERIFIED_ERROR';
   constructor(
+
   ) {
     super();
   }
@@ -190,10 +214,12 @@ export class OrderLimitError extends ErrorResult {
   readonly __typename = 'OrderLimitError';
   readonly errorCode = 'ORDER_LIMIT_ERROR' as any;
   readonly message = 'ORDER_LIMIT_ERROR';
+  readonly maxItems: Scalars['Int'];
   constructor(
-    public maxItems: Scalars['Int'],
+    input: { maxItems: Scalars['Int'] }
   ) {
     super();
+    this.maxItems = input.maxItems
   }
 }
 
@@ -202,6 +228,7 @@ export class OrderModificationError extends ErrorResult {
   readonly errorCode = 'ORDER_MODIFICATION_ERROR' as any;
   readonly message = 'ORDER_MODIFICATION_ERROR';
   constructor(
+
   ) {
     super();
   }
@@ -212,6 +239,7 @@ export class OrderPaymentStateError extends ErrorResult {
   readonly errorCode = 'ORDER_PAYMENT_STATE_ERROR' as any;
   readonly message = 'ORDER_PAYMENT_STATE_ERROR';
   constructor(
+
   ) {
     super();
   }
@@ -221,12 +249,16 @@ export class OrderStateTransitionError extends ErrorResult {
   readonly __typename = 'OrderStateTransitionError';
   readonly errorCode = 'ORDER_STATE_TRANSITION_ERROR' as any;
   readonly message = 'ORDER_STATE_TRANSITION_ERROR';
+  readonly fromState: Scalars['String'];
+  readonly toState: Scalars['String'];
+  readonly transitionError: Scalars['String'];
   constructor(
-    public fromState: Scalars['String'],
-    public toState: Scalars['String'],
-    public transitionError: Scalars['String'],
+    input: { fromState: Scalars['String'], toState: Scalars['String'], transitionError: Scalars['String'] }
   ) {
     super();
+    this.fromState = input.fromState
+    this.toState = input.toState
+    this.transitionError = input.transitionError
   }
 }
 
@@ -235,6 +267,7 @@ export class PasswordAlreadySetError extends ErrorResult {
   readonly errorCode = 'PASSWORD_ALREADY_SET_ERROR' as any;
   readonly message = 'PASSWORD_ALREADY_SET_ERROR';
   constructor(
+
   ) {
     super();
   }
@@ -245,6 +278,7 @@ export class PasswordResetTokenExpiredError extends ErrorResult {
   readonly errorCode = 'PASSWORD_RESET_TOKEN_EXPIRED_ERROR' as any;
   readonly message = 'PASSWORD_RESET_TOKEN_EXPIRED_ERROR';
   constructor(
+
   ) {
     super();
   }
@@ -255,6 +289,7 @@ export class PasswordResetTokenInvalidError extends ErrorResult {
   readonly errorCode = 'PASSWORD_RESET_TOKEN_INVALID_ERROR' as any;
   readonly message = 'PASSWORD_RESET_TOKEN_INVALID_ERROR';
   constructor(
+
   ) {
     super();
   }
@@ -264,10 +299,12 @@ export class PasswordValidationError extends ErrorResult {
   readonly __typename = 'PasswordValidationError';
   readonly errorCode = 'PASSWORD_VALIDATION_ERROR' as any;
   readonly message = 'PASSWORD_VALIDATION_ERROR';
+  readonly validationErrorMessage: Scalars['String'];
   constructor(
-    public validationErrorMessage: Scalars['String'],
+    input: { validationErrorMessage: Scalars['String'] }
   ) {
     super();
+    this.validationErrorMessage = input.validationErrorMessage
   }
 }
 
@@ -275,10 +312,12 @@ export class PaymentDeclinedError extends ErrorResult {
   readonly __typename = 'PaymentDeclinedError';
   readonly errorCode = 'PAYMENT_DECLINED_ERROR' as any;
   readonly message = 'PAYMENT_DECLINED_ERROR';
+  readonly paymentErrorMessage: Scalars['String'];
   constructor(
-    public paymentErrorMessage: Scalars['String'],
+    input: { paymentErrorMessage: Scalars['String'] }
   ) {
     super();
+    this.paymentErrorMessage = input.paymentErrorMessage
   }
 }
 
@@ -286,10 +325,12 @@ export class PaymentFailedError extends ErrorResult {
   readonly __typename = 'PaymentFailedError';
   readonly errorCode = 'PAYMENT_FAILED_ERROR' as any;
   readonly message = 'PAYMENT_FAILED_ERROR';
+  readonly paymentErrorMessage: Scalars['String'];
   constructor(
-    public paymentErrorMessage: Scalars['String'],
+    input: { paymentErrorMessage: Scalars['String'] }
   ) {
     super();
+    this.paymentErrorMessage = input.paymentErrorMessage
   }
 }
 
@@ -298,6 +339,7 @@ export class VerificationTokenExpiredError extends ErrorResult {
   readonly errorCode = 'VERIFICATION_TOKEN_EXPIRED_ERROR' as any;
   readonly message = 'VERIFICATION_TOKEN_EXPIRED_ERROR';
   constructor(
+
   ) {
     super();
   }
@@ -308,6 +350,7 @@ export class VerificationTokenInvalidError extends ErrorResult {
   readonly errorCode = 'VERIFICATION_TOKEN_INVALID_ERROR' as any;
   readonly message = 'VERIFICATION_TOKEN_INVALID_ERROR';
   constructor(
+
   ) {
     super();
   }

+ 4 - 4
packages/core/src/service/helpers/order-modifier/order-modifier.ts

@@ -265,12 +265,12 @@ export class OrderModifier {
                 quantity,
             );
             if (orderItemsLimit < currentItemsCount + correctedQuantity) {
-                return new OrderLimitError(orderItemsLimit);
+                return new OrderLimitError({ maxItems: orderItemsLimit });
             } else {
                 currentItemsCount += correctedQuantity;
             }
             if (correctedQuantity < quantity) {
-                return new InsufficientStockError(correctedQuantity, order);
+                return new InsufficientStockError({ quantityAvailable: correctedQuantity, order });
             }
             updatedOrderLineIds.push(orderLine.id);
             const initialQuantity = orderLine.quantity;
@@ -299,12 +299,12 @@ export class OrderModifier {
             }
             const resultingOrderTotalQuantity = currentItemsCount + correctedQuantity - orderLine.quantity;
             if (orderItemsLimit < resultingOrderTotalQuantity) {
-                return new OrderLimitError(orderItemsLimit);
+                return new OrderLimitError({ maxItems: orderItemsLimit });
             } else {
                 currentItemsCount += correctedQuantity;
             }
             if (correctedQuantity < quantity) {
-                return new InsufficientStockError(correctedQuantity, order);
+                return new InsufficientStockError({ quantityAvailable: correctedQuantity, order });
             } else {
                 const customFields = (row as any).customFields;
                 if (customFields) {

+ 1 - 1
packages/core/src/service/services/asset.service.ts

@@ -487,7 +487,7 @@ export class AssetService {
     ): Promise<Asset | MimeTypeError> {
         const { assetOptions } = this.configService;
         if (!this.validateMimeType(mimetype)) {
-            return new MimeTypeError(filename, mimetype);
+            return new MimeTypeError({ fileName: filename, mimeType: mimetype });
         }
         const { assetPreviewStrategy, assetStorageStrategy } = assetOptions;
         const sourceFileName = await this.getSourceFileName(ctx, filename);

+ 3 - 3
packages/core/src/service/services/auth.service.ts

@@ -63,10 +63,10 @@ export class AuthService {
         const authenticationStrategy = this.getAuthenticationStrategy(apiType, authenticationMethod);
         const authenticateResult = await authenticationStrategy.authenticate(ctx, authenticationData);
         if (typeof authenticateResult === 'string') {
-            return new InvalidCredentialsError(authenticateResult);
+            return new InvalidCredentialsError({ authenticationError: authenticateResult });
         }
         if (!authenticateResult) {
-            return new InvalidCredentialsError('');
+            return new InvalidCredentialsError({ authenticationError: '' });
         }
         return this.createAuthenticatedSessionForUser(ctx, authenticateResult, authenticationStrategy.name);
     }
@@ -120,7 +120,7 @@ export class AuthService {
         );
         const passwordMatches = await nativeAuthenticationStrategy.verifyUserPassword(ctx, userId, password);
         if (!passwordMatches) {
-            return new InvalidCredentialsError('');
+            return new InvalidCredentialsError({ authenticationError: '' });
         }
         return true;
     }

+ 3 - 3
packages/core/src/service/services/channel.service.ts

@@ -64,7 +64,7 @@ export class ChannelService {
     }
 
     /**
-     * Creates a channels cache, that can be used to reduce number of channel queries to database 
+     * Creates a channels cache, that can be used to reduce number of channel queries to database
      *
      * @internal
      */
@@ -277,7 +277,7 @@ export class ChannelService {
      */
     private async ensureCacheExists() {
         if (this.allChannels) {
-            return
+            return;
         }
 
         this.allChannels = await this.createCache();
@@ -319,7 +319,7 @@ export class ChannelService {
                 .getSettings(ctx)
                 .then(s => s.availableLanguages);
             if (!availableLanguageCodes.includes(input.defaultLanguageCode)) {
-                return new LanguageNotAvailableError(input.defaultLanguageCode);
+                return new LanguageNotAvailableError({ languageCode: input.defaultLanguageCode });
             }
         }
     }

+ 2 - 2
packages/core/src/service/services/fulfillment.service.ts

@@ -67,7 +67,7 @@ export class FulfillmentService {
             if (isObject(e)) {
                 message = (e as any).message || e.toString();
             }
-            return new CreateFulfillmentError(message);
+            return new CreateFulfillmentError({ fulfillmentHandlerError: message });
         }
 
         const newFulfillment = await this.connection.getRepository(ctx, Fulfillment).save(
@@ -160,7 +160,7 @@ export class FulfillmentService {
             await this.fulfillmentStateMachine.transition(ctx, fulfillment, orders, state);
         } catch (e: any) {
             const transitionError = ctx.translate(e.message, { fromState, toState: state });
-            return new FulfillmentStateTransitionError(transitionError, fromState, state);
+            return new FulfillmentStateTransitionError({ transitionError, fromState, toState: state });
         }
         await this.connection.getRepository(ctx, Fulfillment).save(fulfillment, { reload: false });
         this.eventBus.publish(new FulfillmentStateTransitionEvent(fromState, state, ctx, fulfillment));

+ 17 - 17
packages/core/src/service/services/order.service.ts

@@ -451,7 +451,7 @@ export class OrderService {
             existingOrderLine?.quantity,
         );
         if (correctedQuantity === 0) {
-            return new InsufficientStockError(correctedQuantity, order);
+            return new InsufficientStockError({ order, quantityAvailable: correctedQuantity });
         }
         const orderLine = await this.orderModifier.getOrCreateOrderLine(
             ctx,
@@ -468,7 +468,7 @@ export class OrderService {
         const quantityWasAdjustedDown = correctedQuantity < quantity;
         const updatedOrder = await this.applyPriceAdjustments(ctx, order, [orderLine]);
         if (quantityWasAdjustedDown) {
-            return new InsufficientStockError(correctedQuantity, updatedOrder);
+            return new InsufficientStockError({ quantityAvailable: correctedQuantity, order: updatedOrder });
         } else {
             return updatedOrder;
         }
@@ -520,7 +520,7 @@ export class OrderService {
         const quantityWasAdjustedDown = correctedQuantity < quantity;
         const updatedOrder = await this.applyPriceAdjustments(ctx, order, updatedOrderLines);
         if (quantityWasAdjustedDown) {
-            return new InsufficientStockError(correctedQuantity, updatedOrder);
+            return new InsufficientStockError({ quantityAvailable: correctedQuantity, order: updatedOrder });
         } else {
             return updatedOrder;
         }
@@ -821,7 +821,7 @@ export class OrderService {
             await this.orderStateMachine.transition(ctx, order, state);
         } catch (e: any) {
             const transitionError = ctx.translate(e.message, { fromState, toState: state });
-            return new OrderStateTransitionError(transitionError, fromState, state);
+            return new OrderStateTransitionError({ transitionError, fromState, toState: state });
         }
         await this.connection.getRepository(ctx, Order).save(order, { reload: false });
         this.eventBus.publish(new OrderStateTransitionEvent(fromState, state, ctx, order));
@@ -978,10 +978,10 @@ export class OrderService {
         await this.connection.getRepository(ctx, Order).save(order, { reload: false });
 
         if (payment.state === 'Error') {
-            return new PaymentFailedError(payment.errorMessage || '');
+            return new PaymentFailedError({ paymentErrorMessage: payment.errorMessage || '' });
         }
         if (payment.state === 'Declined') {
-            return new PaymentDeclinedError(payment.errorMessage || '');
+            return new PaymentDeclinedError({ paymentErrorMessage: payment.errorMessage || '' });
         }
 
         return this.transitionOrderIfTotalIsCovered(ctx, order);
@@ -1054,7 +1054,7 @@ export class OrderService {
         const payment = await this.paymentService.settlePayment(ctx, paymentId);
         if (!isGraphQlErrorResult(payment)) {
             if (payment.state !== 'Settled') {
-                return new SettlePaymentError(payment.errorMessage || '');
+                return new SettlePaymentError({ paymentErrorMessage: payment.errorMessage || '' });
             }
             const order = await this.findOne(ctx, payment.order.id);
             if (order) {
@@ -1139,11 +1139,11 @@ export class OrderService {
             );
             if (fulfillableStockLevel < lineInput.quantity) {
                 const productVariant = translateDeep(line.productVariant, ctx.languageCode);
-                return new InsufficientStockOnHandError(
-                    productVariant.id as string,
-                    productVariant.name,
-                    productVariant.stockOnHand,
-                );
+                return new InsufficientStockOnHandError({
+                    productVariantId: productVariant.id as string,
+                    productVariantName: productVariant.name,
+                    stockOnHand: productVariant.stockOnHand,
+                });
             }
         }
     }
@@ -1248,7 +1248,7 @@ export class OrderService {
             return new MultipleOrderError();
         }
         if (order.active) {
-            return new CancelActiveOrderError(order.state);
+            return new CancelActiveOrderError({ orderState: order.state });
         }
         const fullOrder = await this.findOne(ctx, order.id);
 
@@ -1330,13 +1330,13 @@ export class OrderService {
             order.state === 'ArrangingPayment' ||
             order.state === 'PaymentAuthorized'
         ) {
-            return new RefundOrderStateError(order.state);
+            return new RefundOrderStateError({ orderState: order.state });
         }
         const alreadyRefunded = items.find(
             i => i.refund?.state === 'Pending' || i.refund?.state === 'Settled',
         );
         if (alreadyRefunded) {
-            return new AlreadyRefundedError(alreadyRefunded.refundId as string);
+            return new AlreadyRefundedError({ refundId: alreadyRefunded.refundId as string });
         }
 
         return await this.paymentService.createRefund(ctx, input, order, items, payment);
@@ -1552,7 +1552,7 @@ export class OrderService {
         const currentItemsCount = summate(order.lines, 'quantity');
         const { orderItemsLimit } = this.configService.orderOptions;
         if (orderItemsLimit < currentItemsCount + quantityToAdd) {
-            return new OrderLimitError(orderItemsLimit);
+            return new OrderLimitError({ maxItems: orderItemsLimit });
         }
     }
 
@@ -1564,7 +1564,7 @@ export class OrderService {
         const currentQuantity = orderLine?.quantity || 0;
         const { orderLineItemsLimit } = this.configService.orderOptions;
         if (orderLineItemsLimit < currentQuantity + quantityToAdd) {
-            return new OrderLimitError(orderLineItemsLimit);
+            return new OrderLimitError({ maxItems: orderLineItemsLimit });
         }
     }
 

+ 10 - 4
packages/core/src/service/services/payment.service.ts

@@ -85,7 +85,7 @@ export class PaymentService {
             await this.paymentStateMachine.transition(ctx, payment.order, payment, state);
         } catch (e: any) {
             const transitionError = ctx.translate(e.message, { fromState, toState: state });
-            return new PaymentStateTransitionError(transitionError, fromState, state);
+            return new PaymentStateTransitionError({ transitionError, fromState, toState: state });
         }
         await this.connection.getRepository(ctx, Payment).save(payment, { reload: false });
         this.eventBus.publish(new PaymentStateTransitionEvent(fromState, state, ctx, payment, payment.order));
@@ -119,7 +119,9 @@ export class PaymentService {
         if (paymentMethod.checker && checker) {
             const eligible = await checker.check(ctx, order, paymentMethod.checker.args);
             if (eligible === false || typeof eligible === 'string') {
-                return new IneligiblePaymentMethodError(typeof eligible === 'string' ? eligible : undefined);
+                return new IneligiblePaymentMethodError({
+                    eligibilityCheckerMessage: typeof eligible === 'string' ? eligible : undefined,
+                });
             }
         }
         const result = await handler.createPayment(
@@ -176,7 +178,7 @@ export class PaymentService {
             await this.paymentStateMachine.transition(ctx, payment.order, payment, toState);
         } catch (e: any) {
             const transitionError = ctx.translate(e.message, { fromState, toState });
-            return new PaymentStateTransitionError(transitionError, fromState, toState);
+            return new PaymentStateTransitionError({ transitionError, fromState, toState });
         }
         await this.connection.getRepository(ctx, Payment).save(payment, { reload: false });
         this.eventBus.publish(
@@ -299,7 +301,11 @@ export class PaymentService {
                 try {
                     await this.refundStateMachine.transition(ctx, order, refund, createRefundResult.state);
                 } catch (e: any) {
-                    return new RefundStateTransitionError(e.message, fromState, createRefundResult.state);
+                    return new RefundStateTransitionError({
+                        transitionError: e.message,
+                        fromState,
+                        toState: createRefundResult.state,
+                    });
                 }
                 await this.connection.getRepository(ctx, Refund).save(refund, { reload: false });
                 this.eventBus.publish(

+ 4 - 1
packages/core/src/service/services/product.service.ts

@@ -343,7 +343,10 @@ export class ProductService {
             throw new EntityNotFoundError('ProductOptionGroup', optionGroupId);
         }
         if (product.variants.length) {
-            return new ProductOptionInUseError(optionGroup.code, product.variants.length);
+            return new ProductOptionInUseError({
+                optionGroupCode: optionGroup.code,
+                productVariantCount: product.variants.length,
+            });
         }
         product.optionGroups = product.optionGroups.filter(g => g.id !== optionGroupId);
 

+ 3 - 3
packages/core/src/service/services/promotion.service.ts

@@ -220,15 +220,15 @@ export class PromotionService {
             },
         });
         if (!promotion) {
-            return new CouponCodeInvalidError(couponCode);
+            return new CouponCodeInvalidError({ couponCode });
         }
         if (promotion.endsAt && +promotion.endsAt < +new Date()) {
-            return new CouponCodeExpiredError(couponCode);
+            return new CouponCodeExpiredError({ couponCode });
         }
         if (customerId && promotion.perCustomerUsageLimit != null) {
             const usageCount = await this.countPromotionUsagesForCustomer(ctx, promotion.id, customerId);
             if (promotion.perCustomerUsageLimit <= usageCount) {
-                return new CouponCodeLimitError(couponCode, promotion.perCustomerUsageLimit);
+                return new CouponCodeLimitError({ couponCode, limit: promotion.perCustomerUsageLimit });
             }
         }
         return promotion;

+ 2 - 2
packages/core/src/service/services/user.service.ts

@@ -372,7 +372,7 @@ export class UserService {
         const nativeAuthMethod = user.getNativeAuthenticationMethod();
         const matches = await this.passwordCipher.check(currentPassword, nativeAuthMethod.passwordHash);
         if (!matches) {
-            return new InvalidCredentialsError('');
+            return new InvalidCredentialsError({ authenticationError: '' });
         }
         nativeAuthMethod.passwordHash = await this.passwordCipher.hash(newPassword);
         await this.connection
@@ -392,7 +392,7 @@ export class UserService {
                 typeof passwordValidationResult === 'string'
                     ? passwordValidationResult
                     : 'Password is invalid';
-            return new PasswordValidationError(message);
+            return new PasswordValidationError({ validationErrorMessage: message });
         } else {
             return true;
         }

+ 43 - 29
packages/elasticsearch-plugin/e2e/e2e-helpers.ts

@@ -2,25 +2,33 @@ import { Client } from '@elastic/elasticsearch';
 import { SortOrder } from '@vendure/common/lib/generated-types';
 import { SimpleGraphQLClient } from '@vendure/testing';
 
-import { SearchGetPrices, SearchInput } from '../../core/e2e/graphql/generated-e2e-admin-types';
-import { LogicalOperator, SearchProductsShop } from '../../core/e2e/graphql/generated-e2e-shop-types';
+import { SearchGetPricesQuery, SearchInput } from '../../core/e2e/graphql/generated-e2e-admin-types';
+import {
+    LogicalOperator,
+    SearchProductsShopQuery,
+    SearchProductsShopQueryVariables,
+} from '../../core/e2e/graphql/generated-e2e-shop-types';
 import { SEARCH_PRODUCTS_SHOP } from '../../core/e2e/graphql/shop-definitions';
 import { deleteIndices } from '../src/indexing/indexing-utils';
 
 import { SEARCH_GET_PRICES, SEARCH_PRODUCTS } from './elasticsearch-plugin.e2e-spec';
-import { SearchProductsAdmin } from './graphql/generated-e2e-elasticsearch-plugin-types';
+import {
+    SearchGetPricesQueryVariables,
+    SearchProductsAdminQuery,
+    SearchProductsAdminQueryVariables,
+} from './graphql/generated-e2e-elasticsearch-plugin-types';
 
 // tslint:disable-next-line:no-var-requires
 const { elasticsearchHost, elasticsearchPort } = require('./constants');
 
 export function doAdminSearchQuery(client: SimpleGraphQLClient, input: SearchInput) {
-    return client.query<SearchProductsAdmin.Query, SearchProductsAdmin.Variables>(SEARCH_PRODUCTS, {
+    return client.query<SearchProductsAdminQuery, SearchProductsAdminQueryVariables>(SEARCH_PRODUCTS, {
         input,
     });
 }
 
 export async function testGroupByProduct(client: SimpleGraphQLClient) {
-    const result = await client.query<SearchProductsShop.Query, SearchProductsShop.Variables>(
+    const result = await client.query<SearchProductsShopQuery, SearchProductsShopQueryVariables>(
         SEARCH_PRODUCTS_SHOP,
         {
             input: {
@@ -32,7 +40,7 @@ export async function testGroupByProduct(client: SimpleGraphQLClient) {
 }
 
 export async function testNoGrouping(client: SimpleGraphQLClient) {
-    const result = await client.query<SearchProductsShop.Query, SearchProductsShop.Variables>(
+    const result = await client.query<SearchProductsShopQuery, SearchProductsShopQueryVariables>(
         SEARCH_PRODUCTS_SHOP,
         {
             input: {
@@ -44,7 +52,7 @@ export async function testNoGrouping(client: SimpleGraphQLClient) {
 }
 
 export async function testMatchSearchTerm(client: SimpleGraphQLClient) {
-    const result = await client.query<SearchProductsShop.Query, SearchProductsShop.Variables>(
+    const result = await client.query<SearchProductsShopQuery, SearchProductsShopQueryVariables>(
         SEARCH_PRODUCTS_SHOP,
         {
             input: {
@@ -61,7 +69,7 @@ export async function testMatchSearchTerm(client: SimpleGraphQLClient) {
 }
 
 export async function testMatchFacetIdsAnd(client: SimpleGraphQLClient) {
-    const result = await client.query<SearchProductsShop.Query, SearchProductsShop.Variables>(
+    const result = await client.query<SearchProductsShopQuery, SearchProductsShopQueryVariables>(
         SEARCH_PRODUCTS_SHOP,
         {
             input: {
@@ -85,7 +93,7 @@ export async function testMatchFacetIdsAnd(client: SimpleGraphQLClient) {
 }
 
 export async function testMatchFacetIdsOr(client: SimpleGraphQLClient) {
-    const result = await client.query<SearchProductsShop.Query, SearchProductsShop.Variables>(
+    const result = await client.query<SearchProductsShopQuery, SearchProductsShopQueryVariables>(
         SEARCH_PRODUCTS_SHOP,
         {
             input: {
@@ -117,7 +125,7 @@ export async function testMatchFacetIdsOr(client: SimpleGraphQLClient) {
 }
 
 export async function testMatchFacetValueFiltersAnd(client: SimpleGraphQLClient) {
-    const result = await client.query<SearchProductsShop.Query, SearchProductsShop.Variables>(
+    const result = await client.query<SearchProductsShopQuery, SearchProductsShopQueryVariables>(
         SEARCH_PRODUCTS_SHOP,
         {
             input: {
@@ -132,7 +140,7 @@ export async function testMatchFacetValueFiltersAnd(client: SimpleGraphQLClient)
 }
 
 export async function testMatchFacetValueFiltersOr(client: SimpleGraphQLClient) {
-    const result = await client.query<SearchProductsShop.Query, SearchProductsShop.Variables>(
+    const result = await client.query<SearchProductsShopQuery, SearchProductsShopQueryVariables>(
         SEARCH_PRODUCTS_SHOP,
         {
             input: {
@@ -165,7 +173,7 @@ export async function testMatchFacetValueFiltersOr(client: SimpleGraphQLClient)
 }
 
 export async function testMatchFacetValueFiltersOrWithAnd(client: SimpleGraphQLClient) {
-    const result = await client.query<SearchProductsShop.Query, SearchProductsShop.Variables>(
+    const result = await client.query<SearchProductsShopQuery, SearchProductsShopQueryVariables>(
         SEARCH_PRODUCTS_SHOP,
         {
             input: {
@@ -191,7 +199,7 @@ export async function testMatchFacetValueFiltersOrWithAnd(client: SimpleGraphQLC
 }
 
 export async function testMatchFacetValueFiltersWithFacetIdsOr(client: SimpleGraphQLClient) {
-    const result = await client.query<SearchProductsShop.Query, SearchProductsShop.Variables>(
+    const result = await client.query<SearchProductsShopQuery, SearchProductsShopQueryVariables>(
         SEARCH_PRODUCTS_SHOP,
         {
             input: {
@@ -219,7 +227,7 @@ export async function testMatchFacetValueFiltersWithFacetIdsOr(client: SimpleGra
 }
 
 export async function testMatchFacetValueFiltersWithFacetIdsAnd(client: SimpleGraphQLClient) {
-    const result = await client.query<SearchProductsShop.Query, SearchProductsShop.Variables>(
+    const result = await client.query<SearchProductsShopQuery, SearchProductsShopQueryVariables>(
         SEARCH_PRODUCTS_SHOP,
         {
             input: {
@@ -236,7 +244,7 @@ export async function testMatchFacetValueFiltersWithFacetIdsAnd(client: SimpleGr
 }
 
 export async function testMatchCollectionId(client: SimpleGraphQLClient) {
-    const result = await client.query<SearchProductsShop.Query, SearchProductsShop.Variables>(
+    const result = await client.query<SearchProductsShopQuery, SearchProductsShopQueryVariables>(
         SEARCH_PRODUCTS_SHOP,
         {
             input: {
@@ -253,7 +261,7 @@ export async function testMatchCollectionId(client: SimpleGraphQLClient) {
 }
 
 export async function testMatchCollectionSlug(client: SimpleGraphQLClient) {
-    const result = await client.query<SearchProductsShop.Query, SearchProductsShop.Variables>(
+    const result = await client.query<SearchProductsShopQuery, SearchProductsShopQueryVariables>(
         SEARCH_PRODUCTS_SHOP,
         {
             input: {
@@ -270,15 +278,18 @@ export async function testMatchCollectionSlug(client: SimpleGraphQLClient) {
 }
 
 export async function testSinglePrices(client: SimpleGraphQLClient) {
-    const result = await client.query<SearchGetPrices.Query, SearchGetPrices.Variables>(SEARCH_GET_PRICES, {
-        input: {
-            groupByProduct: false,
-            take: 3,
-            sort: {
-                price: SortOrder.ASC,
+    const result = await client.query<SearchGetPricesQuery, SearchGetPricesQueryVariables>(
+        SEARCH_GET_PRICES,
+        {
+            input: {
+                groupByProduct: false,
+                take: 3,
+                sort: {
+                    price: SortOrder.ASC,
+                },
             },
         },
-    });
+    );
     expect(result.search.items).toEqual([
         {
             price: { value: 799 },
@@ -296,13 +307,16 @@ export async function testSinglePrices(client: SimpleGraphQLClient) {
 }
 
 export async function testPriceRanges(client: SimpleGraphQLClient) {
-    const result = await client.query<SearchGetPrices.Query, SearchGetPrices.Variables>(SEARCH_GET_PRICES, {
-        input: {
-            groupByProduct: true,
-            take: 3,
-            term: 'laptop',
+    const result = await client.query<SearchGetPricesQuery, SearchGetPricesQueryVariables>(
+        SEARCH_GET_PRICES,
+        {
+            input: {
+                groupByProduct: true,
+                take: 3,
+                term: 'laptop',
+            },
         },
-    });
+    );
     expect(result.search.items).toEqual([
         {
             price: { min: 129900, max: 229900 },

+ 9 - 6
packages/elasticsearch-plugin/e2e/elasticsearch-plugin-uuid.e2e-spec.ts

@@ -5,12 +5,15 @@ import path from 'path';
 
 import { initialData } from '../../../e2e-common/e2e-initial-data';
 import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
-import { SearchProductsShop } from '../../core/e2e/graphql/generated-e2e-shop-types';
+import {
+    SearchProductsShopQuery,
+    SearchProductsShopQueryVariables,
+} from '../../core/e2e/graphql/generated-e2e-shop-types';
 import { SEARCH_PRODUCTS_SHOP } from '../../core/e2e/graphql/shop-definitions';
 import { awaitRunningJobs } from '../../core/e2e/utils/await-running-jobs';
 import { ElasticsearchPlugin } from '../src/plugin';
 
-import { GetCollectionList } from './graphql/generated-e2e-elasticsearch-plugin-types';
+import { GetCollectionListQuery } from './graphql/generated-e2e-elasticsearch-plugin-types';
 // tslint:disable-next-line:no-var-requires
 const { elasticsearchHost, elasticsearchPort } = require('./constants');
 
@@ -55,7 +58,7 @@ describe('Elasticsearch plugin with UuidIdStrategy', () => {
     });
 
     it('no term or filters', async () => {
-        const { search } = await shopClient.query<SearchProductsShop.Query, SearchProductsShop.Variables>(
+        const { search } = await shopClient.query<SearchProductsShopQuery, SearchProductsShopQueryVariables>(
             SEARCH_PRODUCTS_SHOP,
             {
                 input: {
@@ -67,7 +70,7 @@ describe('Elasticsearch plugin with UuidIdStrategy', () => {
     });
 
     it('with search term', async () => {
-        const { search } = await shopClient.query<SearchProductsShop.Query, SearchProductsShop.Variables>(
+        const { search } = await shopClient.query<SearchProductsShopQuery, SearchProductsShopQueryVariables>(
             SEARCH_PRODUCTS_SHOP,
             {
                 input: {
@@ -80,8 +83,8 @@ describe('Elasticsearch plugin with UuidIdStrategy', () => {
     });
 
     it('with collectionId filter term', async () => {
-        const { collections } = await shopClient.query<GetCollectionList.Query>(GET_COLLECTION_LIST);
-        const { search } = await shopClient.query<SearchProductsShop.Query, SearchProductsShop.Variables>(
+        const { collections } = await shopClient.query<GetCollectionListQuery>(GET_COLLECTION_LIST);
+        const { search } = await shopClient.query<SearchProductsShopQuery, SearchProductsShopQueryVariables>(
             SEARCH_PRODUCTS_SHOP,
             {
                 input: {

+ 236 - 238
packages/elasticsearch-plugin/e2e/elasticsearch-plugin.e2e-spec.ts

@@ -1,13 +1,7 @@
 /* tslint:disable:no-non-null-assertion no-console */
-import { SortOrder } from '@vendure/common/lib/generated-types';
+import { CurrencyCode, SortOrder } from '@vendure/common/lib/generated-types';
 import { pick } from '@vendure/common/lib/pick';
-import {
-    DefaultJobQueuePlugin,
-    DefaultLogger,
-    facetValueCollectionFilter,
-    LogLevel,
-    mergeConfig,
-} from '@vendure/core';
+import { DefaultJobQueuePlugin, facetValueCollectionFilter, LanguageCode, mergeConfig } from '@vendure/core';
 import { createTestEnvironment, E2E_DEFAULT_CHANNEL_TOKEN } from '@vendure/testing';
 import { fail } from 'assert';
 import gql from 'graphql-tag';
@@ -15,33 +9,11 @@ import path from 'path';
 
 import { initialData } from '../../../e2e-common/e2e-initial-data';
 import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
+import * as Codegen from '../../core/e2e/graphql/generated-e2e-admin-types';
 import {
-    AssignProductsToChannel,
-    AssignProductVariantsToChannel,
-    ChannelFragment,
-    CreateChannel,
-    CreateCollection,
-    CreateFacet,
-    CreateProduct,
-    CreateProductVariants,
-    CurrencyCode,
-    DeleteAsset,
-    DeleteProduct,
-    DeleteProductVariant,
-    LanguageCode,
-    RemoveProductsFromChannel,
-    RemoveProductVariantsFromChannel,
-    SearchCollections,
-    SearchFacetValues,
-    SearchGetPrices,
-    SearchInput,
-    UpdateAsset,
-    UpdateCollection,
-    UpdateProduct,
-    UpdateProductVariants,
-    UpdateTaxRate,
-} from '../../core/e2e/graphql/generated-e2e-admin-types';
-import { SearchProductsShop } from '../../core/e2e/graphql/generated-e2e-shop-types';
+    SearchProductsShopQuery,
+    SearchProductsShopQueryVariables,
+} from '../../core/e2e/graphql/generated-e2e-shop-types';
 import {
     ASSIGN_PRODUCTVARIANT_TO_CHANNEL,
     ASSIGN_PRODUCT_TO_CHANNEL,
@@ -84,10 +56,9 @@ import {
     testSinglePrices,
 } from './e2e-helpers';
 import {
-    GetJobInfo,
+    GetJobInfoQuery,
+    GetJobInfoQueryVariables,
     JobState,
-    Reindex,
-    SearchProductsAdmin,
 } from './graphql/generated-e2e-elasticsearch-plugin-types';
 
 // tslint:disable-next-line:no-var-requires
@@ -101,8 +72,8 @@ if (process.env.CI) {
     jest.setTimeout(10 * 3000);
 }
 
-interface SearchProductShopVariables extends SearchProductsShop.Variables {
-    input: SearchProductsShop.Variables['input'] & {
+interface SearchProductShopVariables extends SearchProductsShopQueryVariables {
+    input: SearchProductsShopQueryVariables['input'] & {
         // This input field is dynamically added only when the `indexStockStatus` init option
         // of DefaultSearchPlugin is set to `true`, and therefore not included in the generated type. Therefore
         // we need to manually patch it here.
@@ -234,14 +205,14 @@ describe('Elasticsearch plugin', () => {
         it('price ranges', () => testPriceRanges(shopClient));
 
         it('returns correct facetValues when not grouped by product', async () => {
-            const result = await shopClient.query<SearchFacetValues.Query, SearchFacetValues.Variables>(
-                SEARCH_GET_FACET_VALUES,
-                {
-                    input: {
-                        groupByProduct: false,
-                    },
+            const result = await shopClient.query<
+                Codegen.SearchFacetValuesQuery,
+                Codegen.SearchFacetValuesQueryVariables
+            >(SEARCH_GET_FACET_VALUES, {
+                input: {
+                    groupByProduct: false,
                 },
-            );
+            });
             expect(result.search.facetValues).toEqual([
                 { count: 21, facetValue: { id: 'T_1', name: 'electronics' } },
                 { count: 17, facetValue: { id: 'T_2', name: 'computers' } },
@@ -253,14 +224,14 @@ describe('Elasticsearch plugin', () => {
         });
 
         it('returns correct facetValues when grouped by product', async () => {
-            const result = await shopClient.query<SearchFacetValues.Query, SearchFacetValues.Variables>(
-                SEARCH_GET_FACET_VALUES,
-                {
-                    input: {
-                        groupByProduct: true,
-                    },
+            const result = await shopClient.query<
+                Codegen.SearchFacetValuesQuery,
+                Codegen.SearchFacetValuesQueryVariables
+            >(SEARCH_GET_FACET_VALUES, {
+                input: {
+                    groupByProduct: true,
                 },
-            );
+            });
             expect(result.search.facetValues).toEqual([
                 { count: 10, facetValue: { id: 'T_1', name: 'electronics' } },
                 { count: 6, facetValue: { id: 'T_2', name: 'computers' } },
@@ -272,40 +243,43 @@ describe('Elasticsearch plugin', () => {
         });
 
         it('omits facetValues of private facets', async () => {
-            const { createFacet } = await adminClient.query<CreateFacet.Mutation, CreateFacet.Variables>(
-                CREATE_FACET,
+            const { createFacet } = await adminClient.query<
+                Codegen.CreateFacetMutation,
+                Codegen.CreateFacetMutationVariables
+            >(CREATE_FACET, {
+                input: {
+                    code: 'profit-margin',
+                    isPrivate: true,
+                    translations: [{ languageCode: LanguageCode.en, name: 'Profit Margin' }],
+                    values: [
+                        {
+                            code: 'massive',
+                            translations: [{ languageCode: LanguageCode.en, name: 'massive' }],
+                        },
+                    ],
+                },
+            });
+            await adminClient.query<Codegen.UpdateProductMutation, Codegen.UpdateProductMutationVariables>(
+                UPDATE_PRODUCT,
                 {
                     input: {
-                        code: 'profit-margin',
-                        isPrivate: true,
-                        translations: [{ languageCode: LanguageCode.en, name: 'Profit Margin' }],
-                        values: [
-                            {
-                                code: 'massive',
-                                translations: [{ languageCode: LanguageCode.en, name: 'massive' }],
-                            },
-                        ],
+                        id: 'T_2',
+                        // T_1 & T_2 are the existing facetValues (electronics & photo)
+                        facetValueIds: ['T_1', 'T_2', createFacet.values[0].id],
                     },
                 },
             );
-            await adminClient.query<UpdateProduct.Mutation, UpdateProduct.Variables>(UPDATE_PRODUCT, {
-                input: {
-                    id: 'T_2',
-                    // T_1 & T_2 are the existing facetValues (electronics & photo)
-                    facetValueIds: ['T_1', 'T_2', createFacet.values[0].id],
-                },
-            });
 
             await awaitRunningJobs(adminClient);
 
-            const result = await shopClient.query<SearchFacetValues.Query, SearchFacetValues.Variables>(
-                SEARCH_GET_FACET_VALUES,
-                {
-                    input: {
-                        groupByProduct: true,
-                    },
+            const result = await shopClient.query<
+                Codegen.SearchFacetValuesQuery,
+                Codegen.SearchFacetValuesQueryVariables
+            >(SEARCH_GET_FACET_VALUES, {
+                input: {
+                    groupByProduct: true,
                 },
-            );
+            });
             expect(result.search.facetValues).toEqual([
                 { count: 10, facetValue: { id: 'T_1', name: 'electronics' } },
                 { count: 6, facetValue: { id: 'T_2', name: 'computers' } },
@@ -317,35 +291,35 @@ describe('Elasticsearch plugin', () => {
         });
 
         it('returns correct collections when not grouped by product', async () => {
-            const result = await shopClient.query<SearchCollections.Query, SearchCollections.Variables>(
-                SEARCH_GET_COLLECTIONS,
-                {
-                    input: {
-                        groupByProduct: false,
-                    },
+            const result = await shopClient.query<
+                Codegen.SearchCollectionsQuery,
+                Codegen.SearchCollectionsQueryVariables
+            >(SEARCH_GET_COLLECTIONS, {
+                input: {
+                    groupByProduct: false,
                 },
-            );
+            });
             expect(result.search.collections).toEqual([
                 { collection: { id: 'T_2', name: 'Plants' }, count: 3 },
             ]);
         });
 
         it('returns correct collections when grouped by product', async () => {
-            const result = await shopClient.query<SearchCollections.Query, SearchCollections.Variables>(
-                SEARCH_GET_COLLECTIONS,
-                {
-                    input: {
-                        groupByProduct: true,
-                    },
+            const result = await shopClient.query<
+                Codegen.SearchCollectionsQuery,
+                Codegen.SearchCollectionsQueryVariables
+            >(SEARCH_GET_COLLECTIONS, {
+                input: {
+                    groupByProduct: true,
                 },
-            );
+            });
             expect(result.search.collections).toEqual([
                 { collection: { id: 'T_2', name: 'Plants' }, count: 3 },
             ]);
         });
 
         it('encodes the productId and productVariantId', async () => {
-            const result = await shopClient.query<SearchProductsShop.Query, SearchProductShopVariables>(
+            const result = await shopClient.query<SearchProductsShopQuery, SearchProductShopVariables>(
                 SEARCH_PRODUCTS_SHOP,
                 {
                     input: {
@@ -362,14 +336,14 @@ describe('Elasticsearch plugin', () => {
         });
 
         it('omits results for disabled ProductVariants', async () => {
-            await adminClient.query<UpdateProductVariants.Mutation, UpdateProductVariants.Variables>(
-                UPDATE_PRODUCT_VARIANTS,
-                {
-                    input: [{ id: 'T_3', enabled: false }],
-                },
-            );
+            await adminClient.query<
+                Codegen.UpdateProductVariantsMutation,
+                Codegen.UpdateProductVariantsMutationVariables
+            >(UPDATE_PRODUCT_VARIANTS, {
+                input: [{ id: 'T_3', enabled: false }],
+            });
             await awaitRunningJobs(adminClient);
-            const result = await shopClient.query<SearchProductsShop.Query, SearchProductShopVariables>(
+            const result = await shopClient.query<SearchProductsShopQuery, SearchProductShopVariables>(
                 SEARCH_PRODUCTS_SHOP,
                 {
                     input: {
@@ -382,7 +356,7 @@ describe('Elasticsearch plugin', () => {
         });
 
         it('encodes collectionIds', async () => {
-            const result = await shopClient.query<SearchProductsShop.Query, SearchProductShopVariables>(
+            const result = await shopClient.query<SearchProductsShopQuery, SearchProductShopVariables>(
                 SEARCH_PRODUCTS_SHOP,
                 {
                     input: {
@@ -397,7 +371,7 @@ describe('Elasticsearch plugin', () => {
         });
 
         it('inStock is false and not grouped by product', async () => {
-            const result = await shopClient.query<SearchProductsShop.Query, SearchProductShopVariables>(
+            const result = await shopClient.query<SearchProductsShopQuery, SearchProductShopVariables>(
                 SEARCH_PRODUCTS_SHOP,
                 {
                     input: {
@@ -410,7 +384,7 @@ describe('Elasticsearch plugin', () => {
         });
 
         it('inStock is false and grouped by product', async () => {
-            const result = await shopClient.query<SearchProductsShop.Query, SearchProductShopVariables>(
+            const result = await shopClient.query<SearchProductsShopQuery, SearchProductShopVariables>(
                 SEARCH_PRODUCTS_SHOP,
                 {
                     input: {
@@ -423,7 +397,7 @@ describe('Elasticsearch plugin', () => {
         });
 
         it('inStock is true and not grouped by product', async () => {
-            const result = await shopClient.query<SearchProductsShop.Query, SearchProductShopVariables>(
+            const result = await shopClient.query<SearchProductsShopQuery, SearchProductShopVariables>(
                 SEARCH_PRODUCTS_SHOP,
                 {
                     input: {
@@ -436,7 +410,7 @@ describe('Elasticsearch plugin', () => {
         });
 
         it('inStock is true and grouped by product', async () => {
-            const result = await shopClient.query<SearchProductsShop.Query, SearchProductShopVariables>(
+            const result = await shopClient.query<SearchProductsShopQuery, SearchProductShopVariables>(
                 SEARCH_PRODUCTS_SHOP,
                 {
                     input: {
@@ -449,7 +423,7 @@ describe('Elasticsearch plugin', () => {
         });
 
         it('inStock is undefined and not grouped by product', async () => {
-            const result = await shopClient.query<SearchProductsShop.Query, SearchProductShopVariables>(
+            const result = await shopClient.query<SearchProductsShopQuery, SearchProductShopVariables>(
                 SEARCH_PRODUCTS_SHOP,
                 {
                     input: {
@@ -462,7 +436,7 @@ describe('Elasticsearch plugin', () => {
         });
 
         it('inStock is undefined and grouped by product', async () => {
-            const result = await shopClient.query<SearchProductsShop.Query, SearchProductShopVariables>(
+            const result = await shopClient.query<SearchProductsShopQuery, SearchProductShopVariables>(
                 SEARCH_PRODUCTS_SHOP,
                 {
                     input: {
@@ -521,15 +495,15 @@ describe('Elasticsearch plugin', () => {
                     'IHD455T6',
                 ]);
 
-                await adminClient.query<UpdateProductVariants.Mutation, UpdateProductVariants.Variables>(
-                    UPDATE_PRODUCT_VARIANTS,
-                    {
-                        input: search.items.map(i => ({
-                            id: i.productVariantId,
-                            sku: i.sku + '_updated',
-                        })),
-                    },
-                );
+                await adminClient.query<
+                    Codegen.UpdateProductVariantsMutation,
+                    Codegen.UpdateProductVariantsMutationVariables
+                >(UPDATE_PRODUCT_VARIANTS, {
+                    input: search.items.map(i => ({
+                        id: i.productVariantId,
+                        sku: i.sku + '_updated',
+                    })),
+                });
                 await awaitRunningJobs(adminClient);
                 const { search: search2 } = await doAdminSearchQuery(adminClient, {
                     term: 'drive',
@@ -552,12 +526,12 @@ describe('Elasticsearch plugin', () => {
                     groupByProduct: false,
                 });
 
-                await adminClient.query<DeleteProductVariant.Mutation, DeleteProductVariant.Variables>(
-                    DELETE_PRODUCT_VARIANT,
-                    {
-                        id: search.items[0].productVariantId,
-                    },
-                );
+                await adminClient.query<
+                    Codegen.DeleteProductVariantMutation,
+                    Codegen.DeleteProductVariantMutationVariables
+                >(DELETE_PRODUCT_VARIANT, {
+                    id: search.items[0].productVariantId,
+                });
 
                 await awaitRunningJobs(adminClient);
                 await awaitRunningJobs(adminClient);
@@ -575,7 +549,10 @@ describe('Elasticsearch plugin', () => {
             });
 
             it('updates index when a Product is changed', async () => {
-                await adminClient.query<UpdateProduct.Mutation, UpdateProduct.Variables>(UPDATE_PRODUCT, {
+                await adminClient.query<
+                    Codegen.UpdateProductMutation,
+                    Codegen.UpdateProductMutationVariables
+                >(UPDATE_PRODUCT, {
                     input: {
                         id: 'T_1',
                         facetValueIds: [],
@@ -607,7 +584,10 @@ describe('Elasticsearch plugin', () => {
                     'T_5',
                     'T_6',
                 ]);
-                await adminClient.query<DeleteProduct.Mutation, DeleteProduct.Variables>(DELETE_PRODUCT, {
+                await adminClient.query<
+                    Codegen.DeleteProductMutation,
+                    Codegen.DeleteProductMutationVariables
+                >(DELETE_PRODUCT, {
                     id: 'T_5',
                 });
                 await awaitRunningJobs(adminClient);
@@ -619,29 +599,29 @@ describe('Elasticsearch plugin', () => {
             });
 
             it('updates index when a Collection is changed', async () => {
-                await adminClient.query<UpdateCollection.Mutation, UpdateCollection.Variables>(
-                    UPDATE_COLLECTION,
-                    {
-                        input: {
-                            id: 'T_2',
-                            filters: [
-                                {
-                                    code: facetValueCollectionFilter.code,
-                                    arguments: [
-                                        {
-                                            name: 'facetValueIds',
-                                            value: `["T_4"]`,
-                                        },
-                                        {
-                                            name: 'containsAny',
-                                            value: `false`,
-                                        },
-                                    ],
-                                },
-                            ],
-                        },
+                await adminClient.query<
+                    Codegen.UpdateCollectionMutation,
+                    Codegen.UpdateCollectionMutationVariables
+                >(UPDATE_COLLECTION, {
+                    input: {
+                        id: 'T_2',
+                        filters: [
+                            {
+                                code: facetValueCollectionFilter.code,
+                                arguments: [
+                                    {
+                                        name: 'facetValueIds',
+                                        value: `["T_4"]`,
+                                    },
+                                    {
+                                        name: 'containsAny',
+                                        value: `false`,
+                                    },
+                                ],
+                            },
+                        ],
                     },
-                );
+                });
                 await awaitRunningJobs(adminClient);
                 // add an additional check for the collection filters to update
                 await awaitRunningJobs(adminClient);
@@ -678,8 +658,8 @@ describe('Elasticsearch plugin', () => {
 
             it('updates index when a Collection created', async () => {
                 const { createCollection } = await adminClient.query<
-                    CreateCollection.Mutation,
-                    CreateCollection.Variables
+                    Codegen.CreateCollectionMutation,
+                    Codegen.CreateCollectionMutationVariables
                 >(CREATE_COLLECTION, {
                     input: {
                         translations: [
@@ -723,7 +703,10 @@ describe('Elasticsearch plugin', () => {
             });
 
             it('updates index when a taxRate is changed', async () => {
-                await adminClient.query<UpdateTaxRate.Mutation, UpdateTaxRate.Variables>(UPDATE_TAX_RATE, {
+                await adminClient.query<
+                    Codegen.UpdateTaxRateMutation,
+                    Codegen.UpdateTaxRateMutationVariables
+                >(UPDATE_TAX_RATE, {
                     input: {
                         // Default Channel's defaultTaxZone is Europe (id 2) and the id of the standard TaxRate
                         // to Europe is 2.
@@ -732,15 +715,15 @@ describe('Elasticsearch plugin', () => {
                     },
                 });
                 await awaitRunningJobs(adminClient);
-                const result = await adminClient.query<SearchGetPrices.Query, SearchGetPrices.Variables>(
-                    SEARCH_GET_PRICES,
-                    {
-                        input: {
-                            groupByProduct: true,
-                            term: 'laptop',
-                        } as SearchInput,
-                    },
-                );
+                const result = await adminClient.query<
+                    Codegen.SearchGetPricesQuery,
+                    Codegen.SearchGetPricesQueryVariables
+                >(SEARCH_GET_PRICES, {
+                    input: {
+                        groupByProduct: true,
+                        term: 'laptop',
+                    } as Codegen.SearchInput,
+                });
                 expect(result.search.items).toEqual([
                     {
                         price: { min: 129900, max: 229900 },
@@ -767,7 +750,10 @@ describe('Elasticsearch plugin', () => {
                     expect(search1.items[0].productAsset!.id).toBe('T_1');
                     expect(search1.items[0].productAsset!.focalPoint).toBeNull();
 
-                    await adminClient.query<UpdateAsset.Mutation, UpdateAsset.Variables>(UPDATE_ASSET, {
+                    await adminClient.query<
+                        Codegen.UpdateAssetMutation,
+                        Codegen.UpdateAssetMutationVariables
+                    >(UPDATE_ASSET, {
                         input: {
                             id: 'T_1',
                             focalPoint: {
@@ -791,7 +777,10 @@ describe('Elasticsearch plugin', () => {
                     const assetId = search1.items[0].productAsset?.id;
                     expect(assetId).toBeTruthy();
 
-                    await adminClient.query<DeleteAsset.Mutation, DeleteAsset.Variables>(DELETE_ASSET, {
+                    await adminClient.query<
+                        Codegen.DeleteAssetMutation,
+                        Codegen.DeleteAssetMutationVariables
+                    >(DELETE_ASSET, {
                         input: {
                             assetId: assetId!,
                             force: true,
@@ -815,16 +804,16 @@ describe('Elasticsearch plugin', () => {
                 const variantToDelete = s1.items.find(i => i.sku === 'IHD455T2_updated')!;
 
                 const { deleteProductVariant } = await adminClient.query<
-                    DeleteProductVariant.Mutation,
-                    DeleteProductVariant.Variables
+                    Codegen.DeleteProductVariantMutation,
+                    Codegen.DeleteProductVariantMutationVariables
                 >(DELETE_PRODUCT_VARIANT, { id: variantToDelete.productVariantId });
 
                 await awaitRunningJobs(adminClient);
 
-                const { search } = await adminClient.query<SearchGetPrices.Query, SearchGetPrices.Variables>(
-                    SEARCH_GET_PRICES,
-                    { input: { term: 'hard drive', groupByProduct: true } },
-                );
+                const { search } = await adminClient.query<
+                    Codegen.SearchGetPricesQuery,
+                    Codegen.SearchGetPricesQueryVariables
+                >(SEARCH_GET_PRICES, { input: { term: 'hard drive', groupByProduct: true } });
                 expect(search.items[0].price).toEqual({
                     min: 7896,
                     max: 13435,
@@ -845,15 +834,15 @@ describe('Elasticsearch plugin', () => {
             });
 
             it('when grouped, disabled is false if at least one variant is enabled', async () => {
-                await adminClient.query<UpdateProductVariants.Mutation, UpdateProductVariants.Variables>(
-                    UPDATE_PRODUCT_VARIANTS,
-                    {
-                        input: [
-                            { id: 'T_1', enabled: false },
-                            { id: 'T_2', enabled: false },
-                        ],
-                    },
-                );
+                await adminClient.query<
+                    Codegen.UpdateProductVariantsMutation,
+                    Codegen.UpdateProductVariantsMutationVariables
+                >(UPDATE_PRODUCT_VARIANTS, {
+                    input: [
+                        { id: 'T_1', enabled: false },
+                        { id: 'T_2', enabled: false },
+                    ],
+                });
                 await awaitRunningJobs(adminClient);
                 const result = await doAdminSearchQuery(adminClient, {
                     groupByProduct: true,
@@ -865,12 +854,12 @@ describe('Elasticsearch plugin', () => {
             });
 
             it('when grouped, disabled is true if all variants are disabled', async () => {
-                await adminClient.query<UpdateProductVariants.Mutation, UpdateProductVariants.Variables>(
-                    UPDATE_PRODUCT_VARIANTS,
-                    {
-                        input: [{ id: 'T_4', enabled: false }],
-                    },
-                );
+                await adminClient.query<
+                    Codegen.UpdateProductVariantsMutation,
+                    Codegen.UpdateProductVariantsMutationVariables
+                >(UPDATE_PRODUCT_VARIANTS, {
+                    input: [{ id: 'T_4', enabled: false }],
+                });
                 await awaitRunningJobs(adminClient);
                 const result = await doAdminSearchQuery(adminClient, {
                     groupByProduct: true,
@@ -883,7 +872,10 @@ describe('Elasticsearch plugin', () => {
             });
 
             it('when grouped, disabled is true product is disabled', async () => {
-                await adminClient.query<UpdateProduct.Mutation, UpdateProduct.Variables>(UPDATE_PRODUCT, {
+                await adminClient.query<
+                    Codegen.UpdateProductMutation,
+                    Codegen.UpdateProductMutationVariables
+                >(UPDATE_PRODUCT, {
                     input: {
                         id: 'T_3',
                         enabled: false,
@@ -901,7 +893,7 @@ describe('Elasticsearch plugin', () => {
 
             // https://github.com/vendure-ecommerce/vendure/issues/295
             it('enabled status survives reindex', async () => {
-                await adminClient.query<Reindex.Mutation>(REINDEX);
+                await adminClient.query<Codegen.ReindexMutation>(REINDEX);
 
                 await awaitRunningJobs(adminClient);
                 const result = await doAdminSearchQuery(adminClient, {
@@ -921,8 +913,8 @@ describe('Elasticsearch plugin', () => {
 
             it('creates synthetic index item for Product with no variants', async () => {
                 const { createProduct } = await adminClient.query<
-                    CreateProduct.Mutation,
-                    CreateProduct.Variables
+                    Codegen.CreateProductMutation,
+                    Codegen.CreateProductMutationVariables
                 >(CREATE_PRODUCT, {
                     input: {
                         facetValueIds: ['T_1'],
@@ -968,8 +960,8 @@ describe('Elasticsearch plugin', () => {
 
             it('removes synthetic index item once a variant is created', async () => {
                 const { createProductVariants } = await adminClient.query<
-                    CreateProductVariants.Mutation,
-                    CreateProductVariants.Variables
+                    Codegen.CreateProductVariantsMutation,
+                    Codegen.CreateProductVariantsMutationVariables
                 >(CREATE_PRODUCT_VARIANTS, {
                     input: [
                         {
@@ -997,12 +989,12 @@ describe('Elasticsearch plugin', () => {
 
         describe('channel handling', () => {
             const SECOND_CHANNEL_TOKEN = 'second-channel-token';
-            let secondChannel: ChannelFragment;
+            let secondChannel: Codegen.ChannelFragment;
 
             beforeAll(async () => {
                 const { createChannel } = await adminClient.query<
-                    CreateChannel.Mutation,
-                    CreateChannel.Variables
+                    Codegen.CreateChannelMutation,
+                    Codegen.CreateChannelMutationVariables
                 >(CREATE_CHANNEL, {
                     input: {
                         code: 'second-channel',
@@ -1014,10 +1006,10 @@ describe('Elasticsearch plugin', () => {
                         defaultShippingZoneId: 'T_1',
                     },
                 });
-                secondChannel = createChannel as ChannelFragment;
+                secondChannel = createChannel as Codegen.ChannelFragment;
 
                 adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
-                await adminClient.query<Reindex.Mutation>(REINDEX);
+                await adminClient.query<Codegen.ReindexMutation>(REINDEX);
                 await awaitRunningJobs(adminClient);
             });
 
@@ -1034,12 +1026,12 @@ describe('Elasticsearch plugin', () => {
 
             it('adding product to channel', async () => {
                 adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
-                await adminClient.query<AssignProductsToChannel.Mutation, AssignProductsToChannel.Variables>(
-                    ASSIGN_PRODUCT_TO_CHANNEL,
-                    {
-                        input: { channelId: secondChannel.id, productIds: ['T_1', 'T_2'] },
-                    },
-                );
+                await adminClient.query<
+                    Codegen.AssignProductsToChannelMutation,
+                    Codegen.AssignProductsToChannelMutationVariables
+                >(ASSIGN_PRODUCT_TO_CHANNEL, {
+                    input: { channelId: secondChannel.id, productIds: ['T_1', 'T_2'] },
+                });
                 await awaitRunningJobs(adminClient);
 
                 adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
@@ -1050,8 +1042,8 @@ describe('Elasticsearch plugin', () => {
             it('removing product from channel', async () => {
                 adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
                 const { removeProductsFromChannel } = await adminClient.query<
-                    RemoveProductsFromChannel.Mutation,
-                    RemoveProductsFromChannel.Variables
+                    Codegen.RemoveProductsFromChannelMutation,
+                    Codegen.RemoveProductsFromChannelMutationVariables
                 >(REMOVE_PRODUCT_FROM_CHANNEL, {
                     input: {
                         productIds: ['T_2'],
@@ -1068,10 +1060,10 @@ describe('Elasticsearch plugin', () => {
             it('reindexes in channel', async () => {
                 adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
 
-                const { reindex } = await adminClient.query<Reindex.Mutation>(REINDEX);
+                const { reindex } = await adminClient.query<Codegen.ReindexMutation>(REINDEX);
                 await awaitRunningJobs(adminClient);
 
-                const { job } = await adminClient.query<GetJobInfo.Query, GetJobInfo.Variables>(
+                const { job } = await adminClient.query<GetJobInfoQuery, GetJobInfoQueryVariables>(
                     GET_JOB_INFO,
                     { id: reindex.id },
                 );
@@ -1084,8 +1076,8 @@ describe('Elasticsearch plugin', () => {
             it('adding product variant to channel', async () => {
                 adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
                 await adminClient.query<
-                    AssignProductVariantsToChannel.Mutation,
-                    AssignProductVariantsToChannel.Variables
+                    Codegen.AssignProductVariantsToChannelMutation,
+                    Codegen.AssignProductVariantsToChannelMutationVariables
                 >(ASSIGN_PRODUCTVARIANT_TO_CHANNEL, {
                     input: { channelId: secondChannel.id, productVariantIds: ['T_10', 'T_15'] },
                 });
@@ -1114,8 +1106,8 @@ describe('Elasticsearch plugin', () => {
             it('removing product variant from channel', async () => {
                 adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
                 await adminClient.query<
-                    RemoveProductVariantsFromChannel.Mutation,
-                    RemoveProductVariantsFromChannel.Variables
+                    Codegen.RemoveProductVariantsFromChannelMutation,
+                    Codegen.RemoveProductVariantsFromChannelMutationVariables
                 >(REMOVE_PRODUCTVARIANT_FROM_CHANNEL, {
                     input: { channelId: secondChannel.id, productVariantIds: ['T_1', 'T_15'] },
                 });
@@ -1142,8 +1134,8 @@ describe('Elasticsearch plugin', () => {
             it('updating product affects current channel', async () => {
                 adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
                 const { updateProduct } = await adminClient.query<
-                    UpdateProduct.Mutation,
-                    UpdateProduct.Variables
+                    Codegen.UpdateProductMutation,
+                    Codegen.UpdateProductMutationVariables
                 >(UPDATE_PRODUCT, {
                     input: {
                         id: 'T_3',
@@ -1174,7 +1166,10 @@ describe('Elasticsearch plugin', () => {
             it('removing from channel with multiple languages', async () => {
                 adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
 
-                await adminClient.query<UpdateProduct.Mutation, UpdateProduct.Variables>(UPDATE_PRODUCT, {
+                await adminClient.query<
+                    Codegen.UpdateProductMutation,
+                    Codegen.UpdateProductMutationVariables
+                >(UPDATE_PRODUCT, {
                     input: {
                         id: 'T_4',
                         translations: [
@@ -1194,18 +1189,18 @@ describe('Elasticsearch plugin', () => {
                     },
                 });
 
-                await adminClient.query<AssignProductsToChannel.Mutation, AssignProductsToChannel.Variables>(
-                    ASSIGN_PRODUCT_TO_CHANNEL,
-                    {
-                        input: { channelId: secondChannel.id, productIds: ['T_4'] },
-                    },
-                );
+                await adminClient.query<
+                    Codegen.AssignProductsToChannelMutation,
+                    Codegen.AssignProductsToChannelMutationVariables
+                >(ASSIGN_PRODUCT_TO_CHANNEL, {
+                    input: { channelId: secondChannel.id, productIds: ['T_4'] },
+                });
                 await awaitRunningJobs(adminClient);
 
                 async function searchSecondChannelForDEProduct() {
                     adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
                     const { search } = await adminClient.query<
-                        SearchProductsShop.Query,
+                        SearchProductsShopQuery,
                         SearchProductShopVariables
                     >(
                         SEARCH_PRODUCTS,
@@ -1222,8 +1217,8 @@ describe('Elasticsearch plugin', () => {
 
                 adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
                 const { removeProductsFromChannel } = await adminClient.query<
-                    RemoveProductsFromChannel.Mutation,
-                    RemoveProductsFromChannel.Variables
+                    Codegen.RemoveProductsFromChannelMutation,
+                    Codegen.RemoveProductsFromChannelMutationVariables
                 >(REMOVE_PRODUCT_FROM_CHANNEL, {
                     input: {
                         productIds: ['T_4'],
@@ -1239,7 +1234,10 @@ describe('Elasticsearch plugin', () => {
 
         describe('multiple language handling', () => {
             function searchInLanguage(languageCode: LanguageCode, groupByProduct: boolean) {
-                return adminClient.query<SearchProductsAdmin.Query, SearchProductsAdmin.Variables>(
+                return adminClient.query<
+                    Codegen.SearchProductsAdminQuery,
+                    Codegen.SearchProductsAdminQueryVariables
+                >(
                     SEARCH_PRODUCTS,
                     {
                         input: {
@@ -1257,8 +1255,8 @@ describe('Elasticsearch plugin', () => {
             beforeAll(async () => {
                 adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
                 const { updateProduct } = await adminClient.query<
-                    UpdateProduct.Mutation,
-                    UpdateProduct.Variables
+                    Codegen.UpdateProductMutation,
+                    Codegen.UpdateProductMutationVariables
                 >(UPDATE_PRODUCT, {
                     input: {
                         id: 'T_1',
@@ -1279,22 +1277,22 @@ describe('Elasticsearch plugin', () => {
                     },
                 });
 
-                await adminClient.query<UpdateProductVariants.Mutation, UpdateProductVariants.Variables>(
-                    UPDATE_PRODUCT_VARIANTS,
-                    {
-                        input: [
-                            {
-                                id: updateProduct.variants[0].id,
-                                translations: [
-                                    {
-                                        languageCode: LanguageCode.fr,
-                                        name: 'laptop variant fr',
-                                    },
-                                ],
-                            },
-                        ],
-                    },
-                );
+                await adminClient.query<
+                    Codegen.UpdateProductVariantsMutation,
+                    Codegen.UpdateProductVariantsMutationVariables
+                >(UPDATE_PRODUCT_VARIANTS, {
+                    input: [
+                        {
+                            id: updateProduct.variants[0].id,
+                            translations: [
+                                {
+                                    languageCode: LanguageCode.fr,
+                                    name: 'laptop variant fr',
+                                },
+                            ],
+                        },
+                    ],
+                });
 
                 await awaitRunningJobs(adminClient);
             });
@@ -1385,7 +1383,7 @@ describe('Elasticsearch plugin', () => {
             }`;
             try {
                 await shopClient.query(gql(query));
-            } catch (error) {
+            } catch (error: any) {
                 expect(error).toBeDefined();
                 expect(error.message).toContain('Cannot query field "hello"');
                 return;

+ 0 - 5
packages/elasticsearch-plugin/e2e/graphql/generated-e2e-elasticsearch-plugin-types.ts

@@ -3001,12 +3001,10 @@ export type OrderAddress = {
 export type OrderFilterParameter = {
     active?: InputMaybe<BooleanOperators>;
     code?: InputMaybe<StringOperators>;
-    couponCodes?: InputMaybe<StringOperators>;
     createdAt?: InputMaybe<DateOperators>;
     currencyCode?: InputMaybe<StringOperators>;
     customerLastName?: InputMaybe<StringOperators>;
     id?: InputMaybe<IdOperators>;
-    nextStates?: InputMaybe<StringOperators>;
     orderPlacedAt?: InputMaybe<DateOperators>;
     shipping?: InputMaybe<NumberOperators>;
     shippingWithTax?: InputMaybe<NumberOperators>;
@@ -3171,11 +3169,9 @@ export type OrderProcessState = {
 
 export type OrderSortParameter = {
     code?: InputMaybe<SortOrder>;
-    couponCodes?: InputMaybe<SortOrder>;
     createdAt?: InputMaybe<SortOrder>;
     customerLastName?: InputMaybe<SortOrder>;
     id?: InputMaybe<SortOrder>;
-    nextStates?: InputMaybe<SortOrder>;
     orderPlacedAt?: InputMaybe<SortOrder>;
     shipping?: InputMaybe<SortOrder>;
     shippingWithTax?: InputMaybe<SortOrder>;
@@ -4197,7 +4193,6 @@ export type RoleFilterParameter = {
     createdAt?: InputMaybe<DateOperators>;
     description?: InputMaybe<StringOperators>;
     id?: InputMaybe<IdOperators>;
-    permissions?: InputMaybe<StringOperators>;
     updatedAt?: InputMaybe<DateOperators>;
 };
 

+ 0 - 5
packages/payments-plugin/e2e/graphql/generated-admin-types.ts

@@ -3001,12 +3001,10 @@ export type OrderAddress = {
 export type OrderFilterParameter = {
     active?: InputMaybe<BooleanOperators>;
     code?: InputMaybe<StringOperators>;
-    couponCodes?: InputMaybe<StringOperators>;
     createdAt?: InputMaybe<DateOperators>;
     currencyCode?: InputMaybe<StringOperators>;
     customerLastName?: InputMaybe<StringOperators>;
     id?: InputMaybe<IdOperators>;
-    nextStates?: InputMaybe<StringOperators>;
     orderPlacedAt?: InputMaybe<DateOperators>;
     shipping?: InputMaybe<NumberOperators>;
     shippingWithTax?: InputMaybe<NumberOperators>;
@@ -3171,11 +3169,9 @@ export type OrderProcessState = {
 
 export type OrderSortParameter = {
     code?: InputMaybe<SortOrder>;
-    couponCodes?: InputMaybe<SortOrder>;
     createdAt?: InputMaybe<SortOrder>;
     customerLastName?: InputMaybe<SortOrder>;
     id?: InputMaybe<SortOrder>;
-    nextStates?: InputMaybe<SortOrder>;
     orderPlacedAt?: InputMaybe<SortOrder>;
     shipping?: InputMaybe<SortOrder>;
     shippingWithTax?: InputMaybe<SortOrder>;
@@ -4197,7 +4193,6 @@ export type RoleFilterParameter = {
     createdAt?: InputMaybe<DateOperators>;
     description?: InputMaybe<StringOperators>;
     id?: InputMaybe<IdOperators>;
-    permissions?: InputMaybe<StringOperators>;
     updatedAt?: InputMaybe<DateOperators>;
 };
 

+ 0 - 2
packages/payments-plugin/e2e/graphql/generated-shop-types.ts

@@ -1848,7 +1848,6 @@ export type OrderAddress = {
 export type OrderFilterParameter = {
     active?: InputMaybe<BooleanOperators>;
     code?: InputMaybe<StringOperators>;
-    couponCodes?: InputMaybe<StringOperators>;
     createdAt?: InputMaybe<DateOperators>;
     currencyCode?: InputMaybe<StringOperators>;
     id?: InputMaybe<IdOperators>;
@@ -1999,7 +1998,6 @@ export type OrderPaymentStateError = ErrorResult & {
 
 export type OrderSortParameter = {
     code?: InputMaybe<SortOrder>;
-    couponCodes?: InputMaybe<SortOrder>;
     createdAt?: InputMaybe<SortOrder>;
     id?: InputMaybe<SortOrder>;
     orderPlacedAt?: InputMaybe<SortOrder>;

+ 24 - 15
packages/payments-plugin/e2e/mollie-payment.e2e-spec.ts

@@ -1,3 +1,4 @@
+/* tslint:disable:no-non-null-assertion */
 import { PaymentStatus } from '@mollie/api-client';
 import { DefaultLogger, LogLevel, mergeConfig } from '@vendure/core';
 import {
@@ -18,11 +19,19 @@ import { MolliePlugin } from '../src/mollie';
 import { molliePaymentHandler } from '../src/mollie/mollie.handler';
 
 import { CREATE_PAYMENT_METHOD, GET_CUSTOMER_LIST } from './graphql/admin-queries';
-import { CreatePaymentMethod, GetCustomerList, GetCustomerListQuery } from './graphql/generated-admin-types';
 import {
-    AddItemToOrder,
-    AddPaymentToOrder,
-    GetOrderByCode,
+    CreatePaymentMethodMutation,
+    CreatePaymentMethodMutationVariables,
+    GetCustomerListQuery,
+    GetCustomerListQueryVariables,
+} from './graphql/generated-admin-types';
+import {
+    AddItemToOrderMutation,
+    AddItemToOrderMutationVariables,
+    AddPaymentToOrderMutation,
+    AddPaymentToOrderMutationVariables,
+    GetOrderByCodeQuery,
+    GetOrderByCodeQueryVariables,
     TestOrderFragmentFragment,
 } from './graphql/generated-shop-types';
 import { ADD_ITEM_TO_ORDER, ADD_PAYMENT, GET_ORDER_BY_CODE } from './graphql/shop-queries';
@@ -68,7 +77,7 @@ describe('Mollie payments', () => {
         await adminClient.asSuperAdmin();
         ({
             customers: { items: customers },
-        } = await adminClient.query<GetCustomerList.Query, GetCustomerList.Variables>(GET_CUSTOMER_LIST, {
+        } = await adminClient.query<GetCustomerListQuery, GetCustomerListQueryVariables>(GET_CUSTOMER_LIST, {
             options: {
                 take: 2,
             },
@@ -86,8 +95,8 @@ describe('Mollie payments', () => {
 
     it('Should add a Mollie paymentMethod', async () => {
         const { createPaymentMethod } = await adminClient.query<
-            CreatePaymentMethod.Mutation,
-            CreatePaymentMethod.Variables
+            CreatePaymentMethodMutation,
+            CreatePaymentMethodMutationVariables
         >(CREATE_PAYMENT_METHOD, {
             input: {
                 code: mockData.methodCode,
@@ -107,7 +116,7 @@ describe('Mollie payments', () => {
     });
 
     it('Should add payment to order', async () => {
-        let mollieRequest;
+        let mollieRequest: any;
         nock('https://api.mollie.com/')
             .post(/.*/, body => {
                 mollieRequest = body;
@@ -115,14 +124,14 @@ describe('Mollie payments', () => {
             })
             .reply(200, mockData.mollieResponse);
         await shopClient.asUserWithCredentials(customers[0].emailAddress, 'test');
-        await shopClient.query<AddItemToOrder.Mutation, AddItemToOrder.Variables>(ADD_ITEM_TO_ORDER, {
+        await shopClient.query<AddItemToOrderMutation, AddItemToOrderMutationVariables>(ADD_ITEM_TO_ORDER, {
             productVariantId: 'T_1',
             quantity: 2,
         });
         await proceedToArrangingPayment(shopClient);
         const { addPaymentToOrder } = await shopClient.query<
-            AddPaymentToOrder.Mutation,
-            AddPaymentToOrder.Variables
+            AddPaymentToOrderMutation,
+            AddPaymentToOrderMutationVariables
         >(ADD_PAYMENT, {
             input: {
                 method: mockData.methodCode,
@@ -157,7 +166,7 @@ describe('Mollie payments', () => {
             body: JSON.stringify({ id: mockData.mollieResponse.id }),
             headers: { 'Content-Type': 'application/json' },
         });
-        const { orderByCode } = await shopClient.query<GetOrderByCode.Query, GetOrderByCode.Variables>(
+        const { orderByCode } = await shopClient.query<GetOrderByCodeQuery, GetOrderByCodeQueryVariables>(
             GET_ORDER_BY_CODE,
             {
                 code: order.code,
@@ -176,19 +185,19 @@ describe('Mollie payments', () => {
                 return true;
             })
             .reply(200, { status: 'failed' });
-        const refund = await refundOne(adminClient, order.lines[0].id, order.payments[0].id);
+        const refund = await refundOne(adminClient, order.lines[0].id, order.payments![0].id);
         expect(refund.state).toBe('Failed');
     });
 
     it('Should successfully refund', async () => {
-        let mollieRequest;
+        let mollieRequest: any;
         nock('https://api.mollie.com/')
             .post(/.*/, body => {
                 mollieRequest = body;
                 return true;
             })
             .reply(200, { status: 'pending' });
-        const refund = await refundOne(adminClient, order.lines[0].id, order.payments[0].id);
+        const refund = await refundOne(adminClient, order.lines[0].id, order.payments![0].id);
         expect(mollieRequest?.amount.value).toBe('1558.80');
         expect(refund.total).toBe(155880);
         expect(refund.state).toBe('Settled');

Plik diff jest za duży
+ 0 - 0
schema-admin.json


Plik diff jest za duży
+ 0 - 0
schema-shop.json


+ 16 - 9
scripts/codegen/plugins/graphql-errors-plugin.ts

@@ -36,6 +36,8 @@ import { ASTVisitFn } from 'graphql/language/visitor';
 export const ERROR_INTERFACE_NAME = 'ErrorResult';
 const empty = () => '';
 
+type TransformedField = { name: string; type: string };
+
 const errorsVisitor: ASTVisitFn<ASTNode> = (node, key, parent) => {
     switch (node.kind) {
         case Kind.NON_NULL_TYPE: {
@@ -49,7 +51,7 @@ const errorsVisitor: ASTVisitFn<ASTNode> = (node, key, parent) => {
             const type = (node.type.kind === 'ListType' ? node.type.type : node.type) as unknown as string;
             const tsType = isScalar(type) ? `Scalars['${type}']` : 'any';
             const listPart = node.type.kind === 'ListType' ? `[]` : ``;
-            return `${node.name.value}: ${tsType}${listPart}`;
+            return { name: node.name.value, type: `${tsType}${listPart}` };
         }
         case Kind.SCALAR_TYPE_DEFINITION: {
             return '';
@@ -71,7 +73,9 @@ const errorsVisitor: ASTVisitFn<ASTNode> = (node, key, parent) => {
                 `export class ${ERROR_INTERFACE_NAME} {`,
                 `  readonly __typename: string;`,
                 `  readonly errorCode: string;`,
-                ...node.fields.filter(f => !(f as any).includes('errorCode:')).map(f => `${f};`),
+                ...node.fields
+                    .filter(f => (f as any as TransformedField).name !== 'errorCode')
+                    .map(f => `  readonly ${f.name}: ${f.type};`),
                 `}`,
             ].join('\n');
         }
@@ -80,6 +84,9 @@ const errorsVisitor: ASTVisitFn<ASTNode> = (node, key, parent) => {
                 return '';
             }
             const originalNode = parent[key] as ObjectTypeDefinitionNode;
+            const constructorArgs = (node.fields as any as TransformedField[]).filter(
+                f => f.name !== 'errorCode' && f.name !== 'message',
+            );
 
             return [
                 `export class ${node.name.value} extends ${ERROR_INTERFACE_NAME} {`,
@@ -89,16 +96,16 @@ const errorsVisitor: ASTVisitFn<ASTNode> = (node, key, parent) => {
                 // will not be compatible between the admin and shop variations.
                 `  readonly errorCode = '${camelToUpperSnakeCase(node.name.value)}' as any;`,
                 `  readonly message = '${camelToUpperSnakeCase(node.name.value)}';`,
+                ...constructorArgs.map(f => `  readonly ${f.name}: ${f.type};`),
                 `  constructor(`,
-                ...node.fields
-                    .filter(
-                        f =>
-                            !(f as unknown as string).includes('errorCode:') &&
-                            !(f as any).includes('message:'),
-                    )
-                    .map(f => `    public ${f},`),
+                constructorArgs.length
+                    ? `    input: { ${constructorArgs.map(f => `${f.name}: ${f.type}`).join(', ')} }`
+                    : '',
                 `  ) {`,
                 `    super();`,
+                ...(constructorArgs.length
+                    ? constructorArgs.map(f => `    this.${f.name} = input.${f.name}`)
+                    : []),
                 `  }`,
                 `}`,
             ].join('\n');

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików