graphql-upload 11.0.0 → 14.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/changelog.md DELETED
@@ -1,493 +0,0 @@
1
- # graphql-upload changelog
2
-
3
- ## 11.0.0
4
-
5
- ### Major
6
-
7
- - Updated Node.js support to `^10.13.0 || ^12.0.0 || >= 13.7.0`.
8
- - Added a [package `exports` field](https://nodejs.org/api/esm.html#esm_package_entry_points) with [conditional exports](https://nodejs.org/api/esm.html#esm_conditional_exports) to support native ESM in Node.js and keep internal code private, [whilst avoiding the dual package hazard](https://nodejs.org/api/esm.html#esm_approach_1_use_an_es_module_wrapper). Published files have been reorganized, so previously undocumented deep imports will need to be rewritten according to the newly documented paths.
9
- - Updated dev dependencies, some of which require newer Node.js versions than previously supported.
10
-
11
- ### Patch
12
-
13
- - Updated the [`graphql`](https://npm.im/graphql) peer dependency to `0.13.1 - 15`, fixing [#200](https://github.com/jaydenseric/graphql-upload/issues/200) via [#201](https://github.com/jaydenseric/graphql-upload/pull/201).
14
- - Updated Prettier related package scripts.
15
- - Configured Prettier option `semi` to the default, `true`.
16
- - Ensure GitHub Actions run on pull request.
17
- - Also run GitHub Actions with Node.js v14.
18
- - Fixed the `ignoreStream` function tests for Node.js v14 with a new `CountReadableStream` test helper, fixing [#209](https://github.com/jaydenseric/graphql-upload/issues/209).
19
- - Minor JSDoc wording tweak for consistency.
20
- - Mention [`Promise.allSettled`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled) in the readme “Tips” section.
21
- - Updated MDN Web Docs links.
22
-
23
- ## 10.0.0
24
-
25
- ### Major
26
-
27
- - Updated Node.js support from v8.10+ to v10+, as earlier versions have reached end-of-life.
28
- - Updated the [`fs-capacitor`](https://npm.im/fs-capacitor) dependency to v6, which now requires Node.js v10+, via [#179](https://github.com/jaydenseric/graphql-upload/pull/179).
29
- - Updated dev dependencies, some of which now require Node.js v10+.
30
- - Replaced the [`tap`](https://npm.im/tap) dev dependency with [`test-director`](https://npm.im/test-director), [`coverage-node`](https://npm.im/coverage-node), and [`hard-rejection`](https://npm.im/hard-rejection) to improve the dev experience and reduce the dev install size by ~75.7 MB. These new dev dependencies require Node.js v10+.
31
- - Reorganized files. This is only a breaking change for projects using undocumented deep imports.
32
- - Removed now redundant Node.js version compatibility logic in the `processRequest` function.
33
- - The `processRequest` function now places references to instances of the now exported and documented `Upload` class in the GraphQL operation for the `GraphQLUpload` scalar to derive its value, and the `GraphQLUpload` scalar now throws a `GraphQLError` when it parses an invalid value, fixing [#175](https://github.com/jaydenseric/graphql-upload/issues/175) via [#181](https://github.com/jaydenseric/graphql-upload/pull/181).
34
- - The `GraphQLUpload` scalar `parseLiteral` and `serialize` methods now throw `GraphQLError` (instead of `Error`) instances, with tweaked messages.
35
-
36
- ### Minor
37
-
38
- - The `createReadStream` function in resolved file uploads now accepts options to configure the encoding and high water mark, fixing [#177](https://github.com/jaydenseric/graphql-upload/issues/177) via [#179](https://github.com/jaydenseric/graphql-upload/pull/179).
39
-
40
- ### Patch
41
-
42
- - Removed the now redundant [`eslint-plugin-import-order-alphabetical`](https://npm.im/eslint-plugin-import-order-alphabetical) and [`express-async-handler`](https://npm.im/express-async-handler) dev dependencies.
43
- - Stop using [`husky`](https://npm.im/husky) and [`lint-staged`](https://npm.im/lint-staged).
44
- - Use [`isobject`](https://npm.im/isobject) for checking if values are enumerable, non-array objects.
45
- - Tests have been massively reorganized, refactored, and improved.
46
- - Test the `GraphQLUpload` scalar.
47
- - Test the `ignoreStream` function.
48
- - Moved the `Upload` class to its own file.
49
- - Added JSDoc for the `Upload` class instance property `file`.
50
- - Test the `Upload` class.
51
- - Improved JSDoc `FileUpload` typedef description.
52
- - Removed now redundant `eslint-disable-next-line` comments.
53
- - Use strict mode for scripts.
54
-
55
- ## 9.0.0
56
-
57
- ### Major
58
-
59
- - Updated Node.js support from v8.5+ to v8.10+, to match what the [`eslint`](https://npm.im/eslint) dev dependency now supports. This is unlikely to be a breaking change for the published package.
60
- - Removed the `Upload` scalar promise resolved `stream` property that has been deprecated since v7, along with associated tests.
61
- - ESM is no longer published, due to CJS/ESM compatibility issues across recent Node.js versions, via [#169](https://github.com/jaydenseric/graphql-upload/pull/169).
62
- - The file structure and non-index file exports have changed. This should only affect projects using undocumented deep imports.
63
-
64
- ### Minor
65
-
66
- - Updated the [`fs-capacitor`](https://npm.im/fs-capacitor) dependency to v4 to support Node.js v13, making required changes to the source and tests, via [#166](https://github.com/jaydenseric/graphql-upload/pull/166).
67
- - JSDoc comments are now included in the published code.
68
- - Several anonymous functions have been named, for better error stack traces.
69
- - Setup [GitHub Sponsors funding](https://github.com/sponsors/jaydenseric):
70
- - Added `.github/funding.yml` to display a sponsor button in GitHub.
71
- - Added a `package.json` `funding` field to enable npm CLI funding features.
72
-
73
- ### Patch
74
-
75
- - Updated dev dependencies.
76
- - Removed the `.nycrc.json` file:
77
- - [`tap`](https://npm.im/tap) now ignores test files by default.
78
- - The `lib/test-helpers` directory is now ignored using [`tap`](https://npm.im/tap) CLI arguments due to [tapjs/node-tap#612](https://github.com/tapjs/node-tap/issues/612).
79
- - Removed the `esm` and `mjs` package tags; they will be added back once native ESM is properly supported.
80
- - Updated JSDoc code examples to use CJS instead of ESM, as native ESM is not yet properly supported.
81
- - No longer test [`fs-capacitor`](https://npm.im/fs-capacitor) implementation details such as temp file creation and cleanup.
82
- - Commented the reasons for several `istanbul ignore next` comments.
83
-
84
- ## 8.1.0
85
-
86
- ### Minor
87
-
88
- - `processRequest` now throws an appropriate error when a multipart field value exceeds the configured size limit, fixing [#159](https://github.com/jaydenseric/graphql-upload/issues/159).
89
- - When the file size limit is exceeded, mention how many bytes the limit is in the stream error message.
90
- - Added a new `processRequest` option to the `graphqlUploadExpress` and `graphqlUploadKoa` middleware, for improved testing without mocks or spies which are difficult to achieve with ESM.
91
-
92
- ### Patch
93
-
94
- - Updated dependencies.
95
- - Due to updated dependencies: Lint fixes, removed redundant `eslint-disable-next-line` comments, and regenerated the readme.
96
- - Documented [`koa-graphql`](https://npm.im/koa-graphql) as known to be compatible, via [#156](https://github.com/jaydenseric/graphql-upload/pull/156).
97
- - Fixed a readme typo, via [#161](https://github.com/jaydenseric/graphql-upload/pull/161).
98
- - Use GitHub Actions instead of Travis for CI.
99
- - Removed `package-lock.json` from `.gitignore` and `.prettierignore`, as it’s disabled in `.npmrc` anyway.
100
- - New file structure.
101
- - Explicitly defined main exports (instead of using `export * from`) to prevent accidental public exposure of internal APIs.
102
- - Moved JSDoc typedefs into the index main entry file, alphabetically sorted.
103
- - Nicer Browserslist query syntax.
104
- - Replaced the `isObject` helper with a smarter and tested `isEnumerableObject`.
105
- - Removed the `isString` helper.
106
- - Enforced 100% code coverage for tests, and improved `processRequest` internals and tests (including a new test using vanilla Node.js HTTP), fixing [#130](https://github.com/jaydenseric/graphql-upload/issues/130) via [#162](https://github.com/jaydenseric/graphql-upload/pull/162).
107
- - Removed a workaround from the `startServer` test helper.
108
- - Added a new `ProcessRequestFunction` JSDoc type, and applied it to `processRequest`.
109
- - Renamed the `UploadOptions` JSDoc type to `ProcessRequestOptions`.
110
- - Misc. documentation improvements.
111
-
112
- ## 8.0.7
113
-
114
- ### Patch
115
-
116
- - Updated dependencies.
117
- - Handle invalid object paths in `map` multipart field entries, fixing [#154](https://github.com/jaydenseric/graphql-upload/issues/154).
118
- - Import `WriteStream` from [`fs-capacitor`](https://npm.im/fs-capacitor) as a named rather than default import.
119
-
120
- ## 8.0.6
121
-
122
- ### Patch
123
-
124
- - Updated dependencies.
125
- - Allow batched operations again, fixing [#142](https://github.com/jaydenseric/graphql-upload/issues/142).
126
- - Simplify tests by writing JSON as strings instead of using `JSON.stringify`.
127
- - Use async middleware with [`express-async-handler`](https://npm.im/express-async-handler) for Express tests.
128
- - Removed unintended `maxFiles` config in certain tests.
129
- - Added the Open Graph image design to the logo Sketch file.
130
-
131
- ## 8.0.5
132
-
133
- ### Patch
134
-
135
- - Updated dependencies.
136
- - Handle invalid types in multipart fields and respond with meaningful HTTP 400 errors, via [#139](https://github.com/jaydenseric/graphql-upload/pull/139):
137
- - Invalid `operations` type.
138
- - Invalid `map` type.
139
- - Invalid `map` entry type.
140
- - Invalid `map` entry array item type.
141
- - Additionally test current Node.js v8 and v10 versions with Travis.
142
- - Reduced the size of the published `package.json` by moving dev tool config to files. This also prevents editor extensions such as Prettier and ESLint from detecting config and attempting to operate when opening package files installed in `node_modules`.
143
- - Removed the [`watch`](https://npm.im/watch) dev dependency and `watch` script.
144
- - Simplified the `prepublishOnly` script.
145
- - Change to the `classic` TAP reporter for tests.
146
- - Add [`apollo-server-koa`](https://npm.im/apollo-server-koa) and [`apollo-server-express`](https://npm.im/apollo-server-express) back to the compatible environments list in the readme, now that they use the current version of this package.
147
-
148
- ## 8.0.4
149
-
150
- ### Patch
151
-
152
- - Updated the [`fs-capacitor`](https://npm.im/fs-capacitor) dependency to v2, fixing [#131](https://github.com/jaydenseric/graphql-upload/issues/131) via [#132](https://github.com/jaydenseric/graphql-upload/pull/132).
153
-
154
- ## 8.0.3
155
-
156
- ### Patch
157
-
158
- - Updated dependencies. The `busboy` update contains [a bug fix for `.pipe()` on file streams](https://github.com/mscdex/busboy/issues/188).
159
- - Use [jsDelivr](https://jsdelivr.com) for the readme logo instead of [RawGit](https://rawgit.com) as they are shutting down.
160
-
161
- ## 8.0.2
162
-
163
- ### Patch
164
-
165
- - Updated dev dependencies.
166
- - Fixed hanging when a request with a large payload has an “immediate” error, such as a malformed request, fixing [#123](https://github.com/jaydenseric/graphql-upload/issues/123) via [#124](https://github.com/jaydenseric/graphql-upload/pull/124).
167
- - Moved JSDoc type definitions to the end of files to make it easier to open to the code.
168
-
169
- ## 8.0.1
170
-
171
- ### Patch
172
-
173
- - Updated dev dependencies.
174
- - Removed the package `module` field. Webpack by default resolves extensionless paths the same way Node.js in `--experimental-modules` mode does; `.mjs` files are preferred. Tools misconfigured or unable to resolve `.mjs` can get confused when `module` points to an `.mjs` ESM file and they attempt to resolve named imports from `.js` CJS files.
175
- - Updated package scripts and config for the new [`husky`](https://npm.im/husky) version.
176
- - Added a package `browserslist` field with the target Node.js version for [`@babel/preset-env`](https://npm.im/@babel/preset-env) and removed related config from `babel.config.js`.
177
- - Tests now log if the environment is CJS or ESM (`--experimental-modules`) and the `NODE_ENV`.
178
- - Fixed broken readme API documentation links.
179
-
180
- ## 8.0.0
181
-
182
- ### Major
183
-
184
- - New naming that drops “apollo” to reflect the independent and universal nature of the project, fixing [#68](https://github.com/jaydenseric/apollo-upload-server/issues/68):
185
-
186
- - Changed the package name from [`apollo-upload-server`](https://npm.im/apollo-upload-server) to [`graphql-upload`](https://npm.im/graphql-upload).
187
- - Renamed `apolloUploadKoa` to `graphqlUploadKoa`.
188
- - Renamed `apolloUploadExpress` to `graphqlUploadExpress`.
189
-
190
- To migrate you project from `apollo-upload-server@7.1.0` to `graphql-upload@8.0.0`:
191
-
192
- 1. Run `npm uninstall apollo-upload-server`.
193
- 2. Run `npm install graphql-upload`.
194
- 3. Find and replace:
195
- - `apolloUploadKoa` → `graphqlUploadKoa`.
196
- - `apolloUploadExpress` → `graphqlUploadExpress`.
197
-
198
- ### Patch
199
-
200
- - Updated dependencies.
201
- - New project logo.
202
-
203
- ## 7.1.0
204
-
205
- ### Minor
206
-
207
- - Support [`graphql`](https://npm.im/graphql) v14.
208
-
209
- ### Patch
210
-
211
- - Updated dev dependencies.
212
-
213
- ## 7.0.0
214
-
215
- ### Major
216
-
217
- - The `processRequest` function now requires a [`http.ServerResponse`](https://nodejs.org/api/http.html#http_class_http_serverresponse) instance as its second argument.
218
- - Replaced the previously exported error classes with [`http-errors`](https://npm.im/http-errors) and snapshot tested error details, via [#105](https://github.com/jaydenseric/apollo-upload-server/pull/105).
219
- - No longer exporting the `SPEC_URL` constant.
220
-
221
- ### Minor
222
-
223
- - `Upload` scalar promises now resolve with a `createReadStream` method instead of a `stream` property, via [#92](https://github.com/jaydenseric/apollo-upload-server/pull/92).
224
- - Accessing an `Upload` scalar promise resolved `stream` property results in a deprecation warning that recommends using `createReadStream` instead. It will be removed in a future release. Via [#107](https://github.com/jaydenseric/apollo-upload-server/pull/107).
225
- - An `Upload` scalar variable can now be used by multiple resolvers, via [#92](https://github.com/jaydenseric/apollo-upload-server/pull/92).
226
- - Multiple `Upload` scalar variables can now use the same multipart data, via [#92](https://github.com/jaydenseric/apollo-upload-server/pull/92).
227
- - Malformed requests containing invalid JSON for `operations` or `map` multipart fields cause an appropriate error with a `400` status instead of crashing the process, relating to [#81](https://github.com/jaydenseric/apollo-upload-server/pull/81) and [#95](https://github.com/jaydenseric/apollo-upload-server/issues/95).
228
- - Malformed requests missing `operations`, `map` and files, or just `map` and files, cause an appropriate error with a `400` status instead of hanging, fixing [#96](https://github.com/jaydenseric/apollo-upload-server/issues/96).
229
- - Tweaked `GraphQLUpload` scalar description to remove details about how it resolves on the server as they are irrelevant to API users.
230
- - Tweaked `GraphQLUpload` scalar error messages.
231
-
232
- ### Patch
233
-
234
- - Updated dev dependencies.
235
- - Removed the [`npm-run-all`](https://npm.im/npm-run-all) dev dependency and made scripts and tests sync for easier debugging, at the cost of slightly longer build times.
236
- - Explicitly set `processRequest` default options instead of relying on [`busboy`](https://npm.im/busboy) defaults.
237
- - Better organized project file structure.
238
- - Configured Prettier to lint `.yml` files.
239
- - Ensure the readme Travis build status badge only tracks `master` branch.
240
-
241
- ## 6.0.0-alpha.1
242
-
243
- Big thanks to new collaborator [@mike-marcacci](https://github.com/mike-marcacci) for his help solving tricky bugs and edge-cases!
244
-
245
- ### Major
246
-
247
- - Updated Node.js support from v6.10+ to v8.5+ for [native ESM](https://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V8.md#8.5.0), [object rest/spread properties](https://node.green#ES2018-features-object-rest-spread-properties), and [async functions](https://node.green#ES2017-features-async-functions).
248
- - Removed the [`@babel/runtime`](https://npm.im/@babel/runtime) dependency and config.
249
- - Fixed [#45](https://github.com/jaydenseric/apollo-upload-server/issues/45), [#77](https://github.com/jaydenseric/apollo-upload-server/issues/77) and [#83](https://github.com/jaydenseric/apollo-upload-server/issues/83) via [#81](https://github.com/jaydenseric/apollo-upload-server/pull/81):
250
- - Add `error` event listeners to file streams to prevent server crashes on aborted requests or parser errors.
251
- - Use [`fs-capacitor`](https://npm.im/fs-capacitor) to ensure the server doesn’t hang if an upload `await` is out of order, or is never consumed.
252
-
253
- ### Minor
254
-
255
- - Refactored package scripts to use `prepare` to support installation via Git (e.g. `npm install jaydenseric/apollo-upload-server`).
256
-
257
- ### Patch
258
-
259
- - Updated dependencies.
260
- - Use single instead of double typographic quotes in error messages.
261
- - Use `babel.config.js` instead of `.babelrc.js`.
262
- - Enabled `shippedProposals` in [`@babel/preset-env`](https://npm.im/@babel/preset-env) config.
263
- - Improved testing:
264
- - Use [`tap`](https://npm.im/tap) instead of [`ava`](https://npm.im/ava). Tests no longer transpile on the fly, are faster and AVA no longer dictates the Babel version.
265
- - Tests run against the actual dist `.mjs` and `.js` files in native ESM (`--experimental-modules`) and CJS environments.
266
- - Removed `get-port` dev dependency.
267
- - Added Express tests.
268
- - Test middleware error response status codes.
269
- - Test behavior of aborted HTTP requests.
270
- - Test that the app can respond if an upload is not handled.
271
- - Test files to upload are created in context, rather than using arbitrary project files, via [#89](https://github.com/jaydenseric/apollo-upload-server/pull/89).
272
- - Improved `package.json` scripts:
273
- - Leveraged `npm-run-all` more for parallelism and reduced noise.
274
- - Removed the clean script `rimraf` dev dependency in favour of native `rm -rf`. Leaner and faster; we only support \*nix now for contributing anyway.
275
- - No longer use `cross-env`; contributors with Windows may setup and use a Bash shell.
276
- - Renamed the `ESM` environment variable to `BABEL_ESM` to be more specific.
277
- - Removed linting fix scripts.
278
- - Linting included in the test script; Travis CI will fail PR's with lint errors.
279
- - Custom watch script.
280
- - Improved ESLint config:
281
- - Simplified ESLint config with [`eslint-config-env`](https://npm.im/eslint-config-env).
282
- - Removed redundant [`eslint-plugin-ava`](https://npm.im/eslint-plugin-ava) dev dependency and config.
283
- - Undo overriding ESLint ignoring dotfiles by default as there are none now.
284
- - Use `.prettierignore` to leave `package.json` formatting to npm.
285
- - Tweaked package `description` and `keywords`.
286
- - Compact package `repository` field.
287
- - Improved documentation.
288
- - Readme badge changes to deal with [shields.io](https://shields.io) unreliability:
289
- - Use the official Travis build status badge.
290
- - Use [Badgen](https://badgen.net) for the npm version badge.
291
- - Removed the licence badge. The licence can be found in `package.json` and rarely changes.
292
- - Removed the Github issues and stars badges. The readme is most viewed on Github anyway.
293
- - Changelog version entries now have “Major”, “Minor” and “Patch” subheadings.
294
-
295
- ## 5.0.0
296
-
297
- ### Major
298
-
299
- - [`graphql`](https://npm.im/graphql) peer dependency range updated to `^0.13.1` for native ESM support via `.mjs`. It’s a breaking change despite being a semver patch.
300
-
301
- ### Patch
302
-
303
- - Updated dependencies.
304
- - More robust npm scripts, with the ability to watch builds and tests together.
305
- - Fixed missing dev dependency for fetching in tests.
306
- - Use [`eslint-plugin-ava`](https://github.com/avajs/eslint-plugin-ava).
307
- - HTTPS `package.json` author URL.
308
- - New readme logo URL that doesn’t need to be updated every version.
309
-
310
- ## 4.0.2
311
-
312
- ### Patch
313
-
314
- - Temporary solution for importing CommonJS in `.mjs`, fixing reopened [#40](https://github.com/jaydenseric/apollo-upload-server/issues/40).
315
-
316
- ## 4.0.1
317
-
318
- ### Patch
319
-
320
- - Correct imports for vanilla Node.js `--experimental-modules` and `.mjs` support, fixing [#40](https://github.com/jaydenseric/apollo-upload-server/issues/40).
321
-
322
- ## 4.0.0
323
-
324
- ### Patch
325
-
326
- - Updated dependencies.
327
- - Simplified npm scripts.
328
- - Readme updates:
329
- - Documented [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) types, via [#39](https://github.com/jaydenseric/apollo-upload-server/pull/39).
330
- - Explained how to use `processRequest` for custom middleware.
331
- - Improved usage instructions.
332
- - Display oldest supported Node.js version.
333
- - Misc. tweaks including a simpler heading structure.
334
-
335
- ## 4.0.0-alpha.3
336
-
337
- ### Minor
338
-
339
- - Updated peer dependencies to support `graphql@0.12`, via [#36](https://github.com/jaydenseric/apollo-upload-server/pull/36).
340
-
341
- ### Patch
342
-
343
- - Updated dependencies.
344
-
345
- ## 4.0.0-alpha.2
346
-
347
- ### Minor
348
-
349
- - Transpile and polyfill for Node.js v6.10+ (down from v7.6+) to [support AWS Lambda](https://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html), fixing [#33](https://github.com/jaydenseric/apollo-upload-server/issues/33).
350
- - Modular project structure that works better for native ESM.
351
- - Added tests.
352
- - Set up Travis to test using the latest stable Node.js version and the oldest supported in `package.json` `engines` (v6.10).
353
- - Added a Travis readme badge.
354
- - Improved error handling, fixing [#26](https://github.com/jaydenseric/apollo-upload-server/issues/26):
355
- - Custom errors are thrown or emitted with meaningful messages that are exported so consumers can use `instanceof` with them.
356
- - Where it makes sense, errors cause relevant HTTP status codes to be set in middleware.
357
- - [Misordered multipart fields](https://github.com/jaydenseric/graphql-multipart-request-spec) cause `processRequest` to throw `MapBeforeOperationsUploadError` and `FilesBeforeMapUploadError` errors in middleware.
358
- - The `map` field provided by the client is used to naively check the `maxFiles` option is not exceeded for a speedy `MaxFilesUploadError` error in middleware. The real number of files parsed is checked too, incase the request is malformed.
359
- - If files are missing from the request the `scalar Upload` promises reject with a `FileMissingUploadError` error.
360
- - Already if a file exceeds the `maxFileSize` option the file is truncated, the stream emits a `limit` event and `stream.truncated === true`. Now an `error` event is also emitted with a `MaxFileSizeUploadError`.
361
- - Aborting requests from the client causes `scalar Upload` promises to reject with a `UploadPromiseDisconnectUploadError` error for file upload streams that have not yet been parsed. For streams being parsed an `error` event is emitted with an `FileStreamDisconnectUploadError` error and `stream.truncated === true`. It is up to consumers to cleanup aborted streams in their resolvers.
362
-
363
- ### Patch
364
-
365
- - Updated dependencies.
366
- - Smarter Babel config with `.babelrc.js`.
367
- - Refactor to use fewer Busboy event listeners.
368
-
369
- ## 4.0.0-alpha.1
370
-
371
- ### Major
372
-
373
- - New API to support the [GraphQL multipart request spec v2.0.0-alpha.2](https://github.com/jaydenseric/graphql-multipart-request-spec/releases/tag/v2.0.0-alpha.2). Files no longer upload to the filesystem; [readable streams](https://nodejs.org/api/stream.html#stream_readable_streams) are used in resolvers instead. Fixes [#13](https://github.com/jaydenseric/apollo-upload-server/issues/13) via [#22](https://github.com/jaydenseric/apollo-upload-server/pull/22).
374
- - Export a new `Upload` scalar type to use in place of the old `Upload` input type. It represents a file upload promise that resolves an object containing `stream`, `filename`, `mimetype` and `encoding`.
375
- - Deprecated the `uploadDir` middleware option.
376
- - `graphql` is now a peer dependency.
377
-
378
- ### Minor
379
-
380
- - Added new `maxFieldSize`, `maxFileSize` and `maxFiles` middleware options.
381
-
382
- ### Patch
383
-
384
- - Middleware are now arrow functions.
385
-
386
- ## 3.0.0
387
-
388
- ### Major
389
-
390
- - Updated Node.js support from v6.4+ to v7.6+.
391
- - Express middleware now passes on errors instead of blocking, via [#20](https://github.com/jaydenseric/apollo-upload-server/pull/20).
392
-
393
- ### Patch
394
-
395
- - Using Babel directly, dropping Rollup.
396
- - New directory structure for compiled files.
397
- - Module files now have `.mjs` extension.
398
- - No longer publish the `src` directory.
399
- - No more sourcemaps.
400
- - Use an arrow function for the Koa middleware, to match the Express middleware.
401
- - Compiled code is now prettier.
402
- - Prettier markdown files.
403
- - Updated package keywords.
404
- - Updated an Apollo documentation link in the changelog.
405
- - Readme improvements:
406
- - Added links to badges.
407
- - Removed the inspiration links; they are less relevant to the evolved codebase.
408
- - Fixed an Apollo link.
409
- - Replaced example resolver code with a link to the [Apollo upload examples](https://github.com/jaydenseric/apollo-upload-examples).
410
-
411
- ## 2.0.4
412
-
413
- ### Patch
414
-
415
- - Updated dependencies.
416
- - Readme tweaks including a new license badge.
417
-
418
- ## 2.0.3
419
-
420
- ### Patch
421
-
422
- - Updated dependencies.
423
- - Removed `package-lock.json`. Lockfiles are [not recommended](https://github.com/sindresorhus/ama/issues/479#issuecomment-310661514) for packages.
424
- - Moved Babel config out of `package.json` to prevent issues when consumers run Babel over `node_modules`.
425
- - Readme tweaks and fixes:
426
- - Renamed the `File` input type `Upload` for clarity.
427
- - Wording and formatting improvements.
428
- - Covered React Native.
429
- - Documented custom middleware.
430
-
431
- ## 2.0.2
432
-
433
- ### Patch
434
-
435
- - Updated dependencies.
436
- - Added a changelog.
437
- - Dropped Yarn in favor of npm@5. Removed `yarn.lock` and updated install instructions.
438
- - Set targeted Node version as a string for `babel-preset-env`.
439
- - New ESLint config. Dropped [Standard Style](https://standardjs.com) and began using [Prettier](https://github.com/prettier/eslint-plugin-prettier).
440
- - Using [lint-staged](https://github.com/okonet/lint-staged) to ensure contributors don't commit lint errors.
441
- - Removed `build:watch` script. Use `npm run build -- --watch` directly.
442
-
443
- ## 2.0.1
444
-
445
- ### Patch
446
-
447
- - Updated dependencies.
448
- - Support regular requests from clients other than apollo-upload-client again, fixing [#4](https://github.com/jaydenseric/apollo-upload-server/issues/4).
449
- - Removed incorrect commas from example GraphQL input type.
450
-
451
- ## 2.0.0
452
-
453
- ### Major
454
-
455
- - Support `apollo-upload-client` v3 and [query batching](https://apollographql.com/docs/apollo-server/requests#batching).
456
-
457
- ### Patch
458
-
459
- - Clearer package description.
460
- - Use [Standard Style](https://standardjs.com) instead of ESLint directly.
461
-
462
- ## 1.1.0
463
-
464
- ### Minor
465
-
466
- - Exporting a new helper function for processing requests. It can be used to create custom middleware, or middleware for unsupported routers.
467
- - Exporting new Koa middleware.
468
- - Upload directory is ensured on every request now. While slightly less efficient, it prevents major errors when if it is deleted while the server is running.
469
-
470
- ### Patch
471
-
472
- - Updated dependencies.
473
- - Documented npm install as well as Yarn.
474
- - Typo fix in the readme.
475
-
476
- ## 1.0.2
477
-
478
- ### Patch
479
-
480
- - Fixed broken Github deep links in the readme.
481
- - Readme rewording.
482
- - Simplified `package.json` description.
483
-
484
- ## 1.0.1
485
-
486
- ### Patch
487
-
488
- - Added missing metadata to `package.json`.
489
- - Added a link to apollographql/graphql-server in the readme.
490
-
491
- ## 1.0.0
492
-
493
- Initial release.
@@ -1,12 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * Official [GraphQL multipart request spec](https://github.com/jaydenseric/graphql-multipart-request-spec)
5
- * URL. Useful for error messages, etc.
6
- * @kind constant
7
- * @name SPEC_URL
8
- * @type {string}
9
- * @ignore
10
- */
11
- exports.SPEC_URL =
12
- 'https://github.com/jaydenseric/graphql-multipart-request-spec';
@@ -1,16 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * Safely ignores a Node.js readable stream.
5
- * @kind function
6
- * @name ignoreStream
7
- * @param {ReadableStream} stream Node.js readable stream.
8
- * @ignore
9
- */
10
- module.exports = function ignoreStream(stream) {
11
- // Prevent an unhandled error from crashing the process.
12
- stream.on('error', () => {});
13
-
14
- // Waste the stream.
15
- stream.resume();
16
- };
@@ -1,90 +0,0 @@
1
- 'use strict';
2
-
3
- const { GraphQLScalarType, GraphQLError } = require('graphql');
4
- const Upload = require('./Upload');
5
-
6
- /**
7
- * A GraphQL `Upload` scalar that can be used in a
8
- * [`GraphQLSchema`](https://graphql.org/graphql-js/type/#graphqlschema).
9
- * It’s value in resolvers is a promise that resolves
10
- * [file upload details]{@link FileUpload} for processing and storage.
11
- * @kind class
12
- * @name GraphQLUpload
13
- * @example <caption>Ways to `import`.</caption>
14
- * ```js
15
- * import { GraphQLUpload } from 'graphql-upload';
16
- * ```
17
- *
18
- * ```js
19
- * import GraphQLUpload from 'graphql-upload/public/GraphQLUpload.js';
20
- * ```
21
- * @example <caption>Ways to `require`.</caption>
22
- * ```js
23
- * const { GraphQLUpload } = require('graphql-upload');
24
- * ```
25
- *
26
- * ```js
27
- * const GraphQLUpload = require('graphql-upload/public/GraphQLUpload');
28
- * ```
29
- * @example <caption>Setup for a schema built with [`makeExecutableSchema`](https://apollographql.com/docs/graphql-tools/generate-schema#makeExecutableSchema).</caption>
30
- * ```js
31
- * const { makeExecutableSchema } = require('graphql-tools');
32
- * const { GraphQLUpload } = require('graphql-upload');
33
- *
34
- * const schema = makeExecutableSchema({
35
- * typeDefs: /* GraphQL *\/ `
36
- * scalar Upload
37
- * `,
38
- * resolvers: {
39
- * Upload: GraphQLUpload,
40
- * },
41
- * });
42
- * ```
43
- * @example <caption>A manually constructed schema with an image upload mutation.</caption>
44
- * ```js
45
- * const {
46
- * GraphQLSchema,
47
- * GraphQLObjectType,
48
- * GraphQLBoolean,
49
- * } = require('graphql');
50
- * const { GraphQLUpload } = require('graphql-upload');
51
- *
52
- * const schema = new GraphQLSchema({
53
- * mutation: new GraphQLObjectType({
54
- * name: 'Mutation',
55
- * fields: {
56
- * uploadImage: {
57
- * description: 'Uploads an image.',
58
- * type: GraphQLBoolean,
59
- * args: {
60
- * image: {
61
- * description: 'Image file.',
62
- * type: GraphQLUpload,
63
- * },
64
- * },
65
- * async resolve(parent, { image }) {
66
- * const { filename, mimetype, createReadStream } = await image;
67
- * const stream = createReadStream();
68
- * // Promisify the stream and store the file, then…
69
- * return true;
70
- * },
71
- * },
72
- * },
73
- * }),
74
- * });
75
- * ```
76
- */
77
- module.exports = new GraphQLScalarType({
78
- name: 'Upload',
79
- description: 'The `Upload` scalar type represents a file upload.',
80
- parseValue(value) {
81
- if (value instanceof Upload) return value.promise;
82
- throw new GraphQLError('Upload value invalid.');
83
- },
84
- parseLiteral(ast) {
85
- throw new GraphQLError('Upload literal unsupported.', ast);
86
- },
87
- serialize() {
88
- throw new GraphQLError('Upload serialization unsupported.');
89
- },
90
- });