Explorar el Código

refactor(core): Re-organize graphql schema files

This change allows us to split between Admin & Shop APIs a little more easily. For example, this
removes 16 redundant Type definitions from the Shop API which are not actually used.
Michael Bromley hace 5 años
padre
commit
820ee68428
Se han modificado 47 ficheros con 289 adiciones y 313 borrados
  1. 14 13
      packages/admin-ui/src/lib/core/src/common/introspection-result.ts
  2. 2 2
      packages/core/src/api/api-internal-modules.ts
  3. 2 6
      packages/core/src/api/api.module.ts
  4. 89 71
      packages/core/src/api/config/configure-graphql-module.ts
  5. 0 0
      packages/core/src/api/schema/admin-api/administrator.type.graphql
  6. 3 0
      packages/core/src/api/schema/admin-api/collection-admin.type.graphql
  7. 0 4
      packages/core/src/api/schema/admin-api/collection.api.graphql
  8. 4 0
      packages/core/src/api/schema/admin-api/customer-admin.type.graphql
  9. 0 5
      packages/core/src/api/schema/admin-api/customer.api.graphql
  10. 3 0
      packages/core/src/api/schema/admin-api/facet-admin.type.graphql
  11. 0 4
      packages/core/src/api/schema/admin-api/facet.api.graphql
  12. 0 0
      packages/core/src/api/schema/admin-api/global-settings.type.graphql
  13. 4 0
      packages/core/src/api/schema/admin-api/history-entry-admin.type.graphql
  14. 0 0
      packages/core/src/api/schema/admin-api/import.type.graphql
  15. 4 0
      packages/core/src/api/schema/admin-api/order-admin.type.graphql
  16. 2 41
      packages/core/src/api/schema/admin-api/order.api.graphql
  17. 0 0
      packages/core/src/api/schema/admin-api/payment-method.type.graphql
  18. 15 0
      packages/core/src/api/schema/admin-api/product-admin.type.graphql
  19. 5 0
      packages/core/src/api/schema/admin-api/product-search-admin.type.graphql
  20. 0 6
      packages/core/src/api/schema/admin-api/product-search.api.graphql
  21. 0 16
      packages/core/src/api/schema/admin-api/product.api.graphql
  22. 0 0
      packages/core/src/api/schema/admin-api/stock-movement.type.graphql
  23. 0 0
      packages/core/src/api/schema/common/address.type.graphql
  24. 0 0
      packages/core/src/api/schema/common/asset.type.graphql
  25. 0 0
      packages/core/src/api/schema/common/auth.type.graphql
  26. 0 0
      packages/core/src/api/schema/common/channel.type.graphql
  27. 0 0
      packages/core/src/api/schema/common/collection.type.graphql
  28. 0 0
      packages/core/src/api/schema/common/country.type.graphql
  29. 0 0
      packages/core/src/api/schema/common/customer-group.type.graphql
  30. 0 0
      packages/core/src/api/schema/common/customer.type.graphql
  31. 0 0
      packages/core/src/api/schema/common/facet-value.type.graphql
  32. 0 0
      packages/core/src/api/schema/common/facet.type.graphql
  33. 0 2
      packages/core/src/api/schema/common/history-entry.type.graphql
  34. 0 0
      packages/core/src/api/schema/common/order.type.graphql
  35. 0 0
      packages/core/src/api/schema/common/product-option-group.type.graphql
  36. 0 0
      packages/core/src/api/schema/common/product-search.type.graphql
  37. 0 0
      packages/core/src/api/schema/common/product.type.graphql
  38. 0 0
      packages/core/src/api/schema/common/promotion.type.graphql
  39. 0 0
      packages/core/src/api/schema/common/role.type.graphql
  40. 0 0
      packages/core/src/api/schema/common/shipping-method.type.graphql
  41. 0 0
      packages/core/src/api/schema/common/tax-category.type.graphql
  42. 0 0
      packages/core/src/api/schema/common/tax-rate.type.graphql
  43. 0 0
      packages/core/src/api/schema/common/user.type.graphql
  44. 0 0
      packages/core/src/api/schema/common/zone.type.graphql
  45. 141 0
      packages/core/src/api/schema/shop-api/shop-error-results.graphql
  46. 0 142
      packages/core/src/api/schema/shop-api/shop.api.graphql
  47. 1 1
      scripts/codegen/client-schema.ts

+ 14 - 13
packages/admin-ui/src/lib/core/src/common/introspection-result.ts

@@ -52,14 +52,17 @@ const result: PossibleTypesResultData = {
         ],
         SettleRefundResult: ['Refund', 'RefundStateTransitionError'],
         TransitionFulfillmentToStateResult: ['Fulfillment', 'FulfillmentStateTransitionError'],
+        ModifyOrderResult: ['Order'],
         RemoveOptionGroupFromProductResult: ['Product', 'ProductOptionInUseError'],
         CreatePromotionResult: ['Promotion', 'MissingConditionsError'],
         UpdatePromotionResult: ['Promotion', 'MissingConditionsError'],
+        StockMovement: ['StockAdjustment', 'Allocation', 'Sale', 'Cancellation', 'Return', 'Release'],
+        StockMovementItem: ['StockAdjustment', 'Allocation', 'Sale', 'Cancellation', 'Return', 'Release'],
         PaginatedList: [
+            'AdministratorList',
             'CustomerGroupList',
             'JobList',
             'PaymentMethodList',
-            'AdministratorList',
             'AssetList',
             'CollectionList',
             'ProductVariantList',
@@ -75,38 +78,38 @@ const result: PossibleTypesResultData = {
             'TaxRateList',
         ],
         Node: [
+            'Administrator',
             'Collection',
             'Customer',
             'Facet',
-            'Fulfillment',
+            'HistoryEntry',
             'Job',
             'Order',
+            'Fulfillment',
+            'PaymentMethod',
             'Product',
             'ProductVariant',
+            'StockAdjustment',
+            'Allocation',
+            'Sale',
+            'Cancellation',
+            'Return',
+            'Release',
             'Address',
-            'Administrator',
             'Asset',
             'Channel',
             'Country',
             'CustomerGroup',
             'FacetValue',
-            'HistoryEntry',
             'OrderItem',
             'OrderLine',
             'Payment',
             'Refund',
-            'PaymentMethod',
             'ProductOptionGroup',
             'ProductOption',
             'Promotion',
             'Role',
             'ShippingMethod',
-            'StockAdjustment',
-            'Allocation',
-            'Sale',
-            'Cancellation',
-            'Return',
-            'Release',
             'TaxCategory',
             'TaxRate',
             'User',
@@ -160,8 +163,6 @@ const result: PossibleTypesResultData = {
             'DateTimeCustomFieldConfig',
         ],
         SearchResultPrice: ['PriceRange', 'SinglePrice'],
-        StockMovement: ['StockAdjustment', 'Allocation', 'Sale', 'Cancellation', 'Return', 'Release'],
-        StockMovementItem: ['StockAdjustment', 'Allocation', 'Sale', 'Cancellation', 'Return', 'Release'],
     },
 };
 export default result;

+ 2 - 2
packages/core/src/api/api-internal-modules.ts

@@ -102,7 +102,6 @@ const shopResolvers = [
 ];
 
 export const entityResolvers = [
-    AdministratorEntityResolver,
     CollectionEntityResolver,
     CustomerEntityResolver,
     CustomerGroupEntityResolver,
@@ -112,7 +111,6 @@ export const entityResolvers = [
     OrderEntityResolver,
     OrderLineEntityResolver,
     PaymentEntityResolver,
-    PaymentMethodEntityResolver,
     ProductEntityResolver,
     ProductOptionEntityResolver,
     ProductOptionGroupEntityResolver,
@@ -123,8 +121,10 @@ export const entityResolvers = [
 ];
 
 export const adminEntityResolvers = [
+    AdministratorEntityResolver,
     CustomerAdminEntityResolver,
     OrderAdminEntityResolver,
+    PaymentMethodEntityResolver,
     FulfillmentAdminEntityResolver,
     ProductVariantAdminEntityResolver,
     ProductAdminEntityResolver,

+ 2 - 6
packages/core/src/api/api.module.ts

@@ -33,9 +33,7 @@ import { ValidateCustomFieldsInterceptor } from './middleware/validate-custom-fi
             apiPath: configService.apiOptions.shopApiPath,
             playground: configService.apiOptions.shopApiPlayground,
             debug: configService.apiOptions.shopApiDebug,
-            typePaths: ['type', 'shop-api', 'common'].map(p =>
-                path.join(__dirname, 'schema', p, '*.graphql'),
-            ),
+            typePaths: ['shop-api', 'common'].map(p => path.join(__dirname, 'schema', p, '*.graphql')),
             resolverModule: ShopApiModule,
         })),
         configureGraphQLModule(configService => ({
@@ -43,9 +41,7 @@ import { ValidateCustomFieldsInterceptor } from './middleware/validate-custom-fi
             apiPath: configService.apiOptions.adminApiPath,
             playground: configService.apiOptions.adminApiPlayground,
             debug: configService.apiOptions.adminApiDebug,
-            typePaths: ['type', 'admin-api', 'common'].map(p =>
-                path.join(__dirname, 'schema', p, '*.graphql'),
-            ),
+            typePaths: ['admin-api', 'common'].map(p => path.join(__dirname, 'schema', p, '*.graphql')),
             resolverModule: AdminApiModule,
         })),
     ],

+ 89 - 71
packages/core/src/api/config/configure-graphql-module.ts

@@ -20,6 +20,7 @@ import { I18nService } from '../../i18n/i18n.service';
 import { getDynamicGraphQlModulesForPlugins } from '../../plugin/dynamic-plugin-api.module';
 import { getPluginAPIExtensions } from '../../plugin/plugin-metadata';
 import { ApiSharedModule } from '../api-internal-modules';
+import { ApiType } from '../common/get-api-type';
 import { IdCodecService } from '../common/id-codec.service';
 import { AssetInterceptorPlugin } from '../middleware/asset-interceptor-plugin';
 import { IdCodecPlugin } from '../middleware/id-codec-plugin';
@@ -79,80 +80,11 @@ async function createGraphQLOptions(
     typesLoader: GraphQLTypesLoader,
     options: GraphQLApiOptions,
 ): Promise<GqlModuleOptions> {
-    // Prevent `Type "Node" is missing a "resolveType" resolver.` warnings.
-    // See https://github.com/apollographql/apollo-server/issues/1075
-    const dummyResolveType = {
-        __resolveType() {
-            return null;
-        },
-    };
-
-    const stockMovementResolveType = {
-        __resolveType(value: any) {
-            switch (value.type) {
-                case StockMovementType.ADJUSTMENT:
-                    return 'StockAdjustment';
-                case StockMovementType.ALLOCATION:
-                    return 'Allocation';
-                case StockMovementType.SALE:
-                    return 'Sale';
-                case StockMovementType.CANCELLATION:
-                    return 'Cancellation';
-                case StockMovementType.RETURN:
-                    return 'Return';
-                case StockMovementType.RELEASE:
-                    return 'Release';
-            }
-        },
-    };
-
-    const customFieldsConfigResolveType = {
-        __resolveType(value: any) {
-            switch (value.type) {
-                case 'string':
-                    return 'StringCustomFieldConfig';
-                case 'localeString':
-                    return 'LocaleStringCustomFieldConfig';
-                case 'int':
-                    return 'IntCustomFieldConfig';
-                case 'float':
-                    return 'FloatCustomFieldConfig';
-                case 'boolean':
-                    return 'BooleanCustomFieldConfig';
-                case 'datetime':
-                    return 'DateTimeCustomFieldConfig';
-            }
-        },
-    };
-
     return {
         path: '/' + options.apiPath,
         typeDefs: await createTypeDefs(options.apiType),
         include: [options.resolverModule, ...getDynamicGraphQlModulesForPlugins(options.apiType)],
-        resolvers: {
-            JSON: GraphQLJSON,
-            DateTime: GraphQLDateTime,
-            Node: dummyResolveType,
-            PaginatedList: dummyResolveType,
-            Upload: GraphQLUpload || dummyResolveType,
-            SearchResultPrice: {
-                __resolveType(value: any) {
-                    return value.hasOwnProperty('value') ? 'SinglePrice' : 'PriceRange';
-                },
-            },
-            StockMovementItem: stockMovementResolveType,
-            StockMovement: stockMovementResolveType,
-            CustomFieldConfig: customFieldsConfigResolveType,
-            CustomField: customFieldsConfigResolveType,
-            ErrorResult: {
-                __resolveType(value: ErrorResult) {
-                    return value.__typename;
-                },
-            },
-            ...(options.apiType === 'admin'
-                ? adminErrorOperationTypeResolvers
-                : shopErrorOperationTypeResolvers),
-        },
+        resolvers: createResolvers(options.apiType),
         uploads: {
             maxFileSize: configService.assetOptions.uploadMaxFileSize,
         },
@@ -194,10 +126,12 @@ async function createGraphQLOptions(
         schema = generatePermissionEnum(schema, configService.authOptions.customPermissions);
         schema = generateListOptions(schema);
         schema = addGraphQLCustomFields(schema, customFields, apiType === 'shop');
-        schema = addServerConfigCustomFields(schema, customFields);
         schema = addOrderLineCustomFieldsInput(schema, customFields.OrderLine || []);
         schema = generateAuthenticationTypes(schema, authStrategies);
         schema = generateErrorCodeEnum(schema);
+        if (apiType === 'admin') {
+            schema = addServerConfigCustomFields(schema, customFields);
+        }
         if (apiType === 'shop') {
             schema = addRegisterCustomerCustomFieldsInput(schema, customFields.Customer || []);
         }
@@ -205,3 +139,87 @@ async function createGraphQLOptions(
         return printSchema(schema);
     }
 }
+
+function createResolvers(apiType: ApiType) {
+    // Prevent `Type "Node" is missing a "resolveType" resolver.` warnings.
+    // See https://github.com/apollographql/apollo-server/issues/1075
+    const dummyResolveType = {
+        __resolveType() {
+            return null;
+        },
+    };
+
+    const stockMovementResolveType = {
+        __resolveType(value: any) {
+            switch (value.type) {
+                case StockMovementType.ADJUSTMENT:
+                    return 'StockAdjustment';
+                case StockMovementType.ALLOCATION:
+                    return 'Allocation';
+                case StockMovementType.SALE:
+                    return 'Sale';
+                case StockMovementType.CANCELLATION:
+                    return 'Cancellation';
+                case StockMovementType.RETURN:
+                    return 'Return';
+                case StockMovementType.RELEASE:
+                    return 'Release';
+            }
+        },
+    };
+
+    const customFieldsConfigResolveType = {
+        __resolveType(value: any) {
+            switch (value.type) {
+                case 'string':
+                    return 'StringCustomFieldConfig';
+                case 'localeString':
+                    return 'LocaleStringCustomFieldConfig';
+                case 'int':
+                    return 'IntCustomFieldConfig';
+                case 'float':
+                    return 'FloatCustomFieldConfig';
+                case 'boolean':
+                    return 'BooleanCustomFieldConfig';
+                case 'datetime':
+                    return 'DateTimeCustomFieldConfig';
+            }
+        },
+    };
+
+    const commonResolvers = {
+        JSON: GraphQLJSON,
+        DateTime: GraphQLDateTime,
+        Node: dummyResolveType,
+        PaginatedList: dummyResolveType,
+        Upload: GraphQLUpload || dummyResolveType,
+        SearchResultPrice: {
+            __resolveType(value: any) {
+                return value.hasOwnProperty('value') ? 'SinglePrice' : 'PriceRange';
+            },
+        },
+        CustomFieldConfig: customFieldsConfigResolveType,
+        CustomField: customFieldsConfigResolveType,
+        ErrorResult: {
+            __resolveType(value: ErrorResult) {
+                return value.__typename;
+            },
+        },
+    };
+
+    const adminResolvers = {
+        StockMovementItem: stockMovementResolveType,
+        StockMovement: stockMovementResolveType,
+        ...adminErrorOperationTypeResolvers,
+    };
+
+    const shopResolvers = {
+        ...shopErrorOperationTypeResolvers,
+    };
+
+    const resolvers =
+        apiType === 'admin'
+            ? { ...commonResolvers, ...adminResolvers }
+            : { ...commonResolvers, ...shopResolvers };
+    return resolvers;
+}

+ 0 - 0
packages/core/src/api/schema/type/administrator.type.graphql → packages/core/src/api/schema/admin-api/administrator.type.graphql


+ 3 - 0
packages/core/src/api/schema/admin-api/collection-admin.type.graphql

@@ -0,0 +1,3 @@
+type Collection implements Node {
+    isPrivate: Boolean!
+}

+ 0 - 4
packages/core/src/api/schema/admin-api/collection.api.graphql

@@ -19,10 +19,6 @@ type Mutation {
     moveCollection(input: MoveCollectionInput!): Collection!
 }
 
-type Collection implements Node {
-    isPrivate: Boolean!
-}
-
 # generated by generateListOptions function
 input CollectionListOptions
 

+ 4 - 0
packages/core/src/api/schema/admin-api/customer-admin.type.graphql

@@ -0,0 +1,4 @@
+type Customer implements Node {
+    groups: [CustomerGroup!]!
+    history(options: HistoryEntryListOptions): HistoryEntryList!
+}

+ 0 - 5
packages/core/src/api/schema/admin-api/customer.api.graphql

@@ -27,11 +27,6 @@ type Mutation {
     deleteCustomerNote(id: ID!): DeletionResponse!
 }
 
-type Customer implements Node {
-    groups: [CustomerGroup!]!
-    history(options: HistoryEntryListOptions): HistoryEntryList!
-}
-
 input UpdateCustomerInput {
     id: ID!
     title: String

+ 3 - 0
packages/core/src/api/schema/admin-api/facet-admin.type.graphql

@@ -0,0 +1,3 @@
+type Facet implements Node {
+    isPrivate: Boolean!
+}

+ 0 - 4
packages/core/src/api/schema/admin-api/facet.api.graphql

@@ -23,10 +23,6 @@ type Mutation {
     deleteFacetValues(ids: [ID!]!, force: Boolean): [DeletionResponse!]!
 }
 
-type Facet implements Node {
-    isPrivate: Boolean!
-}
-
 # generated by generateListOptions function
 input FacetListOptions
 

+ 0 - 0
packages/core/src/api/schema/type/global-settings.type.graphql → packages/core/src/api/schema/admin-api/global-settings.type.graphql


+ 4 - 0
packages/core/src/api/schema/admin-api/history-entry-admin.type.graphql

@@ -0,0 +1,4 @@
+type HistoryEntry implements Node {
+    isPublic: Boolean!
+    administrator: Administrator
+}

+ 0 - 0
packages/core/src/api/schema/type/import.type.graphql → packages/core/src/api/schema/admin-api/import.type.graphql


+ 4 - 0
packages/core/src/api/schema/admin-api/fulfillment.api.graphql → packages/core/src/api/schema/admin-api/order-admin.type.graphql

@@ -1,3 +1,7 @@
+type Order {
+    nextStates: [String!]!
+}
+
 type Fulfillment {
     nextStates: [String!]!
 }

+ 2 - 41
packages/core/src/api/schema/admin-api/order.api.graphql

@@ -15,11 +15,6 @@ type Mutation {
     transitionOrderToState(id: ID!, state: String!): TransitionOrderToStateResult
     transitionFulfillmentToState(id: ID!, state: String!): TransitionFulfillmentToStateResult!
     setOrderCustomFields(input: UpdateOrderInput!): Order
-    # modifyOrder(input: ModifyOrderInput!): ModifyOrderResult!
-}
-
-type Order {
-    nextStates: [String!]!
 }
 
 # generated by generateListOptions function
@@ -73,30 +68,6 @@ input UpdateOrderNoteInput {
     isPublic: Boolean
 }
 
-#input ModifyOrderInput {
-#    id: ID!
-#    addItems: [AddItemInput!]
-#    adjustOrderLines: [OrderLineInput!]
-#    surcharges: [SurchargeInput!]
-#    recalculatePromotions: Boolean!
-#    note: String
-#}
-#
-#input AddItemInput {
-#    productVariantId: ID!
-#    quantity: Int!
-#}
-#
-#input OrderLineInput {
-#    orderLineId: ID!
-#    quantity: Int!
-#}
-#
-#input SurchargeInput {
-#    description: String!
-#    amount: Int!
-#}
-
 "Returned if the Payment settlement fails"
 type SettlePaymentError implements ErrorResult {
     errorCode: ErrorCode!
@@ -213,12 +184,6 @@ type FulfillmentStateTransitionError implements ErrorResult {
     toState: String!
 }
 
-#"Returned when attempting to modify the contents of an Order that is not in the `Modifying` state."
-#type OrderModificationStateError implements ErrorResult {
-#    errorCode: ErrorCode!
-#    message: String!
-#}
-
 union TransitionOrderToStateResult = Order | OrderStateTransitionError
 union SettlePaymentResult =
       Payment
@@ -252,9 +217,5 @@ union RefundOrderResult =
     | RefundStateTransitionError
 union SettleRefundResult = Refund | RefundStateTransitionError
 union TransitionFulfillmentToStateResult = Fulfillment | FulfillmentStateTransitionError
-#union ModifyOrderResult =
-#      Order
-#    | OrderModificationStateError
-#    | OrderLimitError
-#    | NegativeQuantityError
-#    | InsufficientStockError
+union ModifyOrderResult =
+      Order

+ 0 - 0
packages/core/src/api/schema/type/payment-method.type.graphql → packages/core/src/api/schema/admin-api/payment-method.type.graphql


+ 15 - 0
packages/core/src/api/schema/admin-api/product-admin.type.graphql

@@ -0,0 +1,15 @@
+type Product implements Node {
+    enabled: Boolean!
+    channels: [Channel!]!
+}
+
+type ProductVariant implements Node {
+    enabled: Boolean!
+    trackInventory: GlobalFlag!
+    stockOnHand: Int!
+    stockAllocated: Int!
+    outOfStockThreshold: Int!
+    useGlobalOutOfStockThreshold: Boolean!
+    stockMovements(options: StockMovementListOptions): StockMovementList!
+    channels: [Channel!]!
+}

+ 5 - 0
packages/core/src/api/schema/admin-api/product-search-admin.type.graphql

@@ -0,0 +1,5 @@
+type SearchResult {
+    enabled: Boolean!
+    "An array of ids of the Channels in which this result appears"
+    channelIds: [ID!]!
+}

+ 0 - 6
packages/core/src/api/schema/admin-api/product-search.api.graphql

@@ -5,9 +5,3 @@ type Query {
 type Mutation {
     reindex: Job!
 }
-
-type SearchResult {
-    enabled: Boolean!
-    "An array of ids of the Collections in which this result appears"
-    channelIds: [ID!]!
-}

+ 0 - 16
packages/core/src/api/schema/admin-api/product.api.graphql

@@ -44,22 +44,6 @@ type Mutation {
     removeProductVariantsFromChannel(input: RemoveProductVariantsFromChannelInput!): [ProductVariant!]!
 }
 
-type Product implements Node {
-    enabled: Boolean!
-    channels: [Channel!]!
-}
-
-type ProductVariant implements Node {
-    enabled: Boolean!
-    trackInventory: GlobalFlag!
-    stockOnHand: Int!
-    stockAllocated: Int!
-    outOfStockThreshold: Int!
-    useGlobalOutOfStockThreshold: Boolean!
-    stockMovements(options: StockMovementListOptions): StockMovementList!
-    channels: [Channel!]!
-}
-
 input StockMovementListOptions {
     type: StockMovementType
     skip: Int

+ 0 - 0
packages/core/src/api/schema/type/stock-movement.type.graphql → packages/core/src/api/schema/admin-api/stock-movement.type.graphql


+ 0 - 0
packages/core/src/api/schema/type/address.type.graphql → packages/core/src/api/schema/common/address.type.graphql


+ 0 - 0
packages/core/src/api/schema/type/asset.type.graphql → packages/core/src/api/schema/common/asset.type.graphql


+ 0 - 0
packages/core/src/api/schema/type/auth.type.graphql → packages/core/src/api/schema/common/auth.type.graphql


+ 0 - 0
packages/core/src/api/schema/type/channel.type.graphql → packages/core/src/api/schema/common/channel.type.graphql


+ 0 - 0
packages/core/src/api/schema/type/collection.type.graphql → packages/core/src/api/schema/common/collection.type.graphql


+ 0 - 0
packages/core/src/api/schema/type/country.type.graphql → packages/core/src/api/schema/common/country.type.graphql


+ 0 - 0
packages/core/src/api/schema/type/customer-group.type.graphql → packages/core/src/api/schema/common/customer-group.type.graphql


+ 0 - 0
packages/core/src/api/schema/type/customer.type.graphql → packages/core/src/api/schema/common/customer.type.graphql


+ 0 - 0
packages/core/src/api/schema/type/facet-value.type.graphql → packages/core/src/api/schema/common/facet-value.type.graphql


+ 0 - 0
packages/core/src/api/schema/type/facet.type.graphql → packages/core/src/api/schema/common/facet.type.graphql


+ 0 - 2
packages/core/src/api/schema/type/history-entry.type.graphql → packages/core/src/api/schema/common/history-entry.type.graphql

@@ -2,9 +2,7 @@ type HistoryEntry implements Node {
     id: ID!
     createdAt: DateTime!
     updatedAt: DateTime!
-    isPublic: Boolean!
     type: HistoryEntryType!
-    administrator: Administrator
     data: JSON!
 }
 

+ 0 - 0
packages/core/src/api/schema/type/order.type.graphql → packages/core/src/api/schema/common/order.type.graphql


+ 0 - 0
packages/core/src/api/schema/type/product-option-group.type.graphql → packages/core/src/api/schema/common/product-option-group.type.graphql


+ 0 - 0
packages/core/src/api/schema/type/product-search.type.graphql → packages/core/src/api/schema/common/product-search.type.graphql


+ 0 - 0
packages/core/src/api/schema/type/product.type.graphql → packages/core/src/api/schema/common/product.type.graphql


+ 0 - 0
packages/core/src/api/schema/type/promotion.type.graphql → packages/core/src/api/schema/common/promotion.type.graphql


+ 0 - 0
packages/core/src/api/schema/type/role.type.graphql → packages/core/src/api/schema/common/role.type.graphql


+ 0 - 0
packages/core/src/api/schema/type/shipping-method.type.graphql → packages/core/src/api/schema/common/shipping-method.type.graphql


+ 0 - 0
packages/core/src/api/schema/type/tax-category.type.graphql → packages/core/src/api/schema/common/tax-category.type.graphql


+ 0 - 0
packages/core/src/api/schema/type/tax-rate.type.graphql → packages/core/src/api/schema/common/tax-rate.type.graphql


+ 0 - 0
packages/core/src/api/schema/type/user.type.graphql → packages/core/src/api/schema/common/user.type.graphql


+ 0 - 0
packages/core/src/api/schema/type/zone.type.graphql → packages/core/src/api/schema/common/zone.type.graphql


+ 141 - 0
packages/core/src/api/schema/shop-api/shop-error-results.graphql

@@ -0,0 +1,141 @@
+"Returned when attempting to modify the contents of an Order that is not in the `AddingItems` state."
+type OrderModificationError implements ErrorResult {
+    errorCode: ErrorCode!
+    message: String!
+}
+
+"Returned when attempting to set a ShippingMethod for which the order is not eligible"
+type IneligibleShippingMethodError implements ErrorResult {
+    errorCode: ErrorCode!
+    message: String!
+}
+
+"Returned when attempting to add a Payment to an Order that is not in the `ArrangingPayment` state."
+type OrderPaymentStateError implements ErrorResult {
+    errorCode: ErrorCode!
+    message: String!
+}
+
+"Returned when a Payment fails due to an error."
+type PaymentFailedError implements ErrorResult {
+    errorCode: ErrorCode!
+    message: String!
+    paymentErrorMessage: String!
+}
+
+"Returned when a Payment is declined by the payment provider."
+type PaymentDeclinedError implements ErrorResult {
+    errorCode: ErrorCode!
+    message: String!
+    paymentErrorMessage: String!
+}
+
+"Returned if the provided coupon code is invalid"
+type CouponCodeInvalidError implements ErrorResult {
+    errorCode: ErrorCode!
+    message: String!
+    couponCode: String!
+}
+
+"Returned if the provided coupon code is invalid"
+type CouponCodeInvalidError implements ErrorResult {
+    errorCode: ErrorCode!
+    message: String!
+    couponCode: String!
+}
+
+"Returned if the provided coupon code is invalid"
+type CouponCodeExpiredError implements ErrorResult {
+    errorCode: ErrorCode!
+    message: String!
+    couponCode: String!
+}
+
+"Returned if the provided coupon code is invalid"
+type CouponCodeLimitError implements ErrorResult {
+    errorCode: ErrorCode!
+    message: String!
+    couponCode: String!
+    limit: Int!
+}
+
+"Retured when attemting to set the Customer for an Order when already logged in."
+type AlreadyLoggedInError implements ErrorResult {
+    errorCode: ErrorCode!
+    message: String!
+}
+
+"Retured when attemting to register or verify a customer account without a password, when one is required."
+type MissingPasswordError implements ErrorResult {
+    errorCode: ErrorCode!
+    message: String!
+}
+
+"Retured when attemting to verify a customer account with a password, when a password has already been set."
+type PasswordAlreadySetError implements ErrorResult {
+    errorCode: ErrorCode!
+    message: String!
+}
+
+"""
+Retured if the verification token (used to verify a Customer's email address) is either
+invalid or does not match any expected tokens.
+"""
+type VerificationTokenInvalidError implements ErrorResult {
+    errorCode: ErrorCode!
+    message: String!
+}
+
+"""
+Returned if the verification token (used to verify a Customer's email address) is valid, but has
+expired according to the `verificationTokenDuration` setting in the AuthOptions.
+"""
+type VerificationTokenExpiredError implements ErrorResult {
+    errorCode: ErrorCode!
+    message: String!
+}
+
+"""
+Retured if the token used to change a Customer's email address is either
+invalid or does not match any expected tokens.
+"""
+type IdentifierChangeTokenInvalidError implements ErrorResult {
+    errorCode: ErrorCode!
+    message: String!
+}
+
+"""
+Retured if the token used to change a Customer's email address is valid, but has
+expired according to the `verificationTokenDuration` setting in the AuthOptions.
+"""
+type IdentifierChangeTokenExpiredError implements ErrorResult {
+    errorCode: ErrorCode!
+    message: String!
+}
+
+"""
+Retured if the token used to reset a Customer's password is either
+invalid or does not match any expected tokens.
+"""
+type PasswordResetTokenInvalidError implements ErrorResult {
+    errorCode: ErrorCode!
+    message: String!
+}
+
+"""
+Retured if the token used to reset a Customer's password is valid, but has
+expired according to the `verificationTokenDuration` setting in the AuthOptions.
+"""
+type PasswordResetTokenExpiredError implements ErrorResult {
+    errorCode: ErrorCode!
+    message: String!
+}
+
+"""
+Returned if `authOptions.requireVerification` is set to `true` (which is the default)
+and an unverified user attempts to authenticate.
+"""
+type NotVerifiedError implements ErrorResult {
+    errorCode: ErrorCode!
+    message: String!
+}

+ 0 - 142
packages/core/src/api/schema/shop-api/shop.api.graphql

@@ -178,148 +178,6 @@ input OrderListOptions
 # generated by generateListOptions function
 input ProductListOptions
 
-"Returned when attempting to modify the contents of an Order that is not in the `AddingItems` state."
-type OrderModificationError implements ErrorResult {
-    errorCode: ErrorCode!
-    message: String!
-}
-
-"Returned when attempting to set a ShippingMethod for which the order is not eligible"
-type IneligibleShippingMethodError implements ErrorResult {
-    errorCode: ErrorCode!
-    message: String!
-}
-
-"Returned when attempting to add a Payment to an Order that is not in the `ArrangingPayment` state."
-type OrderPaymentStateError implements ErrorResult {
-    errorCode: ErrorCode!
-    message: String!
-}
-
-"Returned when a Payment fails due to an error."
-type PaymentFailedError implements ErrorResult {
-    errorCode: ErrorCode!
-    message: String!
-    paymentErrorMessage: String!
-}
-
-"Returned when a Payment is declined by the payment provider."
-type PaymentDeclinedError implements ErrorResult {
-    errorCode: ErrorCode!
-    message: String!
-    paymentErrorMessage: String!
-}
-
-"Returned if the provided coupon code is invalid"
-type CouponCodeInvalidError implements ErrorResult {
-    errorCode: ErrorCode!
-    message: String!
-    couponCode: String!
-}
-
-"Returned if the provided coupon code is invalid"
-type CouponCodeInvalidError implements ErrorResult {
-    errorCode: ErrorCode!
-    message: String!
-    couponCode: String!
-}
-
-"Returned if the provided coupon code is invalid"
-type CouponCodeExpiredError implements ErrorResult {
-    errorCode: ErrorCode!
-    message: String!
-    couponCode: String!
-}
-
-"Returned if the provided coupon code is invalid"
-type CouponCodeLimitError implements ErrorResult {
-    errorCode: ErrorCode!
-    message: String!
-    couponCode: String!
-    limit: Int!
-}
-
-"Retured when attemting to set the Customer for an Order when already logged in."
-type AlreadyLoggedInError implements ErrorResult {
-    errorCode: ErrorCode!
-    message: String!
-}
-
-"Retured when attemting to register or verify a customer account without a password, when one is required."
-type MissingPasswordError implements ErrorResult {
-    errorCode: ErrorCode!
-    message: String!
-}
-
-"Retured when attemting to verify a customer account with a password, when a password has already been set."
-type PasswordAlreadySetError implements ErrorResult {
-    errorCode: ErrorCode!
-    message: String!
-}
-
-"""
-Retured if the verification token (used to verify a Customer's email address) is either
-invalid or does not match any expected tokens.
-"""
-type VerificationTokenInvalidError implements ErrorResult {
-    errorCode: ErrorCode!
-    message: String!
-}
-
-"""
-Returned if the verification token (used to verify a Customer's email address) is valid, but has
-expired according to the `verificationTokenDuration` setting in the AuthOptions.
-"""
-type VerificationTokenExpiredError implements ErrorResult {
-    errorCode: ErrorCode!
-    message: String!
-}
-
-"""
-Retured if the token used to change a Customer's email address is either
-invalid or does not match any expected tokens.
-"""
-type IdentifierChangeTokenInvalidError implements ErrorResult {
-    errorCode: ErrorCode!
-    message: String!
-}
-
-"""
-Retured if the token used to change a Customer's email address is valid, but has
-expired according to the `verificationTokenDuration` setting in the AuthOptions.
-"""
-type IdentifierChangeTokenExpiredError implements ErrorResult {
-    errorCode: ErrorCode!
-    message: String!
-}
-
-"""
-Retured if the token used to reset a Customer's password is either
-invalid or does not match any expected tokens.
-"""
-type PasswordResetTokenInvalidError implements ErrorResult {
-    errorCode: ErrorCode!
-    message: String!
-}
-
-"""
-Retured if the token used to reset a Customer's password is valid, but has
-expired according to the `verificationTokenDuration` setting in the AuthOptions.
-"""
-type PasswordResetTokenExpiredError implements ErrorResult {
-    errorCode: ErrorCode!
-    message: String!
-}
-
-"""
-Returned if `authOptions.requireVerification` is set to `true` (which is the default)
-and an unverified user attempts to authenticate.
-"""
-type NotVerifiedError implements ErrorResult {
-    errorCode: ErrorCode!
-    message: String!
-}
-
 union UpdateOrderItemsResult =
       Order
     | OrderModificationError

+ 1 - 1
scripts/codegen/client-schema.ts

@@ -4,7 +4,7 @@ import path from 'path';
 
 const CLIENT_SCHEMA_FILE = '../../packages/admin-ui/src/lib/core/src/data/client-state/client-types.graphql';
 const LANGUAGE_CODE_FILE = '../../packages/core/src/api/schema/common/language-code.graphql';
-const AUTH_TYPE_FILE = '../../packages/core/src/api/schema/type/auth.type.graphql';
+const AUTH_TYPE_FILE = '../../packages/core/src/api/schema/common/auth.type.graphql';
 
 function loadGraphQL(file: string): string {
     const filePath = path.join(__dirname, file);