瀏覽代碼

fix(core): Update NestJS & graphql-related deps to fix version conflict

Relates to #532
Changes to e2e tests relate to the new handling of bad user input described here:
https://github.com/apollographql/apollo-server/
blob/9267a79b974e397e87ad9ee408b65c46751e4565/CHANGELOG.md#v2230
Michael Bromley 4 年之前
父節點
當前提交
8891c43696

+ 8 - 6
packages/core/e2e/role.e2e-spec.ts

@@ -56,18 +56,20 @@ describe('Role resolver', () => {
         expect(result.roles.totalItems).toBe(2);
     });
 
-    it(
-        'createRole with invalid permission',
-        assertThrowsWithMessage(async () => {
+    it('createRole with invalid permission', async () => {
+        try {
             await adminClient.query<CreateRole.Mutation, CreateRole.Variables>(CREATE_ROLE, {
                 input: {
                     code: 'test',
                     description: 'test role',
-                    permissions: ['bad permission' as any],
+                    permissions: ['ReadCatalogx' as any],
                 },
             });
-        }, 'Variable "$input" got invalid value "bad permission" at "input.permissions[0]"'),
-    );
+            fail('Should have thrown');
+        } catch (e) {
+            expect(e.response.errors[0]?.extensions.code).toBe('BAD_USER_INPUT');
+        }
+    });
 
     it('createRole with no permissions includes Authenticated', async () => {
         const { createRole } = await adminClient.query<CreateRole.Mutation, CreateRole.Variables>(

+ 7 - 5
packages/core/e2e/shop-order.e2e-spec.ts

@@ -251,9 +251,8 @@ describe('Shop orders', () => {
                     }
                 }
             `;
-            it(
-                'addItemToOrder with private customFields errors',
-                assertThrowsWithMessage(async () => {
+            it('addItemToOrder with private customFields errors', async () => {
+                try {
                     await shopClient.query<AddItemToOrder.Mutation>(ADD_ITEM_TO_ORDER_WITH_CUSTOM_FIELDS, {
                         productVariantId: 'T_2',
                         quantity: 1,
@@ -261,8 +260,11 @@ describe('Shop orders', () => {
                             privateField: 'oh no!',
                         },
                     });
-                }, 'Variable "$customFields" got invalid value { privateField: "oh no!" }; Field "privateField" is not defined by type "OrderLineCustomFieldsInput".'),
-            );
+                    fail('Should have thrown');
+                } catch (e) {
+                    expect(e.response.errors[0].extensions.code).toBe('BAD_USER_INPUT');
+                }
+            });
 
             it('addItemToOrder with equal customFields adds quantity to the existing OrderLine', async () => {
                 const { addItemToOrder: add1 } = await shopClient.query<AddItemToOrder.Mutation>(

+ 11 - 10
packages/core/package.json

@@ -38,17 +38,17 @@
     "cli/**/*"
   ],
   "dependencies": {
-    "@graphql-tools/stitch": "^6.2.4",
-    "@nestjs/common": "7.6.13",
-    "@nestjs/core": "7.6.13",
-    "@nestjs/graphql": "7.9.7",
-    "@nestjs/platform-express": "7.6.13",
-    "@nestjs/terminus": "7.1.0",
-    "@nestjs/testing": "7.6.13",
+    "@graphql-tools/stitch": "^7.5.3",
+    "@nestjs/common": "7.6.17",
+    "@nestjs/core": "7.6.17",
+    "@nestjs/graphql": "7.10.6",
+    "@nestjs/platform-express": "7.6.17",
+    "@nestjs/terminus": "7.2.0",
+    "@nestjs/testing": "7.6.17",
     "@nestjs/typeorm": "7.1.5",
     "@types/fs-extra": "^9.0.1",
     "@vendure/common": "^1.0.0",
-    "apollo-server-express": "2.21.0",
+    "apollo-server-express": "2.24.1",
     "bcrypt": "^5.0.0",
     "body-parser": "^1.19.0",
     "chalk": "^4.1.0",
@@ -59,9 +59,9 @@
     "fs-extra": "^9.0.1",
     "graphql": "15.5.0",
     "graphql-iso-date": "^3.6.1",
-    "graphql-tag": "^2.11.0",
+    "graphql-tag": "^2.12.4",
     "graphql-type-json": "^0.3.2",
-    "graphql-upload": "^11.0.0",
+    "graphql-upload": "^12.0.0",
     "http-proxy-middleware": "^1.0.5",
     "i18next": "^19.8.1",
     "i18next-express-middleware": "^2.0.0",
@@ -84,6 +84,7 @@
     "@types/faker": "^4.1.7",
     "@types/graphql-iso-date": "^3.4.0",
     "@types/graphql-type-json": "^0.3.2",
+    "@types/graphql-upload": "^8.0.4",
     "@types/gulp": "^4.0.7",
     "@types/mime-types": "^2.1.0",
     "@types/ms": "^0.7.31",

+ 6 - 2
packages/core/src/api/config/generate-auth-types.ts

@@ -1,4 +1,4 @@
-import { stitchSchemas } from '@graphql-tools/stitch';
+import { stitchSchemas, ValidationLevel } from '@graphql-tools/stitch';
 import {
     buildASTSchema,
     GraphQLInputFieldConfigMap,
@@ -46,5 +46,9 @@ export function generateAuthenticationTypes(
         fields,
     });
 
-    return stitchSchemas({ schemas: [schema, ...strategySchemas, [authenticationInput]] });
+    return stitchSchemas({
+        subschemas: [schema, ...strategySchemas],
+        types: [authenticationInput],
+        typeMergingOptions: { validationSettings: { validationLevel: ValidationLevel.Off } },
+    });
 }

+ 6 - 2
packages/core/src/api/config/generate-list-options.ts

@@ -1,4 +1,4 @@
-import { stitchSchemas } from '@graphql-tools/stitch';
+import { stitchSchemas, ValidationLevel } from '@graphql-tools/stitch';
 import { notNullOrUndefined } from '@vendure/common/lib/shared-utils';
 import {
     buildSchema,
@@ -74,7 +74,11 @@ export function generateListOptions(typeDefsOrSchema: string | GraphQLSchema): G
             generatedTypes.push(generatedListOptions);
         }
     }
-    return stitchSchemas({ schemas: [schema, generatedTypes] });
+    return stitchSchemas({
+        subschemas: [schema],
+        types: generatedTypes,
+        typeMergingOptions: { validationSettings: { validationLevel: ValidationLevel.Off } },
+    });
 }
 
 function isListQueryType(type: GraphQLOutputType): type is GraphQLObjectType {

+ 7 - 3
packages/core/src/api/config/generate-permissions.ts

@@ -1,5 +1,5 @@
-import { stitchSchemas } from '@graphql-tools/stitch';
-import { GraphQLEnumType, GraphQLInputObjectType, GraphQLSchema } from 'graphql';
+import { stitchSchemas, ValidationLevel } from '@graphql-tools/stitch';
+import { GraphQLEnumType, GraphQLSchema } from 'graphql';
 import { GraphQLEnumValueConfigMap } from 'graphql/type/definition';
 
 import { getAllPermissionsMetadata } from '../../common/constants';
@@ -35,5 +35,9 @@ export function generatePermissionEnum(
         values,
     });
 
-    return stitchSchemas({ schemas: [schema, [permissionsEnum]] });
+    return stitchSchemas({
+        subschemas: [schema],
+        types: [permissionsEnum],
+        typeMergingOptions: { validationSettings: { validationLevel: ValidationLevel.Off } },
+    });
 }

+ 2 - 2
packages/email-plugin/src/dev-mailbox.ts

@@ -1,6 +1,6 @@
 import { LanguageCode } from '@vendure/common/lib/generated-types';
 import { Channel, RequestContext } from '@vendure/core';
-import express from 'express';
+import express, { Router } from 'express';
 import fs from 'fs-extra';
 import http from 'http';
 import path from 'path';
@@ -17,7 +17,7 @@ export class DevMailbox {
         event: EventWithContext,
     ) => void | undefined;
 
-    serve(options: EmailPluginDevModeOptions) {
+    serve(options: EmailPluginDevModeOptions): Router {
         const { outputPath, handlers } = options;
         const server = express.Router();
         server.get('/', (req, res) => {

File diff suppressed because it is too large
+ 349 - 351
yarn.lock


Some files were not shown because too many files changed in this diff