Middleware and a scalar Upload to add support for GraphQL multipart requests (file uploads via queries and mutations) to various Node.js GraphQL servers.
MIT License
Bot releases are hidden (Show)
Published by jaydenseric almost 6 years ago
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.husky
version.browserslist
field with the target Node.js version for @babel/preset-env
and removed related config from babel.config.js
.--experimental-modules
) and the NODE_ENV
.Published by jaydenseric about 6 years ago
New naming that drops “apollo” to reflect the independent and universal nature of the project, fixing #68:
apollo-upload-server
to graphql-upload
.apolloUploadKoa
to graphqlUploadKoa
.apolloUploadExpress
to graphqlUploadExpress
.To migrate you project from [email protected]
to [email protected]
:
npm uninstall apollo-upload-server
.npm install graphql-upload
.apolloUploadKoa
→ graphqlUploadKoa
.apolloUploadExpress
→ graphqlUploadExpress
.Published by jaydenseric about 6 years ago
Published by jaydenseric about 6 years ago
processRequest
function now requires a http.ServerResponse
instance as its second argument.http-errors
and snapshot tested error details, via #105.SPEC_URL
constant.Upload
scalar promises now resolve with a createReadStream
method instead of a stream
property, via #92.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.Upload
scalar variable can now be used by multiple resolvers, via #92.Upload
scalar variables can now use the same multipart data, via #92.operations
or map
multipart fields cause an appropriate error with a 400
status instead of crashing the process, relating to #81 and #95.operations
, map
and files, or just map
and files, cause an appropriate error with a 400
status instead of hanging, fixing #96.GraphQLUpload
scalar description to remove details about how it resolves on the server as they are irrelevant to API users.GraphQLUpload
scalar error messages.npm-run-all
dev dependency and made scripts and tests sync for easier debugging, at the cost of slightly longer build times.processRequest
default options instead of relying on busboy
defaults..yml
files.master
branch.Published by jaydenseric about 6 years ago
Big thanks to new collaborator @mike-marcacci for his help solving tricky bugs and edge-cases!
@babel/runtime
dependency and config.error
event listeners to file streams to prevent server crashes on aborted requests or parser errors.fs-capacitor
to ensure the server doesn’t hang if an upload await
is out of order, or is never consumed.prepare
to support installation via Git (e.g. npm install jaydenseric/apollo-upload-server
).babel.config.js
instead of .babelrc.js
.shippedProposals
in @babel/preset-env
config.tap
instead of ava
. Tests no longer transpile on the fly, are faster and AVA no longer dictates the Babel version..mjs
and .js
files in native ESM (--experimental-modules
) and CJS environments.get-port
dev dependency.package.json
scripts:
npm-run-all
more for parallelism and reduced noise.rimraf
dev dependency in favour of native rm -rf
. Leaner and faster; we only support *nix now for contributing anyway.cross-env
; contributors with Windows may setup and use a Bash shell.ESM
environment variable to BABEL_ESM
to be more specific.eslint-config-env
.eslint-plugin-ava
dev dependency and config..prettierignore
to leave package.json
formatting to npm.description
and keywords
.repository
field.package.json
and rarely changes.changelog.md
version entries now have “Major”, “Minor” and “Patch” subheadings.Published by jaydenseric over 6 years ago
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.eslint-plugin-ava
.package.json
author URL.Published by jaydenseric over 6 years ago
.mjs
, fixing reopened #40.Published by jaydenseric over 6 years ago
--experimental-modules
and .mjs
support, fixing #40.Published by jaydenseric over 6 years ago
Includes all the changes from:
Published by jaydenseric almost 7 years ago
Published by jaydenseric almost 7 years ago
package.json
engines
(v6.10).instanceof
with them.processRequest
to throw MapBeforeOperationsUploadError
and FilesBeforeMapUploadError
errors in middleware.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.scalar Upload
promises reject with a FileMissingUploadError
error.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
.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..babelrc.js
.Published by jaydenseric almost 7 years ago
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
.uploadDir
middleware option.graphql
is now a peer dependency.maxFieldSize
, maxFileSize
and maxFiles
middleware options.Published by jaydenseric almost 7 years ago
.mjs
extension.src
directory.Published by jaydenseric over 7 years ago
Published by jaydenseric over 7 years ago
package-lock.json
. Lockfiles are not recommended for packages.package.json
to prevent issues when consumers run Babel over node_modules
.File
input type Upload
for clarity.Published by jaydenseric over 7 years ago
yarn.lock
and updated install instructions.babel-preset-env
.build:watch
script. Use npm run build -- --watch
directly.Published by jaydenseric over 7 years ago
Published by jaydenseric over 7 years ago
apollo-upload-client
v3 and query batching.Published by jaydenseric over 7 years ago
Published by jaydenseric over 7 years ago