Merge branch 'release-vNEXT'

This commit is contained in:
Jesse Rosenberger 2018-12-13 15:26:32 +02:00
commit ad42402954
No known key found for this signature in database
GPG key ID: C0CCCF81AA6C08D8
40 changed files with 327 additions and 196 deletions

View file

@ -1,6 +1,16 @@
# Changelog # Changelog
### vNEXT ### v2.3.0-alpha
- **BREAKING FOR NODE.JS <= 8.5.0 ONLY**: To continue using Apollo Server 2.x in versions of Node.js prior to v8.5.0, file uploads must be disabled by setting `uploads: false` on the `ApolloServer` constructor options. Without explicitly disabling file-uploads, the server will `throw` at launch (with instructions and a link to our documentation).
This early deprecation is due to changes in the third-party `graphql-upload` package which Apollo Server utilizes to implement out-of-the-box file upload functionality. While, in general, Apollo Server 2.x aims to support all Node.js versions which were under an LTS policy at the time of its release, we felt this required an exception. By `throw`-ing when `uploads` is not explicitly set to `false`, we aim to make it clear immediately (rather than surprisingly) that this deprecation has taken effect.
While Node.js 6.x is covered by a [Long Term Support agreement by the Node.js Foundation](https://github.com/nodejs/Release#release-schedule) until April 2019, there are substantial performance (e.g. [V8](https://v8.dev/) improvements) and language changes (e.g. "modern" ECMAScript support) offered by newer Node.js engines (e.g. 8.x, 10.x). We encourage _all users_ of Apollo Server to update to newer LTS versions of Node.js prior to the "end-of-life" dates for their current server version.
**We intend to drop support for Node.js 6.x in the next major version of Apollo Server.**
### v2.2.7-beta.0
### v2.2.7 ### v2.2.7

View file

@ -44,6 +44,7 @@ sidebar_categories:
Migration: Migration:
- migration-two-dot - migration-two-dot
- migration-engine - migration-engine
- migration-file-uploads
github_repo: apollographql/apollo-server github_repo: apollographql/apollo-server
content_root: docs/source content_root: docs/source

View file

@ -0,0 +1,29 @@
---
title: File uploads in Node.js < v8.5.0
---
File uploads are supported in Apollo Server 2.x through the third-party [`graphql-upload`](https://npm.im/graphql-upload/) package. While Apollo Server 2.x aims to support Node.js LTS versions prior to v8.5.0, the `graphql-upload` project no longer supports file uploads on versions of Node.js prior to v8.5.0 due to changes in the underlying architecture.
While Node.js versions prior to v8.5.0 are still under [_Long Term Support_ (LTS) agreements](https://github.com/nodejs/Release#release-schedule) from the Node.js Foundation, **we encourage _all users_ of Apollo Server to update to newer LTS versions of Node.js** prior to the "end-of-life" dates for their current server version.
For example, while Node.js 6.x is covered by Long Term Support until April 2019, there are substantial performance (e.g. [V8](https://v8.dev/) improvements) and language changes (e.g. "modern" ECMAScript support) offered by newer Node.js engines (e.g. 8.x, 10.x). Switching to newer Long Term Support versions of Node.js comes with long-term benefits; Node.js 10.x LTS releases are covered by the Node.js Foundation through April 2021.
Since file upload support for Node.js versions prior to v8.5.0 is no longer offered by `graphql-upload`, users of those versions must disable file uploads to continue using newer Apollo Server 2.x versions.
**To disable file uploads and continue using Apollo Server 2.x on Node.js 6.x**, add the `uploads: false` setting to the options when constructing the server. For example:
```js
const { typeDefs, resolvers } = require('./anOutsideDependency');
const server = new ApolloServer({
/* Existing Apollo Server settings — e.g. type definitions */
typeDefs,
resolvers,
/* Add this line to disable upload support! */
uploads: false,
/* ... other Apollo Server settings ... */
})
```
For additional assistance, please [search for existing issues](https://github.com/apollographql/apollo-server/issues?q=uploads) or file a [new issue](https://github.com/apollographql/apollo-server/issues/new) on the Apollo Server GitHub repository.

View file

@ -246,7 +246,7 @@ const resolvers = {
Mutation: { Mutation: {
singleUpload: (parent, args) => { singleUpload: (parent, args) => {
return args.file.then(file => { return args.file.then(file => {
//Contents of Upload scalar: https://github.com/jaydenseric/apollo-upload-server#upload-scalar //Contents of Upload scalar: https://github.com/jaydenseric/graphql-upload#class-graphqlupload
//file.stream is a node stream that contains the contents of the uploaded file //file.stream is a node stream that contains the contents of the uploaded file
//node stream api: https://nodejs.org/api/stream.html //node stream api: https://nodejs.org/api/stream.html
return file; return file;

131
package-lock.json generated
View file

@ -4,21 +4,27 @@
"lockfileVersion": 1, "lockfileVersion": 1,
"dependencies": { "dependencies": {
"@apollographql/apollo-tools": { "@apollographql/apollo-tools": {
"version": "0.2.6", "version": "0.2.8",
"resolved": "https://registry.npmjs.org/@apollographql/apollo-tools/-/apollo-tools-0.2.6.tgz", "resolved": "https://registry.npmjs.org/@apollographql/apollo-tools/-/apollo-tools-0.2.8.tgz",
"integrity": "sha512-IKn35EzAHFQw4x8THux+fkVLkFNs8HDzIgKqcU5ZMfkDt3MOa1nfMbGVoVh2YdvpIjPtyUR3kvAAVQwmRPRjAQ==", "integrity": "sha512-A7FTUigtpGCFBaLT1ILicdjM6pZ7LQNw7Vgos0t4aLYtvlKO/L1nMi/NO7bPypzZaJSToTgcxHJPRydP1Md+Kw==",
"requires": { "requires": {
"apollo-env": "0.2.3" "apollo-env": "0.2.5"
} },
}, "dependencies": {
"@apollographql/apollo-upload-server": { "apollo-env": {
"version": "5.0.3", "version": "0.2.5",
"resolved": "https://registry.npmjs.org/@apollographql/apollo-upload-server/-/apollo-upload-server-5.0.3.tgz", "resolved": "https://registry.npmjs.org/apollo-env/-/apollo-env-0.2.5.tgz",
"integrity": "sha512-tGAp3ULNyoA8b5o9LsU2Lq6SwgVPUOKAqKywu2liEtTvrFSGPrObwanhYwArq3GPeOqp2bi+JknSJCIU3oQN1Q==", "integrity": "sha512-Gc7TEbwCl7jJVutnn8TWfzNSkrrqyoo0DP92BQJFU9pZbJhpidoXf2Sw1YwOJl82rRKH3ujM3C8vdZLOgpFcFA==",
"requires": { "requires": {
"@babel/runtime-corejs2": "^7.0.0-rc.1", "core-js": "^3.0.0-beta.3",
"busboy": "^0.2.14", "node-fetch": "^2.2.0"
"object-path": "^0.11.4" }
},
"core-js": {
"version": "3.0.0-beta.3",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.0.0-beta.3.tgz",
"integrity": "sha512-kM/OfrnMThP5PwGAj5HhQLdjUqzjrllqN2EVnk/X9qrLsfYjR2hzZ+E/8CzH0xuosexZtqMTLQrk//BULrBj9w=="
}
} }
}, },
"@apollographql/graphql-playground-html": { "@apollographql/graphql-playground-html": {
@ -63,15 +69,6 @@
"regenerator-runtime": "^0.12.0" "regenerator-runtime": "^0.12.0"
} }
}, },
"@babel/runtime-corejs2": {
"version": "7.1.2",
"resolved": "https://registry.npmjs.org/@babel/runtime-corejs2/-/runtime-corejs2-7.1.2.tgz",
"integrity": "sha512-drxaPByExlcRDKW4ZLubUO4ZkI8/8ax9k9wve1aEthdLKFzjB7XRkOQ0xoTIWGxqdDnWDElkjYq77bt7yrcYJQ==",
"requires": {
"core-js": "^2.5.7",
"regenerator-runtime": "^0.12.0"
}
},
"@iamstarkov/listr-update-renderer": { "@iamstarkov/listr-update-renderer": {
"version": "0.4.1", "version": "0.4.1",
"resolved": "https://registry.npmjs.org/@iamstarkov/listr-update-renderer/-/listr-update-renderer-0.4.1.tgz", "resolved": "https://registry.npmjs.org/@iamstarkov/listr-update-renderer/-/listr-update-renderer-0.4.1.tgz",
@ -2034,22 +2031,6 @@
"protobufjs": "^6.8.6" "protobufjs": "^6.8.6"
} }
}, },
"apollo-env": {
"version": "0.2.3",
"resolved": "https://registry.npmjs.org/apollo-env/-/apollo-env-0.2.3.tgz",
"integrity": "sha512-7hRWPG8tWQNXCNrZsOMqxtkHGqhTzFgsw7RpFDyC1xgcZvVFCJvthWgWO07EhcaHhRqvrPxmicLnoTw2e/iCsA==",
"requires": {
"core-js": "^3.0.0-beta.3",
"node-fetch": "^2.2.0"
},
"dependencies": {
"core-js": {
"version": "3.0.0-beta.3",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.0.0-beta.3.tgz",
"integrity": "sha512-kM/OfrnMThP5PwGAj5HhQLdjUqzjrllqN2EVnk/X9qrLsfYjR2hzZ+E/8CzH0xuosexZtqMTLQrk//BULrBj9w=="
}
}
},
"apollo-fetch": { "apollo-fetch": {
"version": "0.7.0", "version": "0.7.0",
"resolved": "https://registry.npmjs.org/apollo-fetch/-/apollo-fetch-0.7.0.tgz", "resolved": "https://registry.npmjs.org/apollo-fetch/-/apollo-fetch-0.7.0.tgz",
@ -2172,7 +2153,6 @@
"version": "file:packages/apollo-server-core", "version": "file:packages/apollo-server-core",
"requires": { "requires": {
"@apollographql/apollo-tools": "^0.2.6", "@apollographql/apollo-tools": "^0.2.6",
"@apollographql/apollo-upload-server": "^5.0.3",
"@apollographql/graphql-playground-html": "^1.6.6", "@apollographql/graphql-playground-html": "^1.6.6",
"@types/ws": "^6.0.0", "@types/ws": "^6.0.0",
"apollo-cache-control": "file:packages/apollo-cache-control", "apollo-cache-control": "file:packages/apollo-cache-control",
@ -2187,6 +2167,7 @@
"graphql-subscriptions": "^1.0.0", "graphql-subscriptions": "^1.0.0",
"graphql-tag": "^2.9.2", "graphql-tag": "^2.9.2",
"graphql-tools": "^4.0.0", "graphql-tools": "^4.0.0",
"graphql-upload": "^8.0.2",
"json-stable-stringify": "^1.0.1", "json-stable-stringify": "^1.0.1",
"lodash": "^4.17.10", "lodash": "^4.17.10",
"subscriptions-transport-ws": "^0.9.11", "subscriptions-transport-ws": "^0.9.11",
@ -2206,7 +2187,6 @@
"apollo-server-express": { "apollo-server-express": {
"version": "file:packages/apollo-server-express", "version": "file:packages/apollo-server-express",
"requires": { "requires": {
"@apollographql/apollo-upload-server": "^5.0.3",
"@apollographql/graphql-playground-html": "^1.6.6", "@apollographql/graphql-playground-html": "^1.6.6",
"@types/accepts": "^1.3.5", "@types/accepts": "^1.3.5",
"@types/body-parser": "1.17.0", "@types/body-parser": "1.17.0",
@ -2219,30 +2199,17 @@
"graphql-subscriptions": "^1.0.0", "graphql-subscriptions": "^1.0.0",
"graphql-tools": "^4.0.0", "graphql-tools": "^4.0.0",
"type-is": "^1.6.16" "type-is": "^1.6.16"
},
"dependencies": {
"@apollographql/graphql-playground-html": {
"version": "1.6.6",
"bundled": true
}
} }
}, },
"apollo-server-hapi": { "apollo-server-hapi": {
"version": "file:packages/apollo-server-hapi", "version": "file:packages/apollo-server-hapi",
"requires": { "requires": {
"@apollographql/apollo-upload-server": "^5.0.3",
"@apollographql/graphql-playground-html": "^1.6.6", "@apollographql/graphql-playground-html": "^1.6.6",
"accept": "^3.0.2", "accept": "^3.0.2",
"apollo-server-core": "file:packages/apollo-server-core", "apollo-server-core": "file:packages/apollo-server-core",
"boom": "^7.1.0", "boom": "^7.1.0",
"graphql-subscriptions": "^1.0.0", "graphql-subscriptions": "^1.0.0",
"graphql-tools": "^4.0.0" "graphql-tools": "^4.0.0"
},
"dependencies": {
"@apollographql/graphql-playground-html": {
"version": "1.6.6",
"bundled": true
}
} }
}, },
"apollo-server-integration-testsuite": { "apollo-server-integration-testsuite": {
@ -2254,7 +2221,6 @@
"apollo-server-koa": { "apollo-server-koa": {
"version": "file:packages/apollo-server-koa", "version": "file:packages/apollo-server-koa",
"requires": { "requires": {
"@apollographql/apollo-upload-server": "^5.0.3",
"@apollographql/graphql-playground-html": "^1.6.6", "@apollographql/graphql-playground-html": "^1.6.6",
"@koa/cors": "^2.2.1", "@koa/cors": "^2.2.1",
"@types/accepts": "^1.3.5", "@types/accepts": "^1.3.5",
@ -2271,12 +2237,6 @@
"koa-bodyparser": "^3.0.0", "koa-bodyparser": "^3.0.0",
"koa-router": "^7.4.0", "koa-router": "^7.4.0",
"type-is": "^1.6.16" "type-is": "^1.6.16"
},
"dependencies": {
"@apollographql/graphql-playground-html": {
"version": "1.6.6",
"bundled": true
}
} }
}, },
"apollo-server-lambda": { "apollo-server-lambda": {
@ -2286,28 +2246,15 @@
"apollo-server-core": "file:packages/apollo-server-core", "apollo-server-core": "file:packages/apollo-server-core",
"apollo-server-env": "file:packages/apollo-server-env", "apollo-server-env": "file:packages/apollo-server-env",
"graphql-tools": "^4.0.0" "graphql-tools": "^4.0.0"
},
"dependencies": {
"@apollographql/graphql-playground-html": {
"version": "1.6.6",
"bundled": true
}
} }
}, },
"apollo-server-micro": { "apollo-server-micro": {
"version": "file:packages/apollo-server-micro", "version": "file:packages/apollo-server-micro",
"requires": { "requires": {
"@apollographql/apollo-upload-server": "^5.0.3",
"@apollographql/graphql-playground-html": "^1.6.6", "@apollographql/graphql-playground-html": "^1.6.6",
"accept": "^3.0.2", "accept": "^3.0.2",
"apollo-server-core": "file:packages/apollo-server-core", "apollo-server-core": "file:packages/apollo-server-core",
"micro": "^9.3.2" "micro": "^9.3.2"
},
"dependencies": {
"@apollographql/graphql-playground-html": {
"version": "1.6.6",
"bundled": true
}
} }
}, },
"apollo-server-plugin-base": { "apollo-server-plugin-base": {
@ -3857,7 +3804,8 @@
"core-js": { "core-js": {
"version": "2.5.7", "version": "2.5.7",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.7.tgz", "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.7.tgz",
"integrity": "sha512-RszJCAxg/PP6uzXVXL6BsxSXx/B05oJAQ2vkJRjyjrEcNVycaqOmNb5OTxZPE3xa5gwZduqza6L9JOCenh/Ecw==" "integrity": "sha512-RszJCAxg/PP6uzXVXL6BsxSXx/B05oJAQ2vkJRjyjrEcNVycaqOmNb5OTxZPE3xa5gwZduqza6L9JOCenh/Ecw==",
"dev": true
}, },
"core-util-is": { "core-util-is": {
"version": "1.0.2", "version": "1.0.2",
@ -5309,6 +5257,11 @@
} }
} }
}, },
"fs-capacitor": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/fs-capacitor/-/fs-capacitor-1.0.1.tgz",
"integrity": "sha512-XdZK0Q78WP29Vm3FGgJRhRhrBm51PagovzWtW2kJ3Q6cYJbGtZqWSGTSPwvtEkyjIirFd7b8Yes/dpOYjt4RRQ=="
},
"fs-extra": { "fs-extra": {
"version": "7.0.1", "version": "7.0.1",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz",
@ -6360,6 +6313,31 @@
"uuid": "^3.1.0" "uuid": "^3.1.0"
} }
}, },
"graphql-upload": {
"version": "8.0.2",
"resolved": "https://registry.npmjs.org/graphql-upload/-/graphql-upload-8.0.2.tgz",
"integrity": "sha512-u8a5tKPfJ0rU4MY+B3skabL8pEjMkm3tUzq25KBx6nT0yEWmqUO7Z5tdwvwYLFpkLwew94Gue0ARbZtar3gLTw==",
"requires": {
"busboy": "^0.2.14",
"fs-capacitor": "^1.0.0",
"http-errors": "^1.7.1",
"object-path": "^0.11.4"
},
"dependencies": {
"http-errors": {
"version": "1.7.1",
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.1.tgz",
"integrity": "sha512-jWEUgtZWGSMba9I1N3gc1HmvpBUaNC9vDdA46yScAdp+C5rdEuKWUBLWTQpW9FwSWSbYYs++b6SDCxf9UEJzfw==",
"requires": {
"depd": "~1.1.2",
"inherits": "2.0.3",
"setprototypeof": "1.1.0",
"statuses": ">= 1.5.0 < 2",
"toidentifier": "1.0.0"
}
}
}
},
"growly": { "growly": {
"version": "1.3.0", "version": "1.3.0",
"resolved": "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz", "resolved": "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz",
@ -11304,7 +11282,8 @@
"regenerator-runtime": { "regenerator-runtime": {
"version": "0.12.1", "version": "0.12.1",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.12.1.tgz", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.12.1.tgz",
"integrity": "sha512-odxIc1/vDlo4iZcfXqRYFj0vpXFNoGdKMAUieAlFYO6m/nl5e9KR/beGf41z4a1FI+aQgtjhuaSlDxQ0hmkrHg==" "integrity": "sha512-odxIc1/vDlo4iZcfXqRYFj0vpXFNoGdKMAUieAlFYO6m/nl5e9KR/beGf41z4a1FI+aQgtjhuaSlDxQ0hmkrHg==",
"dev": true
}, },
"regex-cache": { "regex-cache": {
"version": "0.4.4", "version": "0.4.4",

View file

@ -1,6 +1,6 @@
{ {
"name": "apollo-cache-control", "name": "apollo-cache-control",
"version": "0.3.4", "version": "0.4.0-alpha.0",
"description": "A GraphQL extension for cache control", "description": "A GraphQL extension for cache control",
"main": "./dist/index.js", "main": "./dist/index.js",
"types": "./dist/index.d.ts", "types": "./dist/index.d.ts",

View file

@ -1,6 +1,6 @@
{ {
"name": "apollo-engine-reporting-protobuf", "name": "apollo-engine-reporting-protobuf",
"version": "0.1.1", "version": "0.2.0-alpha.0",
"description": "Protobuf format for Apollo Engine", "description": "Protobuf format for Apollo Engine",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",

View file

@ -1,6 +1,6 @@
{ {
"name": "apollo-engine-reporting", "name": "apollo-engine-reporting",
"version": "0.1.4", "version": "0.2.0-alpha.0",
"description": "Send reports about your GraphQL services to Apollo Engine", "description": "Send reports about your GraphQL services to Apollo Engine",
"main": "./dist/index.js", "main": "./dist/index.js",
"types": "./dist/index.d.ts", "types": "./dist/index.d.ts",

View file

@ -1,6 +1,6 @@
{ {
"name": "apollo-server-azure-functions", "name": "apollo-server-azure-functions",
"version": "2.2.7", "version": "2.3.0-alpha.0",
"description": "Production-ready Node.js GraphQL server for Azure Functions", "description": "Production-ready Node.js GraphQL server for Azure Functions",
"keywords": [ "keywords": [
"GraphQL", "GraphQL",

View file

@ -1,6 +1,6 @@
{ {
"name": "apollo-server-cloud-functions", "name": "apollo-server-cloud-functions",
"version": "2.2.7", "version": "2.3.0-alpha.0",
"description": "Production-ready Node.js GraphQL server for Google Cloud Functions", "description": "Production-ready Node.js GraphQL server for Google Cloud Functions",
"keywords": [ "keywords": [
"GraphQL", "GraphQL",

View file

@ -1,6 +1,6 @@
{ {
"name": "apollo-server-cloudflare", "name": "apollo-server-cloudflare",
"version": "2.2.7", "version": "2.3.0-alpha.0",
"description": "Production-ready Node.js GraphQL server for Cloudflare workers", "description": "Production-ready Node.js GraphQL server for Cloudflare workers",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",

View file

@ -1,6 +1,6 @@
{ {
"name": "apollo-server-core", "name": "apollo-server-core",
"version": "2.2.7", "version": "2.3.0-alpha.0",
"description": "Core engine for Apollo GraphQL server", "description": "Core engine for Apollo GraphQL server",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",
@ -25,7 +25,6 @@
}, },
"dependencies": { "dependencies": {
"@apollographql/apollo-tools": "^0.2.6", "@apollographql/apollo-tools": "^0.2.6",
"@apollographql/apollo-upload-server": "^5.0.3",
"@apollographql/graphql-playground-html": "^1.6.6", "@apollographql/graphql-playground-html": "^1.6.6",
"@types/ws": "^6.0.0", "@types/ws": "^6.0.0",
"apollo-cache-control": "file:../apollo-cache-control", "apollo-cache-control": "file:../apollo-cache-control",
@ -40,6 +39,7 @@
"graphql-subscriptions": "^1.0.0", "graphql-subscriptions": "^1.0.0",
"graphql-tag": "^2.9.2", "graphql-tag": "^2.9.2",
"graphql-tools": "^4.0.0", "graphql-tools": "^4.0.0",
"graphql-upload": "^8.0.2",
"json-stable-stringify": "^1.0.1", "json-stable-stringify": "^1.0.1",
"lodash": "^4.17.10", "lodash": "^4.17.10",
"subscriptions-transport-ws": "^0.9.11", "subscriptions-transport-ws": "^0.9.11",

View file

@ -14,6 +14,7 @@ import { GraphQLExtension } from 'graphql-extensions';
import { EngineReportingAgent } from 'apollo-engine-reporting'; import { EngineReportingAgent } from 'apollo-engine-reporting';
import { InMemoryLRUCache } from 'apollo-server-caching'; import { InMemoryLRUCache } from 'apollo-server-caching';
import { ApolloServerPlugin } from 'apollo-server-plugin-base'; import { ApolloServerPlugin } from 'apollo-server-plugin-base';
import supportsUploadsInNode from './utils/supportsUploadsInNode';
import { import {
SubscriptionServer, SubscriptionServer,
@ -88,6 +89,9 @@ function getEngineServiceId(engine: Config['engine']): string | undefined {
return; return;
} }
const forbidUploadsForTesting =
process && process.env.NODE_ENV === 'test' && !supportsUploadsInNode;
export class ApolloServerBase { export class ApolloServerBase {
public subscriptionsPath?: string; public subscriptionsPath?: string;
public graphqlPath: string = '/graphql'; public graphqlPath: string = '/graphql';
@ -199,8 +203,16 @@ export class ApolloServerBase {
this.requestOptions = requestOptions as GraphQLOptions; this.requestOptions = requestOptions as GraphQLOptions;
this.context = context; this.context = context;
if (uploads !== false) { if (uploads !== false && !forbidUploadsForTesting) {
if (this.supportsUploads()) { if (this.supportsUploads()) {
if (!supportsUploadsInNode) {
printNodeFileUploadsMessage();
throw new Error(
'`graphql-upload` is no longer supported on Node.js < v8.5.0. ' +
'See https://bit.ly/gql-upload-node-6.',
);
}
if (uploads === true || typeof uploads === 'undefined') { if (uploads === true || typeof uploads === 'undefined') {
this.uploadsConfig = {}; this.uploadsConfig = {};
} else { } else {
@ -249,9 +261,7 @@ export class ApolloServerBase {
); );
if (this.uploadsConfig) { if (this.uploadsConfig) {
const { const { GraphQLUpload } = require('graphql-upload');
GraphQLUpload,
} = require('@apollographql/apollo-upload-server');
if (resolvers && !resolvers.Upload) { if (resolvers && !resolvers.Upload) {
resolvers.Upload = GraphQLUpload; resolvers.Upload = GraphQLUpload;
} }
@ -542,3 +552,32 @@ export class ApolloServerBase {
return processGraphQLRequest(options, requestCtx); return processGraphQLRequest(options, requestCtx);
} }
} }
function printNodeFileUploadsMessage() {
console.error(
[
'*****************************************************************',
'* *',
'* ERROR! Manual intervention is necessary for Node.js < v8.5.0! *',
'* *',
'*****************************************************************',
'',
'The third-party `graphql-upload` package, which is used to implement',
'file uploads in Apollo Server 2.x, no longer supports Node.js LTS',
'versions prior to Node.js v8.5.0.',
'',
'Deployments which NEED file upload capabilities should update to',
'Node.js >= v8.5.0 to continue using uploads.',
'',
'If this server DOES NOT NEED file uploads and wishes to continue',
'using this version of Node.js, uploads can be disabled by adding:',
'',
' uploads: false,',
'',
'...to the options for Apollo Server and re-deploying the server.',
'',
'For more information, see https://bit.ly/gql-upload-node-6.',
'',
].join('\n'),
);
}

View file

@ -41,6 +41,18 @@ export const gql: (
...substitutions: any[] ...substitutions: any[]
) => DocumentNode = gqlTag; ) => DocumentNode = gqlTag;
import supportsUploadsInNode from './utils/supportsUploadsInNode';
import { GraphQLScalarType } from 'graphql'; import { GraphQLScalarType } from 'graphql';
import { GraphQLUpload as UploadScalar } from '@apollographql/apollo-upload-server'; export { default as processFileUploads } from './processFileUploads';
export const GraphQLUpload = UploadScalar as GraphQLScalarType;
// 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).
export const GraphQLUpload = supportsUploadsInNode
? (require('graphql-upload').GraphQLUpload as GraphQLScalarType)
: undefined;

View file

@ -0,0 +1,16 @@
import supportsUploadsInNode from './utils/supportsUploadsInNode';
// We'll memoize this function once at module load time since it should never
// 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
| undefined = (() => {
if (supportsUploadsInNode) {
return require('graphql-upload')
.processRequest as typeof import('graphql-upload').processRequest;
}
return undefined;
})();
export default processFileUploads;

View file

@ -72,7 +72,7 @@ export interface Config
plugins?: PluginDefinition[]; plugins?: PluginDefinition[];
persistedQueries?: PersistedQueryOptions | false; persistedQueries?: PersistedQueryOptions | false;
subscriptions?: Partial<SubscriptionServerOptions> | string | false; subscriptions?: Partial<SubscriptionServerOptions> | string | false;
//https://github.com/jaydenseric/apollo-upload-server#options //https://github.com/jaydenseric/graphql-upload#type-uploadoptions
uploads?: boolean | FileUploadOptions; uploads?: boolean | FileUploadOptions;
playground?: PlaygroundConfig; playground?: PlaygroundConfig;
} }

View file

@ -0,0 +1,21 @@
const supportsUploadsInNode = (() => {
if (
process &&
process.release &&
process.release.name === 'node' &&
process.versions &&
typeof process.versions.node === 'string'
) {
const [nodeMajor, nodeMinor] = process.versions.node
.split('.', 2)
.map(segment => parseInt(segment, 10));
if (nodeMajor < 8 || (nodeMajor === 8 && nodeMinor < 5)) {
return false;
}
}
return true;
})();
export default supportsUploadsInNode;

View file

@ -1,6 +1,6 @@
{ {
"name": "apollo-server-express", "name": "apollo-server-express",
"version": "2.2.7", "version": "2.3.0-alpha.0",
"description": "Production-ready Node.js GraphQL server for Express and Connect", "description": "Production-ready Node.js GraphQL server for Express and Connect",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",
@ -26,7 +26,6 @@
"node": ">=6" "node": ">=6"
}, },
"dependencies": { "dependencies": {
"@apollographql/apollo-upload-server": "^5.0.3",
"@apollographql/graphql-playground-html": "^1.6.6", "@apollographql/graphql-playground-html": "^1.6.6",
"@types/accepts": "^1.3.5", "@types/accepts": "^1.3.5",
"@types/body-parser": "1.17.0", "@types/body-parser": "1.17.0",

View file

@ -10,14 +10,13 @@ import {
FileUploadOptions, FileUploadOptions,
ApolloServerBase, ApolloServerBase,
formatApolloErrors, formatApolloErrors,
processFileUploads,
} from 'apollo-server-core'; } from 'apollo-server-core';
import accepts from 'accepts'; import accepts from 'accepts';
import typeis from 'type-is'; import typeis from 'type-is';
import { graphqlExpress } from './expressApollo'; import { graphqlExpress } from './expressApollo';
import { processRequest as processFileUploads } from '@apollographql/apollo-upload-server';
export { GraphQLOptions, GraphQLExtension } from 'apollo-server-core'; export { GraphQLOptions, GraphQLExtension } from 'apollo-server-core';
export interface ServerRegistration { export interface ServerRegistration {
@ -44,8 +43,11 @@ const fileUploadMiddleware = (
next: express.NextFunction, next: express.NextFunction,
) => { ) => {
// Note: we use typeis directly instead of via req.is for connect support. // Note: we use typeis directly instead of via req.is for connect support.
if (typeis(req, ['multipart/form-data'])) { if (
processFileUploads(req, uploadsConfig) typeof processFileUploads === 'function' &&
typeis(req, ['multipart/form-data'])
) {
processFileUploads(req, res, uploadsConfig)
.then(body => { .then(body => {
req.body = body; req.body = body;
next(); next();
@ -134,7 +136,7 @@ export class ApolloServer extends ApolloServerBase {
} }
let uploadsMiddleware; let uploadsMiddleware;
if (this.uploadsConfig) { if (this.uploadsConfig && typeof processFileUploads === 'function') {
uploadsMiddleware = fileUploadMiddleware(this.uploadsConfig, this); uploadsMiddleware = fileUploadMiddleware(this.uploadsConfig, this);
} }

View file

@ -11,7 +11,7 @@ import { gql, AuthenticationError, Config } from 'apollo-server-core';
import { ApolloServer, ServerRegistration } from '../ApolloServer'; import { ApolloServer, ServerRegistration } from '../ApolloServer';
import { import {
atLeastMajorNodeVersion, NODE_MAJOR_VERSION,
testApolloServer, testApolloServer,
createServerInfo, createServerInfo,
} from 'apollo-server-integration-testsuite'; } from 'apollo-server-integration-testsuite';
@ -427,8 +427,9 @@ describe('apollo-server-express', () => {
}); });
}); });
}); });
// NODE: Intentionally skip file upload tests on Node.js 10 or higher. // NODE: Skip Node.js 6, but only because `graphql-upload`
(atLeastMajorNodeVersion(10) ? describe.skip : describe)( // doesn't support it.
(NODE_MAJOR_VERSION === 6 ? describe.skip : describe)(
'file uploads', 'file uploads',
() => { () => {
it('enabled uploads', async () => { it('enabled uploads', async () => {

View file

@ -1,6 +1,6 @@
{ {
"name": "apollo-server-hapi", "name": "apollo-server-hapi",
"version": "2.2.7", "version": "2.3.0-alpha.0",
"description": "Production-ready Node.js GraphQL server for Hapi", "description": "Production-ready Node.js GraphQL server for Hapi",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",
@ -25,7 +25,6 @@
"node": ">=8" "node": ">=8"
}, },
"dependencies": { "dependencies": {
"@apollographql/apollo-upload-server": "^5.0.3",
"@apollographql/graphql-playground-html": "^1.6.6", "@apollographql/graphql-playground-html": "^1.6.6",
"accept": "^3.0.2", "accept": "^3.0.2",
"apollo-server-core": "file:../apollo-server-core", "apollo-server-core": "file:../apollo-server-core",

View file

@ -4,7 +4,6 @@ import {
renderPlaygroundPage, renderPlaygroundPage,
RenderPageOptions as PlaygroundRenderPageOptions, RenderPageOptions as PlaygroundRenderPageOptions,
} from '@apollographql/graphql-playground-html'; } from '@apollographql/graphql-playground-html';
import { processRequest as processFileUploads } from '@apollographql/apollo-upload-server';
import { graphqlHapi } from './hapiApollo'; import { graphqlHapi } from './hapiApollo';
@ -13,13 +12,21 @@ import {
ApolloServerBase, ApolloServerBase,
GraphQLOptions, GraphQLOptions,
FileUploadOptions, FileUploadOptions,
processFileUploads,
} from 'apollo-server-core'; } from 'apollo-server-core';
function handleFileUploads(uploadsConfig: FileUploadOptions) { function handleFileUploads(uploadsConfig: FileUploadOptions) {
return async (request: hapi.Request) => { return async (request: hapi.Request, _h?: hapi.ResponseToolkit) => {
if (request.mime === 'multipart/form-data') { if (
typeof processFileUploads === 'function' &&
request.mime === 'multipart/form-data'
) {
Object.defineProperty(request, 'payload', { Object.defineProperty(request, 'payload', {
value: await processFileUploads(request, uploadsConfig), value: await processFileUploads(
request,
request.response,
uploadsConfig,
),
writable: false, writable: false,
}); });
} }
@ -64,7 +71,7 @@ export class ApolloServer extends ApolloServerBase {
return h.continue; return h.continue;
} }
if (this.uploadsConfig) { if (this.uploadsConfig && typeof processFileUploads === 'function') {
await handleFileUploads(this.uploadsConfig)(request); await handleFileUploads(this.uploadsConfig)(request);
} }

View file

@ -1,5 +1,5 @@
import { import {
atLeastMajorNodeVersion, NODE_MAJOR_VERSION,
testApolloServer, testApolloServer,
createServerInfo, createServerInfo,
} from 'apollo-server-integration-testsuite'; } from 'apollo-server-integration-testsuite';
@ -16,7 +16,7 @@ import { ApolloServer } from '../ApolloServer';
const port = 5555; const port = 5555;
// NODE: Intentionally skip for Node.js < 8 since Hapi 17 doesn't support those. // NODE: Intentionally skip for Node.js < 8 since Hapi 17 doesn't support those.
(atLeastMajorNodeVersion(8) ? describe : describe.skip)( (NODE_MAJOR_VERSION < 8 ? describe.skip : describe)(
'apollo-server-hapi', 'apollo-server-hapi',
() => { () => {
let server: ApolloServer; let server: ApolloServer;

View file

@ -4,40 +4,37 @@ import { Config } from 'apollo-server-core';
import testSuite, { import testSuite, {
schema as Schema, schema as Schema,
CreateAppOptions, CreateAppOptions,
atLeastMajorNodeVersion, NODE_MAJOR_VERSION,
} from 'apollo-server-integration-testsuite'; } from 'apollo-server-integration-testsuite';
// NODE: Intentionally skip on Node.js < 8 since Hapi 17 doesn't support less // NODE: Intentionally skip on Node.js < 8 since Hapi 17 doesn't support less
(atLeastMajorNodeVersion(8) ? describe : describe.skip)( (NODE_MAJOR_VERSION < 8 ? describe.skip : describe)('integration:Hapi', () => {
'integration:Hapi', async function createApp(options: CreateAppOptions = {}) {
() => { const { Server } = require('hapi');
async function createApp(options: CreateAppOptions = {}) {
const { Server } = require('hapi');
const app: import('hapi').Server = new Server({ const app: import('hapi').Server = new Server({
host: 'localhost', host: 'localhost',
port: 8000, port: 8000,
}); });
const server = new ApolloServer( const server = new ApolloServer(
(options.graphqlOptions as Config) || { schema: Schema }, (options.graphqlOptions as Config) || { schema: Schema },
); );
await server.applyMiddleware({ await server.applyMiddleware({
app, app,
}); });
await app.start(); await app.start();
return app.listener; return app.listener;
}
async function destroyApp(app) {
if (!app || !app.close) {
return;
} }
await new Promise(resolve => app.close(resolve));
}
async function destroyApp(app) { testSuite(createApp, destroyApp);
if (!app || !app.close) { });
return;
}
await new Promise(resolve => app.close(resolve));
}
testSuite(createApp, destroyApp);
},
);

View file

@ -1,7 +1,7 @@
{ {
"name": "apollo-server-integration-testsuite", "name": "apollo-server-integration-testsuite",
"private": true, "private": true,
"version": "2.2.7", "version": "2.3.0-alpha.0",
"description": "Apollo Server Integrations testsuite", "description": "Apollo Server Integrations testsuite",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",

View file

@ -23,13 +23,10 @@ import gql from 'graphql-tag';
export * from './ApolloServer'; export * from './ApolloServer';
const NODE_MAJOR_VERSION: number = parseInt( export const NODE_MAJOR_VERSION: number = parseInt(
process.versions.node.split('.', 1)[0], process.versions.node.split('.', 1)[0],
10, 10,
); );
export function atLeastMajorNodeVersion(desiredVersion: number): boolean {
return NODE_MAJOR_VERSION >= desiredVersion;
}
const QueryRootType = new GraphQLObjectType({ const QueryRootType = new GraphQLObjectType({
name: 'QueryRoot', name: 'QueryRoot',

View file

@ -1,6 +1,6 @@
{ {
"name": "apollo-server-koa", "name": "apollo-server-koa",
"version": "2.2.7", "version": "2.3.0-alpha.0",
"description": "Production-ready Node.js GraphQL server for Koa", "description": "Production-ready Node.js GraphQL server for Koa",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",
@ -25,7 +25,6 @@
"node": ">=6" "node": ">=6"
}, },
"dependencies": { "dependencies": {
"@apollographql/apollo-upload-server": "^5.0.3",
"@apollographql/graphql-playground-html": "^1.6.6", "@apollographql/graphql-playground-html": "^1.6.6",
"@koa/cors": "^2.2.1", "@koa/cors": "^2.2.1",
"@types/accepts": "^1.3.5", "@types/accepts": "^1.3.5",

View file

@ -6,14 +6,16 @@ import {
renderPlaygroundPage, renderPlaygroundPage,
RenderPageOptions as PlaygroundRenderPageOptions, RenderPageOptions as PlaygroundRenderPageOptions,
} from '@apollographql/graphql-playground-html'; } from '@apollographql/graphql-playground-html';
import { ApolloServerBase, formatApolloErrors } from 'apollo-server-core'; import {
ApolloServerBase,
formatApolloErrors,
processFileUploads,
} from 'apollo-server-core';
import accepts from 'accepts'; import accepts from 'accepts';
import typeis from 'type-is'; import typeis from 'type-is';
import { graphqlKoa } from './koaApollo'; import { graphqlKoa } from './koaApollo';
import { processRequest as processFileUploads } from '@apollographql/apollo-upload-server';
export { GraphQLOptions, GraphQLExtension } from 'apollo-server-core'; export { GraphQLOptions, GraphQLExtension } from 'apollo-server-core';
import { GraphQLOptions, FileUploadOptions } from 'apollo-server-core'; import { GraphQLOptions, FileUploadOptions } from 'apollo-server-core';
@ -32,7 +34,11 @@ const fileUploadMiddleware = (
) => async (ctx: Koa.Context, next: Function) => { ) => async (ctx: Koa.Context, next: Function) => {
if (typeis(ctx.req, ['multipart/form-data'])) { if (typeis(ctx.req, ['multipart/form-data'])) {
try { try {
ctx.request.body = await processFileUploads(ctx.req, uploadsConfig); ctx.request.body = await processFileUploads(
ctx.req,
ctx.res,
uploadsConfig,
);
return next(); return next();
} catch (error) { } catch (error) {
if (error.status && error.expose) ctx.status = error.status; if (error.status && error.expose) ctx.status = error.status;
@ -134,7 +140,7 @@ export class ApolloServer extends ApolloServerBase {
} }
let uploadsMiddleware; let uploadsMiddleware;
if (this.uploadsConfig) { if (this.uploadsConfig && typeof processFileUploads === 'function') {
uploadsMiddleware = fileUploadMiddleware(this.uploadsConfig, this); uploadsMiddleware = fileUploadMiddleware(this.uploadsConfig, this);
} }

View file

@ -11,7 +11,7 @@ import { gql, AuthenticationError, Config } from 'apollo-server-core';
import { ApolloServer, ServerRegistration } from '../ApolloServer'; import { ApolloServer, ServerRegistration } from '../ApolloServer';
import { import {
atLeastMajorNodeVersion, NODE_MAJOR_VERSION,
testApolloServer, testApolloServer,
createServerInfo, createServerInfo,
} from 'apollo-server-integration-testsuite'; } from 'apollo-server-integration-testsuite';
@ -323,8 +323,9 @@ describe('apollo-server-koa', () => {
}); });
}); });
}); });
// NODE: Intentionally skip file upload tests on Node.js 10 or higher. // NODE: Skip Node.js 6, but only because `graphql-upload`
(atLeastMajorNodeVersion(10) ? describe.skip : describe)( // doesn't support it anymore.
(NODE_MAJOR_VERSION === 6 ? describe.skip : describe)(
'file uploads', 'file uploads',
() => { () => {
it('enabled uploads', async () => { it('enabled uploads', async () => {

View file

@ -1,6 +1,6 @@
{ {
"name": "apollo-server-lambda", "name": "apollo-server-lambda",
"version": "2.2.7", "version": "2.3.0-alpha.0",
"description": "Production-ready Node.js GraphQL server for AWS Lambda", "description": "Production-ready Node.js GraphQL server for AWS Lambda",
"keywords": [ "keywords": [
"GraphQL", "GraphQL",

View file

@ -1,6 +1,6 @@
{ {
"name": "apollo-server-micro", "name": "apollo-server-micro",
"version": "2.2.7", "version": "2.3.0-alpha.0",
"description": "Production-ready Node.js GraphQL server for Micro", "description": "Production-ready Node.js GraphQL server for Micro",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",
@ -23,7 +23,6 @@
}, },
"homepage": "https://github.com/apollographql/apollo-server#readme", "homepage": "https://github.com/apollographql/apollo-server#readme",
"dependencies": { "dependencies": {
"@apollographql/apollo-upload-server": "^5.0.3",
"@apollographql/graphql-playground-html": "^1.6.6", "@apollographql/graphql-playground-html": "^1.6.6",
"accept": "^3.0.2", "accept": "^3.0.2",
"apollo-server-core": "file:../apollo-server-core", "apollo-server-core": "file:../apollo-server-core",

View file

@ -1,5 +1,8 @@
import { ApolloServerBase, GraphQLOptions } from 'apollo-server-core'; import {
import { processRequest as processFileUploads } from '@apollographql/apollo-upload-server'; ApolloServerBase,
GraphQLOptions,
processFileUploads,
} from 'apollo-server-core';
import { ServerResponse } from 'http'; import { ServerResponse } from 'http';
import { send } from 'micro'; import { send } from 'micro';
import { renderPlaygroundPage } from '@apollographql/graphql-playground-html'; import { renderPlaygroundPage } from '@apollographql/graphql-playground-html';
@ -39,7 +42,9 @@ export class ApolloServer extends ApolloServerBase {
await promiseWillStart; await promiseWillStart;
await this.handleFileUploads(req); if (typeof processFileUploads === 'function') {
await this.handleFileUploads(req, res);
}
(await this.handleHealthCheck({ (await this.handleHealthCheck({
req, req,
@ -161,15 +166,19 @@ export class ApolloServer extends ApolloServerBase {
} }
// If file uploads are detected, prepare them for easier handling with // If file uploads are detected, prepare them for easier handling with
// the help of `apollo-upload-server`. // the help of `graphql-upload`.
private async handleFileUploads(req: MicroRequest) { private async handleFileUploads(req: MicroRequest, res: ServerResponse) {
if (typeof processFileUploads !== 'function') {
return;
}
const contentType = req.headers['content-type']; const contentType = req.headers['content-type'];
if ( if (
this.uploadsConfig && this.uploadsConfig &&
contentType && contentType &&
contentType.startsWith('multipart/form-data') contentType.startsWith('multipart/form-data')
) { ) {
req.filePayload = await processFileUploads(req, this.uploadsConfig); req.filePayload = await processFileUploads(req, res, this.uploadsConfig);
} }
} }
} }

View file

@ -1,7 +1,7 @@
import micro from 'micro'; import micro from 'micro';
import listen from 'test-listen'; import listen from 'test-listen';
import { createApolloFetch } from 'apollo-fetch'; import { createApolloFetch } from 'apollo-fetch';
import { atLeastMajorNodeVersion } from 'apollo-server-integration-testsuite'; import { NODE_MAJOR_VERSION } from 'apollo-server-integration-testsuite';
import { gql } from 'apollo-server-core'; import { gql } from 'apollo-server-core';
import FormData from 'form-data'; import FormData from 'form-data';
import fs from 'fs'; import fs from 'fs';
@ -146,7 +146,10 @@ describe('apollo-server-micro', function() {
}); });
}); });
(atLeastMajorNodeVersion(10) ? describe.skip : describe)( // NODE: Intentionally skip file upload tests on Node.js 10.
// Also skip Node.js 6, but only because `graphql-upload`
// doesn't support it.
(NODE_MAJOR_VERSION === 6 ? describe.skip : describe)(
'file uploads', 'file uploads',
function() { function() {
it('should handle file uploads', async function() { it('should handle file uploads', async function() {

View file

@ -1,6 +1,6 @@
{ {
"name": "apollo-server-plugin-base", "name": "apollo-server-plugin-base",
"version": "0.1.7", "version": "0.2.0-alpha.0",
"description": "Apollo Server plugin base classes", "description": "Apollo Server plugin base classes",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",

View file

@ -1,6 +1,6 @@
{ {
"name": "apollo-server-testing", "name": "apollo-server-testing",
"version": "2.2.7", "version": "2.3.0-alpha.0",
"description": "Test utils for apollo-server", "description": "Test utils for apollo-server",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",

View file

@ -1,6 +1,6 @@
{ {
"name": "apollo-server", "name": "apollo-server",
"version": "2.2.7", "version": "2.3.0-alpha.0",
"description": "Production ready GraphQL Server", "description": "Production ready GraphQL Server",
"author": "opensource@apollographql.com", "author": "opensource@apollographql.com",
"main": "dist/index.js", "main": "dist/index.js",

View file

@ -1,6 +1,6 @@
{ {
"name": "apollo-tracing", "name": "apollo-tracing",
"version": "0.3.4", "version": "0.4.0-alpha.0",
"description": "Collect and expose trace data for GraphQL requests", "description": "Collect and expose trace data for GraphQL requests",
"main": "./dist/index.js", "main": "./dist/index.js",
"types": "./dist/index.d.ts", "types": "./dist/index.d.ts",

View file

@ -1,6 +1,6 @@
{ {
"name": "graphql-extensions", "name": "graphql-extensions",
"version": "0.3.7", "version": "0.4.0-alpha.0",
"description": "Add extensions to GraphQL servers", "description": "Add extensions to GraphQL servers",
"main": "./dist/index.js", "main": "./dist/index.js",
"types": "./dist/index.d.ts", "types": "./dist/index.d.ts",

View file

@ -1,25 +0,0 @@
import { GraphQLScalarType } from 'graphql';
export const GraphQLUpload: GraphQLScalarType;
export interface ApolloUploadOptions {
/**
* Max allowed non-file multipart form field size in bytes; enough for your queries (default: 1 MB)
*/
maxFieldSize?: number;
/**
* Max allowed file size in bytes (default: Infinity)
*/
maxFileSize?: number;
/**
* Max allowed number of files (default: Infinity)
*/
maxFiles?: number;
}
export type Request = any;
export function processRequest(
request: Request,
options?: ApolloUploadOptions,
): Promise<any>;

30
types/graphql-upload/index.d.ts vendored Normal file
View file

@ -0,0 +1,30 @@
declare module 'graphql-upload' {
import { GraphQLScalarType } from 'graphql';
export const GraphQLUpload: GraphQLScalarType;
export interface ApolloUploadOptions {
/**
* Max allowed non-file multipart form field size in bytes; enough for your queries (default: 1 MB)
*/
maxFieldSize?: number;
/**
* Max allowed file size in bytes (default: Infinity)
*/
maxFileSize?: number;
/**
* Max allowed number of files (default: Infinity)
*/
maxFiles?: number;
}
export type Request = any;
export type Response = any;
export function processRequest(
request: Request,
response: Response,
options?: ApolloUploadOptions,
): Promise<any>;
}