diff --git a/package-lock.json b/package-lock.json index 8a1a0807e4b..8b426469587 100644 --- a/package-lock.json +++ b/package-lock.json @@ -227,15 +227,6 @@ "@babel/helper-plugin-utils": "^7.0.0" } }, - "@babel/runtime": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.0.0.tgz", - "integrity": "sha512-7hGhzlcmg01CvH1EHdSPVXYX1aJ8KCEyz6I9xYIi/asDtzBPMyMhVibhM/K6g/5qnKBwjZtp10bNZIEFTRW1MA==", - "dev": true, - "requires": { - "regenerator-runtime": "^0.12.0" - } - }, "@babel/template": { "version": "7.2.2", "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.2.2.tgz", @@ -3059,12 +3050,6 @@ "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-12.0.9.tgz", "integrity": "sha512-sCZy4SxP9rN2w30Hlmg5dtdRwgYQfYRiLo9usw8X9cxlf+H4FqM1xX7+sNH7NNKVdbXMJWqva7iyy+fxh/V7fA==" }, - "@types/yup": { - "version": "0.26.22", - "resolved": "https://registry.npmjs.org/@types/yup/-/yup-0.26.22.tgz", - "integrity": "sha512-AhUPifCc7j2BEfp+wye3Mj7v3mMhbtu5BbO7n0zpwC/NVSETc8+MHENRmoxjE8wLC8AmFr5+uEhg5cvqusaRFQ==", - "dev": true - }, "@wry/equality": { "version": "0.1.9", "resolved": "https://registry.npmjs.org/@wry/equality/-/equality-0.1.9.tgz", @@ -6258,12 +6243,6 @@ } } }, - "fn-name": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/fn-name/-/fn-name-2.0.1.tgz", - "integrity": "sha1-UhTXU3pNBqSjAcDMJi/rhBiAAuc=", - "dev": true - }, "for-in": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", @@ -12518,12 +12497,6 @@ "integrity": "sha1-AMLa7t2iDofjeCs0Stuhzd1q1wk=", "dev": true }, - "property-expr": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/property-expr/-/property-expr-1.5.1.tgz", - "integrity": "sha512-CGuc0VUTGthpJXL36ydB6jnbyOf/rAHFvmVrJlH+Rg0DqqLFQGAP6hIaxD/G0OAmBJPhXDHuEJigrp0e0wFV6g==", - "dev": true - }, "proto-list": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/proto-list/-/proto-list-1.2.4.tgz", @@ -12848,12 +12821,6 @@ "redis-errors": "^1.0.0" } }, - "regenerator-runtime": { - "version": "0.12.1", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.12.1.tgz", - "integrity": "sha512-odxIc1/vDlo4iZcfXqRYFj0vpXFNoGdKMAUieAlFYO6m/nl5e9KR/beGf41z4a1FI+aQgtjhuaSlDxQ0hmkrHg==", - "dev": true - }, "regex-not": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", @@ -13850,12 +13817,6 @@ "integrity": "sha1-rifbOPZgp64uHDt9G8KQgZuFGeY=", "dev": true }, - "synchronous-promise": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/synchronous-promise/-/synchronous-promise-2.0.6.tgz", - "integrity": "sha512-TyOuWLwkmtPL49LHCX1caIwHjRzcVd62+GF6h8W/jHOeZUFHpnd2XJDVuUlaTaLPH1nuu2M69mfHr5XbQJnf/g==", - "dev": true - }, "tar": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/tar/-/tar-2.2.2.tgz", @@ -14050,12 +14011,6 @@ "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==" }, - "toposort": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/toposort/-/toposort-2.0.2.tgz", - "integrity": "sha1-riF2gXXRVZ1IvvNUILL0li8JwzA=", - "dev": true - }, "tough-cookie": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", @@ -14737,20 +14692,6 @@ "resolved": "https://registry.npmjs.org/ylru/-/ylru-1.2.1.tgz", "integrity": "sha512-faQrqNMzcPCHGVC2aaOINk13K+aaBDUPjGWl0teOXywElLjyVAB6Oe2jj62jHYtwsU49jXhScYbvPENK+6zAvQ==" }, - "yup": { - "version": "0.27.0", - "resolved": "https://registry.npmjs.org/yup/-/yup-0.27.0.tgz", - "integrity": "sha512-v1yFnE4+u9za42gG/b/081E7uNW9mUj3qtkmelLbW5YPROZzSH/KUUyJu9Wt8vxFJcT9otL/eZopS0YK1L5yPQ==", - "dev": true, - "requires": { - "@babel/runtime": "^7.0.0", - "fn-name": "~2.0.1", - "lodash": "^4.17.11", - "property-expr": "^1.5.0", - "synchronous-promise": "^2.0.6", - "toposort": "^2.0.2" - } - }, "zen-observable": { "version": "0.8.14", "resolved": "https://registry.npmjs.org/zen-observable/-/zen-observable-0.8.14.tgz", diff --git a/package.json b/package.json index a941f4f8d08..d71bdb0a2ce 100644 --- a/package.json +++ b/package.json @@ -96,7 +96,6 @@ "@types/test-listen": "1.1.0", "@types/type-is": "1.6.2", "@types/ws": "6.0.1", - "@types/yup": "0.26.22", "apollo-fetch": "0.7.0", "apollo-link": "1.2.12", "apollo-link-http": "1.5.15", @@ -139,8 +138,7 @@ "ts-jest": "24.0.2", "tslint": "5.18.0", "typescript": "3.5.3", - "ws": "6.2.1", - "yup": "0.27.0" + "ws": "6.2.1" }, "jest": { "projects": [ diff --git a/packages/apollo-server-integration-testsuite/src/ApolloServer.ts b/packages/apollo-server-integration-testsuite/src/ApolloServer.ts index 92caa5da53a..34eb3f1a3c3 100644 --- a/packages/apollo-server-integration-testsuite/src/ApolloServer.ts +++ b/packages/apollo-server-integration-testsuite/src/ApolloServer.ts @@ -609,15 +609,49 @@ export function testApolloServer( }); it('works with errors similar to GraphQL errors, such as yup', async () => { + // https://npm.im/yup is a package that produces a particular type of + // error that we test compatibility with. This test was first brought + // with https://github.com/apollographql/apollo-server/pull/1288. We + // used to use the actual `yup` package to generate the error, but we + // don't need to actually bundle that dependency just to test + // compatibility with that particular error shape. To be honest, it's + // not clear from the original PR which attribute of this error need be + // mocked, but for the sake not not breaking anything, all of yup's + // error properties have been reproduced here. const throwError = jest.fn(async () => { - const schema = yup.object().shape({ - email: yup - .string() - .email() - .required('Please enter your email address'), + // Intentionally `any` because this is a custom Error class with + // various custom properties (like `value` and `params`). + const yuppieError: any = new Error('email must be a valid email'); + yuppieError.name = 'ValidationError'; + + // Set `message` to enumerable, which `yup` does and `Error` doesn't. + Object.defineProperty(yuppieError, 'message', { + enumerable: true, }); - await schema.validate({ email: 'lol' }); + // Set other properties which `yup` sets. + yuppieError.path = 'email'; + yuppieError.type = undefined; + yuppieError.value = { email: 'invalid-email' }; + yuppieError.errors = ['email must be a valid email']; + yuppieError.inner = []; + yuppieError.params = { + path: 'email', + value: 'invalid-email', + originalValue: 'invalid-email', + label: undefined, + regex: /@/, + }; + + // This stack is fake, but roughly what `yup` generates! + yuppieError.stack = [ + 'ValidationError: email must be a valid email', + ' at createError (yup/lib/util/createValidation.js:64:35)', + ' at yup/lib/util/createValidation.js:113:108', + ' at process._tickCallback (internal/process/next_tick.js:68:7)', + ].join('\n'); + + throw yuppieError; }); const formatError = jest.fn(error => {