diff --git a/package-lock.json b/package-lock.json index 5e36c7fe8e8..787691252ba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -86,6 +86,44 @@ "xss": "^1.0.6" } }, + "@apollographql/graphql-upload-8-fork": { + "version": "8.1.3", + "resolved": "https://registry.npmjs.org/@apollographql/graphql-upload-8-fork/-/graphql-upload-8-fork-8.1.3.tgz", + "integrity": "sha512-ssOPUT7euLqDXcdVv3Qs4LoL4BPtfermW1IOouaqEmj36TpHYDmYDIbKoSQxikd9vtMumFnP87OybH7sC9fJ6g==", + "requires": { + "@types/express": "*", + "@types/fs-capacitor": "*", + "@types/koa": "*", + "busboy": "^0.3.1", + "fs-capacitor": "^2.0.4", + "http-errors": "^1.7.3", + "object-path": "^0.11.4" + }, + "dependencies": { + "http-errors": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.8.0.tgz", + "integrity": "sha512-4I8r0C5JDhT5VkvI47QktDW75rNlGVsUf/8hzjCC/wkWI/jdTRmBb9aI7erSG82r1bjKY3F6k28WnsVxB1C73A==", + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.4", + "setprototypeof": "1.2.0", + "statuses": ">= 1.5.0 < 2", + "toidentifier": "1.0.0" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" + } + } + }, "@babel/code-frame": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0.tgz", @@ -4602,17 +4640,6 @@ "@types/node": "*" } }, - "@types/graphql-upload": { - "version": "8.0.3", - "resolved": "https://registry.npmjs.org/@types/graphql-upload/-/graphql-upload-8.0.3.tgz", - "integrity": "sha512-hmLg9pCU/GmxBscg8GCr1vmSoEmbItNNxdD5YH2TJkXm//8atjwuprB+xJBK714JG1dkxbbhp5RHX+Pz1KsCMA==", - "requires": { - "@types/express": "*", - "@types/fs-capacitor": "*", - "@types/koa": "*", - "graphql": "^14.5.3" - } - }, "@types/hapi": { "version": "17.8.10", "resolved": "https://registry.npmjs.org/@types/hapi/-/hapi-17.8.10.tgz", @@ -5560,7 +5587,7 @@ "requires": { "@apollographql/apollo-tools": "^0.4.3", "@apollographql/graphql-playground-html": "1.6.26", - "@types/graphql-upload": "^8.0.0", + "@apollographql/graphql-upload-8-fork": "^8.1.3", "@types/ws": "^7.0.0", "apollo-cache-control": "file:packages/apollo-cache-control", "apollo-datasource": "file:packages/apollo-datasource", @@ -5577,7 +5604,6 @@ "graphql-extensions": "file:packages/graphql-extensions", "graphql-tag": "^2.11.0", "graphql-tools": "^4.0.0", - "graphql-upload": "^8.0.2", "loglevel": "^1.6.7", "lru-cache": "^6.0.0", "sha.js": "^2.4.11", @@ -10114,6 +10140,7 @@ "version": "14.7.0", "resolved": "https://registry.npmjs.org/graphql/-/graphql-14.7.0.tgz", "integrity": "sha512-l0xWZpoPKpppFzMfvVyFmp9vLN7w/ZZJPefUicMCepfJeQ8sMcztloGYY9DfjVPo6tIUDzU5Hw3MUbIjj9AVVA==", + "dev": true, "requires": { "iterall": "^1.2.2" } @@ -10158,17 +10185,6 @@ "uuid": "^3.1.0" } }, - "graphql-upload": { - "version": "8.0.7", - "resolved": "https://registry.npmjs.org/graphql-upload/-/graphql-upload-8.0.7.tgz", - "integrity": "sha512-gi2yygbDPXbHPC7H0PNPqP++VKSoNoJO4UrXWq4T0Bi4IhyUd3Ycop/FSxhx2svWIK3jdXR/i0vi91yR1aAF0g==", - "requires": { - "busboy": "^0.3.1", - "fs-capacitor": "^2.0.4", - "http-errors": "^1.7.2", - "object-path": "^0.11.4" - } - }, "growly": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz", @@ -18154,9 +18170,9 @@ "integrity": "sha512-6OO5X1+2tYkNyNEx6TsCxEqFfRWaqx6EtMiSbGrw8Ob8v9Ne+Hl8rBAgLBZn5wjEz3s/s6U1WXFUFOcxxAwUpg==" }, "object-path": { - "version": "0.11.4", - "resolved": "https://registry.npmjs.org/object-path/-/object-path-0.11.4.tgz", - "integrity": "sha1-NwrnUvvzfePqcKhhwju6iRVpGUk=" + "version": "0.11.5", + "resolved": "https://registry.npmjs.org/object-path/-/object-path-0.11.5.tgz", + "integrity": "sha512-jgSbThcoR/s+XumvGMTMf81QVBmah+/Q7K7YduKeKVWL7N111unR2d6pZZarSk6kY/caeNxUDyxOvMWyzoU2eg==" }, "object-visit": { "version": "1.0.1", diff --git a/package.json b/package.json index b0aa1848876..cb741f1b95d 100644 --- a/package.json +++ b/package.json @@ -55,6 +55,7 @@ "graphql-extensions": "file:packages/graphql-extensions" }, "devDependencies": { + "@apollographql/graphql-upload-8-fork": "^8.1.3", "@types/async-retry": "1.4.2", "@types/aws-lambda": "8.10.66", "@types/body-parser": "1.19.0", diff --git a/packages/apollo-server-core/package.json b/packages/apollo-server-core/package.json index c154b260746..cea32631e3b 100644 --- a/packages/apollo-server-core/package.json +++ b/packages/apollo-server-core/package.json @@ -27,7 +27,7 @@ "dependencies": { "@apollographql/apollo-tools": "^0.4.3", "@apollographql/graphql-playground-html": "1.6.26", - "@types/graphql-upload": "^8.0.0", + "@apollographql/graphql-upload-8-fork": "^8.1.3", "@types/ws": "^7.0.0", "apollo-cache-control": "file:../apollo-cache-control", "apollo-datasource": "file:../apollo-datasource", @@ -44,7 +44,6 @@ "graphql-extensions": "file:../graphql-extensions", "graphql-tag": "^2.11.0", "graphql-tools": "^4.0.0", - "graphql-upload": "^8.0.2", "loglevel": "^1.6.7", "lru-cache": "^6.0.0", "sha.js": "^2.4.11", diff --git a/packages/apollo-server-core/src/ApolloServer.ts b/packages/apollo-server-core/src/ApolloServer.ts index c599a3b9e47..b9aec5fd2d0 100644 --- a/packages/apollo-server-core/src/ApolloServer.ts +++ b/packages/apollo-server-core/src/ApolloServer.ts @@ -471,7 +471,7 @@ export class ApolloServerBase { } if (this.uploadsConfig) { - const { GraphQLUpload } = require('graphql-upload'); + const { GraphQLUpload } = require('@apollographql/graphql-upload-8-fork'); if (Array.isArray(resolvers)) { if (resolvers.every(resolver => !resolver.Upload)) { resolvers.push({ Upload: GraphQLUpload }); diff --git a/packages/apollo-server-core/src/index.ts b/packages/apollo-server-core/src/index.ts index 1afc60b763e..111c40c608c 100644 --- a/packages/apollo-server-core/src/index.ts +++ b/packages/apollo-server-core/src/index.ts @@ -46,16 +46,17 @@ import runtimeSupportsUploads from './utils/runtimeSupportsUploads'; import { GraphQLScalarType } from 'graphql'; export { default as processFileUploads } from './processFileUploads'; -// This is a conditional export intended to avoid traversing the -// entire module tree of `graphql-upload`. This only defined if the -// version of Node.js is >= 8.5.0 since those are the only Node.js versions -// which are supported by `graphql-upload@8`. Since the source of -// `graphql-upload` is not transpiled for older targets (in fact, it includes -// experimental ECMAScript modules), this conditional export is necessary -// to avoid modern ECMAScript from failing to parse by versions of Node.js -// which don't support it (yet — eg. Node.js 6 and async/await). +// This is a conditional export intended to avoid traversing the entire module +// tree of `graphql-upload` (or specifically, our fork of it). This only +// defined if the version of Node.js is >= 8.5.0 since those are the only +// Node.js versions which are supported by `graphql-upload@8`. Since the source +// of `graphql-upload` is not transpiled for older targets (in fact, it includes +// experimental ECMAScript modules), this conditional export is necessary to +// avoid modern ECMAScript from failing to parse by versions of Node.js which +// don't support it (yet — eg. Node.js 6 and async/await). export const GraphQLUpload = runtimeSupportsUploads - ? (require('graphql-upload').GraphQLUpload as GraphQLScalarType) + ? (require('@apollographql/graphql-upload-8-fork') + .GraphQLUpload as GraphQLScalarType) : undefined; export * from './plugin'; diff --git a/packages/apollo-server-core/src/processFileUploads.ts b/packages/apollo-server-core/src/processFileUploads.ts index 22ffb483e6d..7e402c394c3 100644 --- a/packages/apollo-server-core/src/processFileUploads.ts +++ b/packages/apollo-server-core/src/processFileUploads.ts @@ -4,11 +4,11 @@ import runtimeSupportsUploads from './utils/runtimeSupportsUploads'; // change during runtime. In the event that we're using a version of Node.js // less than 8.5.0, we'll const processFileUploads: - | typeof import('graphql-upload').processRequest + | typeof import('@apollographql/graphql-upload-8-fork').processRequest | undefined = (() => { if (runtimeSupportsUploads) { - return require('graphql-upload') - .processRequest as typeof import('graphql-upload').processRequest; + return require('@apollographql/graphql-upload-8-fork') + .processRequest as typeof import('@apollographql/graphql-upload-8-fork').processRequest; } return undefined; })(); diff --git a/packages/apollo-server-core/src/types.ts b/packages/apollo-server-core/src/types.ts index ec0385c99da..bd1bddd9803 100644 --- a/packages/apollo-server-core/src/types.ts +++ b/packages/apollo-server-core/src/types.ts @@ -131,7 +131,7 @@ export interface Config extends BaseConfig { engine?: boolean | EngineReportingOptions; } -// Configuration for how Apollo Server talks to the Apollo registry. +// Configuration for the built-in graphql-upload integration. export interface FileUploadOptions { //Max allowed non-file multipart form field size in bytes; enough for your queries (default: 1 MB). maxFieldSize?: number; diff --git a/packages/apollo-server-fastify/src/ApolloServer.ts b/packages/apollo-server-fastify/src/ApolloServer.ts index 9e8db6d2465..42bc458b229 100644 --- a/packages/apollo-server-fastify/src/ApolloServer.ts +++ b/packages/apollo-server-fastify/src/ApolloServer.ts @@ -11,7 +11,7 @@ import { import { FastifyInstance, FastifyReply, FastifyRequest } from 'fastify'; import { IncomingMessage, OutgoingMessage, ServerResponse, Server } from 'http'; import { graphqlFastify } from './fastifyApollo'; -import { GraphQLOperation } from 'graphql-upload'; +import type { GraphQLOperation } from '@apollographql/graphql-upload-8-fork'; const kMultipart = Symbol('multipart'); const fastJson = require('fast-json-stringify');