Przeglądaj źródła

feat(admin-ui): Update Apollo Client to v3

Michael Bromley 5 lat temu
rodzic
commit
4e628a6d32
26 zmienionych plików z 803 dodań i 753 usunięć
  1. 6 10
      packages/admin-ui/package.json
  2. 147 609
      packages/admin-ui/src/lib/core/src/common/introspection-result.ts
  3. 1 1
      packages/admin-ui/src/lib/core/src/data/check-jobs-link.ts
  4. 8 8
      packages/admin-ui/src/lib/core/src/data/client-state/client-resolvers.ts
  5. 9 10
      packages/admin-ui/src/lib/core/src/data/data.module.ts
  6. 1 1
      packages/admin-ui/src/lib/core/src/data/definitions/administrator-definitions.ts
  7. 1 1
      packages/admin-ui/src/lib/core/src/data/definitions/auth-definitions.ts
  8. 16 1
      packages/admin-ui/src/lib/core/src/data/definitions/client-definitions.ts
  9. 1 1
      packages/admin-ui/src/lib/core/src/data/definitions/collection-definitions.ts
  10. 1 1
      packages/admin-ui/src/lib/core/src/data/definitions/customer-definitions.ts
  11. 1 1
      packages/admin-ui/src/lib/core/src/data/definitions/facet-definitions.ts
  12. 1 1
      packages/admin-ui/src/lib/core/src/data/definitions/order-definitions.ts
  13. 1 1
      packages/admin-ui/src/lib/core/src/data/definitions/product-definitions.ts
  14. 1 1
      packages/admin-ui/src/lib/core/src/data/definitions/promotion-definitions.ts
  15. 1 1
      packages/admin-ui/src/lib/core/src/data/definitions/settings-definitions.ts
  16. 1 1
      packages/admin-ui/src/lib/core/src/data/definitions/shared-definitions.ts
  17. 1 1
      packages/admin-ui/src/lib/core/src/data/definitions/shipping-definitions.ts
  18. 1 1
      packages/admin-ui/src/lib/core/src/data/omit-typename-link.ts
  19. 3 14
      packages/admin-ui/src/lib/core/src/data/providers/base-data.service.ts
  20. 3 3
      packages/admin-ui/src/lib/core/src/data/providers/data.service.ts
  21. 1 1
      packages/admin-ui/src/lib/core/src/data/providers/settings-data.service.ts
  22. 1 1
      packages/admin-ui/src/lib/core/src/data/query-result.ts
  23. 1 1
      packages/admin-ui/src/lib/core/src/data/server-config.ts
  24. 1 1
      packages/admin-ui/tsconfig.json
  25. 1 1
      scripts/codegen/generate-graphql-types.ts
  26. 593 80
      yarn.lock

+ 6 - 10
packages/admin-ui/package.json

@@ -37,16 +37,11 @@
     "@ngx-translate/http-loader": "^4.0.0",
     "@vendure/common": "^0.15.0",
     "@webcomponents/custom-elements": "^1.2.4",
-    "apollo-angular": "^1.8.0",
-    "apollo-cache-inmemory": "^1.6.5",
-    "apollo-client": "^2.6.8",
-    "apollo-link": "^1.2.13",
-    "apollo-link-context": "^1.0.19",
+    "apollo-angular": "^2.0.4",
     "apollo-upload-client": "^12.1.0",
     "core-js": "^3.1.3",
     "dayjs": "^1.8.20",
-    "graphql": "^14.6.0",
-    "graphql-tag": "^2.10.3",
+    "graphql": "14.6.0",
     "messageformat": "2.3.0",
     "ngx-pagination": "^5.0.0",
     "ngx-translate-messageformat-compiler": "^4.6.0",
@@ -60,9 +55,10 @@
     "prosemirror-schema-basic": "^1.1.2",
     "prosemirror-schema-list": "^1.0.0",
     "prosemirror-state": "^1.0.0",
-    "rxjs": "^6.5.4",
+    "rxjs": "^6.6.3",
     "tslib": "^2.0.0",
-    "zone.js": "~0.10.2"
+    "zone.js": "~0.10.2",
+    "@apollo/client": "^3.0.0"
   },
   "devDependencies": {
     "@angular-devkit/build-angular": "~0.1001.4",
@@ -96,4 +92,4 @@
     "tslint": "~6.1.0",
     "typescript": "4.0.3"
   }
-}
+}

+ 147 - 609
packages/admin-ui/src/lib/core/src/common/introspection-result.ts

@@ -1,617 +1,155 @@
 // tslint:disable
 
-export interface IntrospectionResultData {
-    __schema: {
-        types: {
-            kind: string;
-            name: string;
-            possibleTypes: {
-                name: string;
-            }[];
-        }[];
+export interface PossibleTypesResultData {
+    possibleTypes: {
+        [key: string]: string[];
     };
 }
-const result: IntrospectionResultData = {
-    __schema: {
-        types: [
-            {
-                kind: 'INTERFACE',
-                name: 'Node',
-                possibleTypes: [
-                    {
-                        name: 'Channel',
-                    },
-                    {
-                        name: 'Zone',
-                    },
-                    {
-                        name: 'Country',
-                    },
-                    {
-                        name: 'Administrator',
-                    },
-                    {
-                        name: 'User',
-                    },
-                    {
-                        name: 'Role',
-                    },
-                    {
-                        name: 'AuthenticationMethod',
-                    },
-                    {
-                        name: 'Asset',
-                    },
-                    {
-                        name: 'Collection',
-                    },
-                    {
-                        name: 'ProductVariant',
-                    },
-                    {
-                        name: 'StockAdjustment',
-                    },
-                    {
-                        name: 'Sale',
-                    },
-                    {
-                        name: 'OrderLine',
-                    },
-                    {
-                        name: 'OrderItem',
-                    },
-                    {
-                        name: 'Fulfillment',
-                    },
-                    {
-                        name: 'Order',
-                    },
-                    {
-                        name: 'Customer',
-                    },
-                    {
-                        name: 'CustomerGroup',
-                    },
-                    {
-                        name: 'HistoryEntry',
-                    },
-                    {
-                        name: 'Address',
-                    },
-                    {
-                        name: 'Promotion',
-                    },
-                    {
-                        name: 'Payment',
-                    },
-                    {
-                        name: 'Refund',
-                    },
-                    {
-                        name: 'ShippingMethod',
-                    },
-                    {
-                        name: 'Cancellation',
-                    },
-                    {
-                        name: 'Return',
-                    },
-                    {
-                        name: 'Product',
-                    },
-                    {
-                        name: 'ProductOptionGroup',
-                    },
-                    {
-                        name: 'ProductOption',
-                    },
-                    {
-                        name: 'FacetValue',
-                    },
-                    {
-                        name: 'Facet',
-                    },
-                    {
-                        name: 'TaxRate',
-                    },
-                    {
-                        name: 'TaxCategory',
-                    },
-                    {
-                        name: 'Job',
-                    },
-                    {
-                        name: 'PaymentMethod',
-                    },
-                ],
-            },
-            {
-                kind: 'INTERFACE',
-                name: 'PaginatedList',
-                possibleTypes: [
-                    {
-                        name: 'AdministratorList',
-                    },
-                    {
-                        name: 'AssetList',
-                    },
-                    {
-                        name: 'ProductVariantList',
-                    },
-                    {
-                        name: 'CustomerList',
-                    },
-                    {
-                        name: 'HistoryEntryList',
-                    },
-                    {
-                        name: 'OrderList',
-                    },
-                    {
-                        name: 'CollectionList',
-                    },
-                    {
-                        name: 'CountryList',
-                    },
-                    {
-                        name: 'CustomerGroupList',
-                    },
-                    {
-                        name: 'FacetList',
-                    },
-                    {
-                        name: 'JobList',
-                    },
-                    {
-                        name: 'PaymentMethodList',
-                    },
-                    {
-                        name: 'ProductList',
-                    },
-                    {
-                        name: 'PromotionList',
-                    },
-                    {
-                        name: 'RoleList',
-                    },
-                    {
-                        name: 'ShippingMethodList',
-                    },
-                    {
-                        name: 'TaxRateList',
-                    },
-                ],
-            },
-            {
-                kind: 'UNION',
-                name: 'StockMovementItem',
-                possibleTypes: [
-                    {
-                        name: 'StockAdjustment',
-                    },
-                    {
-                        name: 'Sale',
-                    },
-                    {
-                        name: 'Cancellation',
-                    },
-                    {
-                        name: 'Return',
-                    },
-                ],
-            },
-            {
-                kind: 'INTERFACE',
-                name: 'StockMovement',
-                possibleTypes: [
-                    {
-                        name: 'StockAdjustment',
-                    },
-                    {
-                        name: 'Sale',
-                    },
-                    {
-                        name: 'Cancellation',
-                    },
-                    {
-                        name: 'Return',
-                    },
-                ],
-            },
-            {
-                kind: 'UNION',
-                name: 'CustomFieldConfig',
-                possibleTypes: [
-                    {
-                        name: 'StringCustomFieldConfig',
-                    },
-                    {
-                        name: 'LocaleStringCustomFieldConfig',
-                    },
-                    {
-                        name: 'IntCustomFieldConfig',
-                    },
-                    {
-                        name: 'FloatCustomFieldConfig',
-                    },
-                    {
-                        name: 'BooleanCustomFieldConfig',
-                    },
-                    {
-                        name: 'DateTimeCustomFieldConfig',
-                    },
-                ],
-            },
-            {
-                kind: 'INTERFACE',
-                name: 'CustomField',
-                possibleTypes: [
-                    {
-                        name: 'StringCustomFieldConfig',
-                    },
-                    {
-                        name: 'LocaleStringCustomFieldConfig',
-                    },
-                    {
-                        name: 'IntCustomFieldConfig',
-                    },
-                    {
-                        name: 'FloatCustomFieldConfig',
-                    },
-                    {
-                        name: 'BooleanCustomFieldConfig',
-                    },
-                    {
-                        name: 'DateTimeCustomFieldConfig',
-                    },
-                ],
-            },
-            {
-                kind: 'UNION',
-                name: 'SearchResultPrice',
-                possibleTypes: [
-                    {
-                        name: 'PriceRange',
-                    },
-                    {
-                        name: 'SinglePrice',
-                    },
-                ],
-            },
-            {
-                kind: 'UNION',
-                name: 'AddFulfillmentToOrderResult',
-                possibleTypes: [
-                    {
-                        name: 'Fulfillment',
-                    },
-                    {
-                        name: 'EmptyOrderLineSelectionError',
-                    },
-                    {
-                        name: 'ItemsAlreadyFulfilledError',
-                    },
-                ],
-            },
-            {
-                kind: 'INTERFACE',
-                name: 'ErrorResult',
-                possibleTypes: [
-                    {
-                        name: 'EmptyOrderLineSelectionError',
-                    },
-                    {
-                        name: 'ItemsAlreadyFulfilledError',
-                    },
-                    {
-                        name: 'InvalidCredentialsError',
-                    },
-                    {
-                        name: 'QuantityTooGreatError',
-                    },
-                    {
-                        name: 'MultipleOrderError',
-                    },
-                    {
-                        name: 'CancelActiveOrderError',
-                    },
-                    {
-                        name: 'OrderStateTransitionError',
-                    },
-                    {
-                        name: 'MimeTypeError',
-                    },
-                    {
-                        name: 'LanguageNotAvailableError',
-                    },
-                    {
-                        name: 'EmailAddressConflictError',
-                    },
-                    {
-                        name: 'MissingConditionsError',
-                    },
-                    {
-                        name: 'NativeAuthStrategyError',
-                    },
-                    {
-                        name: 'NothingToRefundError',
-                    },
-                    {
-                        name: 'PaymentOrderMismatchError',
-                    },
-                    {
-                        name: 'RefundOrderStateError',
-                    },
-                    {
-                        name: 'AlreadyRefundedError',
-                    },
-                    {
-                        name: 'RefundStateTransitionError',
-                    },
-                    {
-                        name: 'ProductOptionInUseError',
-                    },
-                    {
-                        name: 'SettlePaymentError',
-                    },
-                    {
-                        name: 'PaymentStateTransitionError',
-                    },
-                    {
-                        name: 'FulfillmentStateTransitionError',
-                    },
-                    {
-                        name: 'ChannelDefaultLanguageError',
-                    },
-                ],
-            },
-            {
-                kind: 'UNION',
-                name: 'AuthenticationResult',
-                possibleTypes: [
-                    {
-                        name: 'CurrentUser',
-                    },
-                    {
-                        name: 'InvalidCredentialsError',
-                    },
-                ],
-            },
-            {
-                kind: 'UNION',
-                name: 'CancelOrderResult',
-                possibleTypes: [
-                    {
-                        name: 'Order',
-                    },
-                    {
-                        name: 'EmptyOrderLineSelectionError',
-                    },
-                    {
-                        name: 'QuantityTooGreatError',
-                    },
-                    {
-                        name: 'MultipleOrderError',
-                    },
-                    {
-                        name: 'CancelActiveOrderError',
-                    },
-                    {
-                        name: 'OrderStateTransitionError',
-                    },
-                ],
-            },
-            {
-                kind: 'UNION',
-                name: 'CreateAssetResult',
-                possibleTypes: [
-                    {
-                        name: 'Asset',
-                    },
-                    {
-                        name: 'MimeTypeError',
-                    },
-                ],
-            },
-            {
-                kind: 'UNION',
-                name: 'CreateChannelResult',
-                possibleTypes: [
-                    {
-                        name: 'Channel',
-                    },
-                    {
-                        name: 'LanguageNotAvailableError',
-                    },
-                ],
-            },
-            {
-                kind: 'UNION',
-                name: 'CreateCustomerResult',
-                possibleTypes: [
-                    {
-                        name: 'Customer',
-                    },
-                    {
-                        name: 'EmailAddressConflictError',
-                    },
-                ],
-            },
-            {
-                kind: 'UNION',
-                name: 'CreatePromotionResult',
-                possibleTypes: [
-                    {
-                        name: 'Promotion',
-                    },
-                    {
-                        name: 'MissingConditionsError',
-                    },
-                ],
-            },
-            {
-                kind: 'UNION',
-                name: 'NativeAuthenticationResult',
-                possibleTypes: [
-                    {
-                        name: 'CurrentUser',
-                    },
-                    {
-                        name: 'InvalidCredentialsError',
-                    },
-                    {
-                        name: 'NativeAuthStrategyError',
-                    },
-                ],
-            },
-            {
-                kind: 'UNION',
-                name: 'RefundOrderResult',
-                possibleTypes: [
-                    {
-                        name: 'Refund',
-                    },
-                    {
-                        name: 'QuantityTooGreatError',
-                    },
-                    {
-                        name: 'NothingToRefundError',
-                    },
-                    {
-                        name: 'OrderStateTransitionError',
-                    },
-                    {
-                        name: 'MultipleOrderError',
-                    },
-                    {
-                        name: 'PaymentOrderMismatchError',
-                    },
-                    {
-                        name: 'RefundOrderStateError',
-                    },
-                    {
-                        name: 'AlreadyRefundedError',
-                    },
-                    {
-                        name: 'RefundStateTransitionError',
-                    },
-                ],
-            },
-            {
-                kind: 'UNION',
-                name: 'RemoveOptionGroupFromProductResult',
-                possibleTypes: [
-                    {
-                        name: 'Product',
-                    },
-                    {
-                        name: 'ProductOptionInUseError',
-                    },
-                ],
-            },
-            {
-                kind: 'UNION',
-                name: 'SettlePaymentResult',
-                possibleTypes: [
-                    {
-                        name: 'Payment',
-                    },
-                    {
-                        name: 'SettlePaymentError',
-                    },
-                    {
-                        name: 'PaymentStateTransitionError',
-                    },
-                    {
-                        name: 'OrderStateTransitionError',
-                    },
-                ],
-            },
-            {
-                kind: 'UNION',
-                name: 'SettleRefundResult',
-                possibleTypes: [
-                    {
-                        name: 'Refund',
-                    },
-                    {
-                        name: 'RefundStateTransitionError',
-                    },
-                ],
-            },
-            {
-                kind: 'UNION',
-                name: 'TransitionFulfillmentToStateResult',
-                possibleTypes: [
-                    {
-                        name: 'Fulfillment',
-                    },
-                    {
-                        name: 'FulfillmentStateTransitionError',
-                    },
-                ],
-            },
-            {
-                kind: 'UNION',
-                name: 'TransitionOrderToStateResult',
-                possibleTypes: [
-                    {
-                        name: 'Order',
-                    },
-                    {
-                        name: 'OrderStateTransitionError',
-                    },
-                ],
-            },
-            {
-                kind: 'UNION',
-                name: 'UpdateChannelResult',
-                possibleTypes: [
-                    {
-                        name: 'Channel',
-                    },
-                    {
-                        name: 'LanguageNotAvailableError',
-                    },
-                ],
-            },
-            {
-                kind: 'UNION',
-                name: 'UpdateCustomerResult',
-                possibleTypes: [
-                    {
-                        name: 'Customer',
-                    },
-                    {
-                        name: 'EmailAddressConflictError',
-                    },
-                ],
-            },
-            {
-                kind: 'UNION',
-                name: 'UpdateGlobalSettingsResult',
-                possibleTypes: [
-                    {
-                        name: 'GlobalSettings',
-                    },
-                    {
-                        name: 'ChannelDefaultLanguageError',
-                    },
-                ],
-            },
-            {
-                kind: 'UNION',
-                name: 'UpdatePromotionResult',
-                possibleTypes: [
-                    {
-                        name: 'Promotion',
-                    },
-                    {
-                        name: 'MissingConditionsError',
-                    },
-                ],
-            },
+const result: PossibleTypesResultData = {
+    possibleTypes: {
+        Node: [
+            'Channel',
+            'Zone',
+            'Country',
+            'Administrator',
+            'User',
+            'Role',
+            'AuthenticationMethod',
+            'Asset',
+            'Collection',
+            'ProductVariant',
+            'StockAdjustment',
+            'Sale',
+            'OrderLine',
+            'OrderItem',
+            'Fulfillment',
+            'Order',
+            'Customer',
+            'CustomerGroup',
+            'HistoryEntry',
+            'Address',
+            'Promotion',
+            'Payment',
+            'Refund',
+            'ShippingMethod',
+            'Cancellation',
+            'Return',
+            'Product',
+            'ProductOptionGroup',
+            'ProductOption',
+            'FacetValue',
+            'Facet',
+            'TaxRate',
+            'TaxCategory',
+            'Job',
+            'PaymentMethod',
         ],
+        PaginatedList: [
+            'AdministratorList',
+            'AssetList',
+            'ProductVariantList',
+            'CustomerList',
+            'HistoryEntryList',
+            'OrderList',
+            'CollectionList',
+            'CountryList',
+            'CustomerGroupList',
+            'FacetList',
+            'JobList',
+            'PaymentMethodList',
+            'ProductList',
+            'PromotionList',
+            'RoleList',
+            'ShippingMethodList',
+            'TaxRateList',
+        ],
+        StockMovementItem: ['StockAdjustment', 'Sale', 'Cancellation', 'Return'],
+        StockMovement: ['StockAdjustment', 'Sale', 'Cancellation', 'Return'],
+        CustomFieldConfig: [
+            'StringCustomFieldConfig',
+            'LocaleStringCustomFieldConfig',
+            'IntCustomFieldConfig',
+            'FloatCustomFieldConfig',
+            'BooleanCustomFieldConfig',
+            'DateTimeCustomFieldConfig',
+        ],
+        CustomField: [
+            'StringCustomFieldConfig',
+            'LocaleStringCustomFieldConfig',
+            'IntCustomFieldConfig',
+            'FloatCustomFieldConfig',
+            'BooleanCustomFieldConfig',
+            'DateTimeCustomFieldConfig',
+        ],
+        SearchResultPrice: ['PriceRange', 'SinglePrice'],
+        AddFulfillmentToOrderResult: [
+            'Fulfillment',
+            'EmptyOrderLineSelectionError',
+            'ItemsAlreadyFulfilledError',
+        ],
+        ErrorResult: [
+            'EmptyOrderLineSelectionError',
+            'ItemsAlreadyFulfilledError',
+            'InvalidCredentialsError',
+            'QuantityTooGreatError',
+            'MultipleOrderError',
+            'CancelActiveOrderError',
+            'OrderStateTransitionError',
+            'MimeTypeError',
+            'LanguageNotAvailableError',
+            'EmailAddressConflictError',
+            'MissingConditionsError',
+            'NativeAuthStrategyError',
+            'NothingToRefundError',
+            'PaymentOrderMismatchError',
+            'RefundOrderStateError',
+            'AlreadyRefundedError',
+            'RefundStateTransitionError',
+            'ProductOptionInUseError',
+            'SettlePaymentError',
+            'PaymentStateTransitionError',
+            'FulfillmentStateTransitionError',
+            'ChannelDefaultLanguageError',
+        ],
+        AuthenticationResult: ['CurrentUser', 'InvalidCredentialsError'],
+        CancelOrderResult: [
+            'Order',
+            'EmptyOrderLineSelectionError',
+            'QuantityTooGreatError',
+            'MultipleOrderError',
+            'CancelActiveOrderError',
+            'OrderStateTransitionError',
+        ],
+        CreateAssetResult: ['Asset', 'MimeTypeError'],
+        CreateChannelResult: ['Channel', 'LanguageNotAvailableError'],
+        CreateCustomerResult: ['Customer', 'EmailAddressConflictError'],
+        CreatePromotionResult: ['Promotion', 'MissingConditionsError'],
+        NativeAuthenticationResult: ['CurrentUser', 'InvalidCredentialsError', 'NativeAuthStrategyError'],
+        RefundOrderResult: [
+            'Refund',
+            'QuantityTooGreatError',
+            'NothingToRefundError',
+            'OrderStateTransitionError',
+            'MultipleOrderError',
+            'PaymentOrderMismatchError',
+            'RefundOrderStateError',
+            'AlreadyRefundedError',
+            'RefundStateTransitionError',
+        ],
+        RemoveOptionGroupFromProductResult: ['Product', 'ProductOptionInUseError'],
+        SettlePaymentResult: [
+            'Payment',
+            'SettlePaymentError',
+            'PaymentStateTransitionError',
+            'OrderStateTransitionError',
+        ],
+        SettleRefundResult: ['Refund', 'RefundStateTransitionError'],
+        TransitionFulfillmentToStateResult: ['Fulfillment', 'FulfillmentStateTransitionError'],
+        TransitionOrderToStateResult: ['Order', 'OrderStateTransitionError'],
+        UpdateChannelResult: ['Channel', 'LanguageNotAvailableError'],
+        UpdateCustomerResult: ['Customer', 'EmailAddressConflictError'],
+        UpdateGlobalSettingsResult: ['GlobalSettings', 'ChannelDefaultLanguageError'],
+        UpdatePromotionResult: ['Promotion', 'MissingConditionsError'],
     },
 };
 export default result;

+ 1 - 1
packages/admin-ui/src/lib/core/src/data/check-jobs-link.ts

@@ -1,5 +1,5 @@
 import { Injector } from '@angular/core';
-import { ApolloLink, Operation } from 'apollo-link';
+import { ApolloLink, Operation } from '@apollo/client/core';
 
 import { JobQueueService } from '../providers/job-queue/job-queue.service';
 

+ 8 - 8
packages/admin-ui/src/lib/core/src/data/client-state/client-resolvers.ts

@@ -1,4 +1,4 @@
-import { InMemoryCache } from 'apollo-cache-inmemory';
+import { InMemoryCache } from '@apollo/client/core';
 
 import {
     GetNetworkStatus,
@@ -11,7 +11,7 @@ import {
     UpdateUserChannels,
     UserStatus,
 } from '../../common/generated-types';
-import { GET_NEWTORK_STATUS, GET_USER_STATUS } from '../definitions/client-definitions';
+import { GET_NEWTORK_STATUS, GET_UI_STATE, GET_USER_STATUS } from '../definitions/client-definitions';
 
 export type ResolverContext = {
     cache: InMemoryCache;
@@ -50,7 +50,7 @@ export const clientResolvers: ResolverDefinition = {
                     activeChannelId,
                 },
             };
-            cache.writeData({ data });
+            cache.writeQuery({ query: GET_USER_STATUS, data });
             return data.userStatus;
         },
         setAsLoggedOut: (_, args, { cache }): GetUserStatus.UserStatus => {
@@ -65,7 +65,7 @@ export const clientResolvers: ResolverDefinition = {
                     activeChannelId: null,
                 },
             };
-            cache.writeData({ data });
+            cache.writeQuery({ query: GET_USER_STATUS, data });
             return data.userStatus;
         },
         setUiLanguage: (_, args: SetUiLanguage.Variables, { cache }): LanguageCode => {
@@ -75,7 +75,7 @@ export const clientResolvers: ResolverDefinition = {
                     language: args.languageCode,
                 },
             };
-            cache.writeData({ data });
+            cache.writeQuery({ query: GET_UI_STATE, data });
             return args.languageCode;
         },
         setActiveChannel: (_, args: SetActiveChannel.Variables, { cache }): UserStatus => {
@@ -93,7 +93,7 @@ export const clientResolvers: ResolverDefinition = {
                     activeChannelId: activeChannel.id,
                 },
             };
-            cache.writeData({ data });
+            cache.writeQuery({ query: GET_USER_STATUS, data });
             return { ...previous.userStatus, ...data.userStatus };
         },
         updateUserChannels: (_, args: UpdateUserChannels.Variables, { cache }): UserStatus => {
@@ -105,7 +105,7 @@ export const clientResolvers: ResolverDefinition = {
                     channels: args.channels,
                 },
             };
-            cache.writeData({ data });
+            cache.writeQuery({ query: GET_USER_STATUS, data });
             return { ...previous.userStatus, ...data.userStatus };
         },
     },
@@ -120,6 +120,6 @@ function updateRequestsInFlight(cache: InMemoryCache, increment: 1 | -1): number
             inFlightRequests,
         },
     };
-    cache.writeData({ data });
+    cache.writeQuery({ query: GET_NEWTORK_STATUS, data });
     return inFlightRequests;
 }

+ 9 - 10
packages/admin-ui/src/lib/core/src/data/data.module.ts

@@ -1,10 +1,9 @@
 import { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
 import { APP_INITIALIZER, Injector, NgModule } from '@angular/core';
-import { APOLLO_OPTIONS, ApolloModule } from 'apollo-angular';
-import { InMemoryCache, IntrospectionFragmentMatcher } from 'apollo-cache-inmemory';
-import { ApolloClientOptions } from 'apollo-client';
-import { ApolloLink } from 'apollo-link';
-import { setContext } from 'apollo-link-context';
+import { ApolloClientOptions, InMemoryCache } from '@apollo/client/core';
+import { setContext } from '@apollo/client/link/context';
+import { ApolloLink } from '@apollo/client/link/core';
+import { APOLLO_OPTIONS } from 'apollo-angular';
 import { createUploadLink } from 'apollo-upload-client';
 
 import { getAppConfig } from '../app.config';
@@ -14,6 +13,7 @@ import { LocalStorageService } from '../providers/local-storage/local-storage.se
 import { CheckJobsLink } from './check-jobs-link';
 import { getClientDefaults } from './client-state/client-defaults';
 import { clientResolvers } from './client-state/client-resolvers';
+import { GET_CLIENT_STATE } from './definitions/client-definitions';
 import { OmitTypenameLink } from './omit-typename-link';
 import { BaseDataService } from './providers/base-data.service';
 import { DataService } from './providers/data.service';
@@ -30,11 +30,10 @@ export function createApollo(
     const { adminApiPath, tokenMethod } = getAppConfig();
     const serverLocation = getServerLocation();
     const apolloCache = new InMemoryCache({
-        fragmentMatcher: new IntrospectionFragmentMatcher({
-            introspectionQueryResultData: introspectionResult,
-        }),
+        possibleTypes: introspectionResult.possibleTypes,
     });
-    apolloCache.writeData({
+    apolloCache.writeQuery({
+        query: GET_CLIENT_STATE,
         data: getClientDefaults(localStorageService),
     });
 
@@ -76,7 +75,7 @@ export function createApollo(
  * state via the apollo-link-state package.
  */
 @NgModule({
-    imports: [ApolloModule, HttpClientModule],
+    imports: [HttpClientModule],
     exports: [],
     declarations: [],
     providers: [

+ 1 - 1
packages/admin-ui/src/lib/core/src/data/definitions/administrator-definitions.ts

@@ -1,4 +1,4 @@
-import gql from 'graphql-tag';
+import { gql } from 'apollo-angular';
 
 export const ROLE_FRAGMENT = gql`
     fragment Role on Role {

+ 1 - 1
packages/admin-ui/src/lib/core/src/data/definitions/auth-definitions.ts

@@ -1,4 +1,4 @@
-import gql from 'graphql-tag';
+import { gql } from 'apollo-angular';
 
 import { ERROR_RESULT_FRAGMENT } from './shared-definitions';
 

+ 16 - 1
packages/admin-ui/src/lib/core/src/data/definitions/client-definitions.ts

@@ -1,4 +1,4 @@
-import gql from 'graphql-tag';
+import { gql } from 'apollo-angular';
 
 export const REQUEST_STARTED = gql`
     mutation RequestStarted {
@@ -77,6 +77,21 @@ export const GET_UI_STATE = gql`
     }
 `;
 
+export const GET_CLIENT_STATE = gql`
+    query GetClientState {
+        networkStatus @client {
+            inFlightRequests
+        }
+        userStatus @client {
+            ...UserStatus
+        }
+        uiState @client {
+            language
+        }
+    }
+    ${USER_STATUS_FRAGMENT}
+`;
+
 export const SET_ACTIVE_CHANNEL = gql`
     mutation SetActiveChannel($channelId: ID!) {
         setActiveChannel(channelId: $channelId) @client {

+ 1 - 1
packages/admin-ui/src/lib/core/src/data/definitions/collection-definitions.ts

@@ -1,4 +1,4 @@
-import gql from 'graphql-tag';
+import { gql } from 'apollo-angular';
 
 import { ASSET_FRAGMENT } from './product-definitions';
 import { CONFIGURABLE_OPERATION_DEF_FRAGMENT, CONFIGURABLE_OPERATION_FRAGMENT } from './shared-definitions';

+ 1 - 1
packages/admin-ui/src/lib/core/src/data/definitions/customer-definitions.ts

@@ -1,4 +1,4 @@
-import gql from 'graphql-tag';
+import { gql } from 'apollo-angular';
 
 import { ERROR_RESULT_FRAGMENT } from './shared-definitions';
 

+ 1 - 1
packages/admin-ui/src/lib/core/src/data/definitions/facet-definitions.ts

@@ -1,4 +1,4 @@
-import gql from 'graphql-tag';
+import { gql } from 'apollo-angular';
 
 export const FACET_VALUE_FRAGMENT = gql`
     fragment FacetValue on FacetValue {

+ 1 - 1
packages/admin-ui/src/lib/core/src/data/definitions/order-definitions.ts

@@ -1,4 +1,4 @@
-import gql from 'graphql-tag';
+import { gql } from 'apollo-angular';
 
 import { ERROR_RESULT_FRAGMENT } from './shared-definitions';
 

+ 1 - 1
packages/admin-ui/src/lib/core/src/data/definitions/product-definitions.ts

@@ -1,4 +1,4 @@
-import gql from 'graphql-tag';
+import { gql } from 'apollo-angular';
 
 import { ERROR_RESULT_FRAGMENT } from './shared-definitions';
 

+ 1 - 1
packages/admin-ui/src/lib/core/src/data/definitions/promotion-definitions.ts

@@ -1,4 +1,4 @@
-import gql from 'graphql-tag';
+import { gql } from 'apollo-angular';
 
 import {
     CONFIGURABLE_OPERATION_DEF_FRAGMENT,

+ 1 - 1
packages/admin-ui/src/lib/core/src/data/definitions/settings-definitions.ts

@@ -1,4 +1,4 @@
-import gql from 'graphql-tag';
+import { gql } from 'apollo-angular';
 
 import { CONFIGURABLE_OPERATION_DEF_FRAGMENT, ERROR_RESULT_FRAGMENT } from './shared-definitions';
 

+ 1 - 1
packages/admin-ui/src/lib/core/src/data/definitions/shared-definitions.ts

@@ -1,4 +1,4 @@
-import gql from 'graphql-tag';
+import { gql } from 'apollo-angular';
 
 export const CONFIGURABLE_OPERATION_FRAGMENT = gql`
     fragment ConfigurableOperation on ConfigurableOperation {

+ 1 - 1
packages/admin-ui/src/lib/core/src/data/definitions/shipping-definitions.ts

@@ -1,4 +1,4 @@
-import gql from 'graphql-tag';
+import { gql } from 'apollo-angular';
 
 import { CONFIGURABLE_OPERATION_DEF_FRAGMENT, CONFIGURABLE_OPERATION_FRAGMENT } from './shared-definitions';
 

+ 1 - 1
packages/admin-ui/src/lib/core/src/data/omit-typename-link.ts

@@ -1,5 +1,5 @@
+import { ApolloLink } from '@apollo/client/core';
 import { omit } from '@vendure/common/lib/omit';
-import { ApolloLink } from 'apollo-link';
 
 /**
  * The "__typename" property added by Apollo Client causes errors when posting the entity

+ 3 - 14
packages/admin-ui/src/lib/core/src/data/providers/base-data.service.ts

@@ -1,9 +1,7 @@
 import { HttpClient } from '@angular/common/http';
 import { Injectable } from '@angular/core';
+import { DataProxy, MutationUpdaterFn, WatchQueryFetchPolicy } from '@apollo/client/core';
 import { Apollo } from 'apollo-angular';
-import { DataProxy } from 'apollo-cache';
-import { WatchQueryFetchPolicy } from 'apollo-client';
-import { ExecutionResult } from 'apollo-link';
 import { DocumentNode } from 'graphql/language/ast';
 import { Observable } from 'rxjs';
 import { map } from 'rxjs/operators';
@@ -18,15 +16,6 @@ import {
     removeReadonlyCustomFields,
 } from '../utils/remove-readonly-custom-fields';
 
-/**
- * Make the MutationUpdaterFn type-safe until this issue is resolved: https://github.com/apollographql/apollo-link/issues/616
- */
-export type TypedFetchResult<T = Record<string, any>> = ExecutionResult & {
-    context?: T;
-    data: T;
-};
-export type TypedMutationUpdateFn<T> = (proxy: DataProxy, mutationResult: TypedFetchResult<T>) => void;
-
 @Injectable()
 export class BaseDataService {
     constructor(
@@ -64,7 +53,7 @@ export class BaseDataService {
     mutate<T, V = Record<string, any>>(
         mutation: DocumentNode,
         variables?: V,
-        update?: TypedMutationUpdateFn<T>,
+        update?: MutationUpdaterFn<T>,
     ): Observable<T> {
         const withCustomFields = addCustomFields(mutation, this.customFields);
         const withoutReadonlyFields = this.removeReadonlyCustomFieldsFromVariables(mutation, variables);
@@ -73,7 +62,7 @@ export class BaseDataService {
             .mutate<T, V>({
                 mutation: withCustomFields,
                 variables: withoutReadonlyFields,
-                update: update as any,
+                update,
             })
             .pipe(map(result => result.data as T));
     }

+ 3 - 3
packages/admin-ui/src/lib/core/src/data/providers/data.service.ts

@@ -1,5 +1,5 @@
 import { Injectable } from '@angular/core';
-import { WatchQueryFetchPolicy } from 'apollo-client';
+import { MutationUpdaterFn, WatchQueryFetchPolicy } from '@apollo/client/core';
 import { DocumentNode } from 'graphql';
 import { Observable } from 'rxjs';
 
@@ -7,7 +7,7 @@ import { QueryResult } from '../query-result';
 
 import { AdministratorDataService } from './administrator-data.service';
 import { AuthDataService } from './auth-data.service';
-import { BaseDataService, TypedMutationUpdateFn } from './base-data.service';
+import { BaseDataService } from './base-data.service';
 import { ClientDataService } from './client-data.service';
 import { CollectionDataService } from './collection-data.service';
 import { CustomerDataService } from './customer-data.service';
@@ -63,7 +63,7 @@ export class DataService {
     mutate<T, V = Record<string, any>>(
         mutation: DocumentNode,
         variables?: V,
-        update?: TypedMutationUpdateFn<T>,
+        update?: MutationUpdaterFn<T>,
     ): Observable<T> {
         return this.baseDataService.mutate(mutation, variables, update);
     }

+ 1 - 1
packages/admin-ui/src/lib/core/src/data/providers/settings-data.service.ts

@@ -1,5 +1,5 @@
+import { FetchPolicy } from '@apollo/client/core';
 import { pick } from '@vendure/common/lib/pick';
-import { FetchPolicy } from 'apollo-client';
 
 import {
     AddMembersToZone,

+ 1 - 1
packages/admin-ui/src/lib/core/src/data/query-result.ts

@@ -1,6 +1,6 @@
+import { ApolloQueryResult, NetworkStatus } from '@apollo/client/core';
 import { notNullOrUndefined } from '@vendure/common/lib/shared-utils';
 import { Apollo, QueryRef } from 'apollo-angular';
-import { ApolloQueryResult, NetworkStatus } from 'apollo-client';
 import { merge, Observable, Subject } from 'rxjs';
 import { distinctUntilChanged, filter, finalize, map, skip, take, takeUntil, tap } from 'rxjs/operators';
 

+ 1 - 1
packages/admin-ui/src/lib/core/src/data/server-config.ts

@@ -1,5 +1,5 @@
 import { Injectable, Injector } from '@angular/core';
-import gql from 'graphql-tag';
+import { gql } from 'apollo-angular';
 
 import {
     CustomFieldConfig,

+ 1 - 1
packages/admin-ui/tsconfig.json

@@ -59,4 +59,4 @@
       ]
     }
   }
-}
+}

+ 1 - 1
scripts/codegen/generate-graphql-types.ts

@@ -125,7 +125,7 @@ Promise.all([
                     schema: [ADMIN_SCHEMA_OUTPUT_FILE, path.join(__dirname, 'client-schema.ts')],
                     documents: CLIENT_QUERY_FILES,
                     plugins: [disableTsLintPlugin, 'fragment-matcher'],
-                    config,
+                    config: { ...config, apolloClientVersion: 3 },
                 },
                 [path.join(__dirname, '../../packages/common/src/generated-types.ts')]: {
                     schema: [ADMIN_SCHEMA_OUTPUT_FILE],

Plik diff jest za duży
+ 593 - 80
yarn.lock


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