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 visible (Hide)
Published by jaydenseric 11 days ago
Updated Node.js support to ^18.18.0 || ^20.9.0 || >=22.0.0
.
Updated dev dependencies, some of which require newer Node.js versions than previously supported.
Use the TypeScript v5.5+ JSDoc tag @import
to import types in modules.
Removed JSDoc tag @typedef
that were unintentionally re-exporting types; to migrate import TypeScript types from the correct module:
- import type { GraphQLUpload } from "graphql-upload/Upload.mjs";
+ import type GraphQLUpload from "graphql-upload/GraphQLUpload.mjs";
- import type { processRequest } from "graphql-upload/Upload.mjs";
+ import type processRequest from "graphql-upload/processRequest.mjs";
- import type { GraphQLUpload } from "graphql-upload/processRequest.mjs";
+ import type GraphQLUpload from "graphql-upload/GraphQLUpload.mjs";
Refactored tests to use the standard AbortController
, fetch
, File
, and FormData
APIs available in modern Node.js and removed the dev dependencies node-abort-controller
and node-fetch
.
Replaced the test utility function streamToString
with the function text
from node:stream/consumers
that’s available in modern Node.js.
Use the Node.js test runner API and remove the dev dependency test-director
.
@types/express
to 4.0.29 - 5
and the dev dependency express
to v5, via #389.package.json
field repository
to conform to new npm requirements.npm run
with node --run
.npm run
with node --run
.actions/checkout
to v4.actions/setup-node
to v4.eslint-plugin-jsdoc
and revised types.--unhandled-rejections=throw
in the package script tests
as it’s now the default for all supported Node.js versions.FileUploadCreateReadStreamOptions
property highWaterMark
description and use the function getDefaultHighWaterMark
from node:stream
in tests.Deferred
with polyfilled Promise.withResolvers
.await
in tests.processRequest
.FileUploadCreateReadStreamOptions
in the module processRequest.mjs
.return
in the middleware.async-listen
to replace the test utility function listen
.noUnusedLocals
and noUnusedParameters
and used the prefix _
for purposefully unused function parameters in tests.node:
URL scheme for Node.js builtin module imports.GraphQLUpload.mjs
.Published by jaydenseric about 2 years ago
Published by jaydenseric about 2 years ago
Updated the fs-capacitor
dependency to v8, fixing #318.
The type FileUploadCreateReadStreamOptions
from the processRequest.mjs
module now uses types from fs-capacitor
that are slightly more specific.
The API is now ESM in .mjs
files instead of CJS in .js
files, accessible via import
but not require
. To migrate imports:
- import GraphQLUpload from "graphql-upload/GraphQLUpload.js";
+ import GraphQLUpload from "graphql-upload/GraphQLUpload.mjs";
- import graphqlUploadExpress from "graphql-upload/graphqlUploadExpress.js";
+ import graphqlUploadExpress from "graphql-upload/graphqlUploadExpress.mjs";
- import graphqlUploadKoa from "graphql-upload/graphqlUploadKoa.js";
+ import graphqlUploadKoa from "graphql-upload/graphqlUploadKoa.mjs";
- import processRequest from "graphql-upload/processRequest.js";
+ import processRequest from "graphql-upload/processRequest.mjs";
- import Upload from "graphql-upload/Upload.js";
+ import Upload from "graphql-upload/Upload.mjs";
Published by jaydenseric over 2 years ago
ctx
parameter for the Koa middleware created by the function graphqlUploadKoa
, from import("koa").Context
to import("koa").ParameterizedContext
.Published by jaydenseric over 2 years ago
graphqlUploadExpress.js
and graphqlUploadKoa.js
within the module processRequest.js
, fixing #314.Published by jaydenseric over 2 years ago
busboy
dependency to v1, fixing #311.
processRequest
and the middleware graphqlUploadExpress
and graphqlUploadKoa
the option maxFileSize
is actually 1 byte less than the amount specified.typescript
dev dependency.processRequest
use the on
method instead of once
to listen for error
events on the busboy
parser, as in edge cases the same parser could have multiple error
events and all must be handled to prevent the Node.js process exiting with an error.processRequest
.processRequest
with a maliciously malformed multipart request.Published by jaydenseric over 2 years ago
Updated Node.js support to ^14.17.0 || ^16.0.0 || >= 18.0.0
.
Updated the graphql
peer dependency to ^16.3.0
.
Updated the http-errors
dependency to v2.
Public modules are now individually listed in the package files
and exports
fields.
Removed the package main index module; deep imports must be used. To migrate imports:
- import { GraphQLUpload } from "graphql-upload";
+ import GraphQLUpload from "graphql-upload/GraphQLUpload.js";
- import { graphqlUploadExpress } from "graphql-upload";
+ import graphqlUploadExpress from "graphql-upload/graphqlUploadExpress.js";
- import { graphqlUploadKoa } from "graphql-upload";
+ import graphqlUploadKoa from "graphql-upload/graphqlUploadKoa.js";
- import { processRequest } from "graphql-upload";
+ import processRequest from "graphql-upload/processRequest.js";
- import { Upload } from "graphql-upload";
+ import Upload from "graphql-upload/Upload.js";
Shortened public module deep import paths, removing the /public/
. To migrate imports:
- import GraphQLUpload from "graphql-upload/public/GraphQLUpload.js";
+ import GraphQLUpload from "graphql-upload/GraphQLUpload.js";
- import graphqlUploadExpress from "graphql-upload/public/graphqlUploadExpress.js";
+ import graphqlUploadExpress from "graphql-upload/graphqlUploadExpress.js";
- import graphqlUploadKoa from "graphql-upload/public/graphqlUploadKoa.js";
+ import graphqlUploadKoa from "graphql-upload/graphqlUploadKoa.js";
- import processRequest from "graphql-upload/public/processRequest.js";
+ import processRequest from "graphql-upload/processRequest.js";
- import Upload from "graphql-upload/public/Upload.js";
+ import Upload from "graphql-upload/Upload.js";
Implemented TypeScript types via JSDoc comments, closing #282.
The GraphQLUpload
scalar no longer uses deprecated GraphQLError
constructor parameters.
types
script.jsdoc-md
dev dependency and the related package scripts, replacing the readme “API” section with a manually written “Exports” section.hard-rejection
dev dependency. Instead, tests are run with the Node.js CLI flag --unhandled-rejections=throw
to make Node.js v14 behave like newer versions.formdata-node
dev dependency. Instead, File
and FormData
are imported from node-fetch
.actions/checkout
to v3.actions/setup-node
to v3..js
file extension in require
paths.Readable
property readableEncoding
instead of _readableState.encoding
in tests.substring
instead of the deprecated string method substr
in tests.license.md
MIT License file, closing #86.Published by jaydenseric almost 3 years ago
^12.22.0 || ^14.17.0 || >= 16.0.0
../package
from the package exports
field; the full package.json
filename must be used in a require
path.graphql
peer dependency to 0.13.1 - 16
.processRequest
function with a GraphQL multipart request that has no files.processRequest
function with an unparsable multipart request.form-data
dev dependency with formdata-node
, formdata-node
, and node-abort-controller
and refactored tests to align with web standards.processRequest
function to remove the isobject
dependency.processRequest
function, via #273:
Upload
scalar value createReadStream
method:
error
event when the multipart request is aborted certain ways while the file is uploading.error
event details for multipart request file field parse errors.singleQuote
to the default, false
.Published by jaydenseric over 3 years ago
^12.20 || >= 14.13
..mjs
files instead of CJS in .js
files.package.json
exports
field public subpath folder mapping (deprecated by Node.js) with a subpath pattern. Deep require
paths must now include the .js
file extension.sideEffects
field.actions/checkout
to v2.actions/setup-node
to v2.npm install-test
command.CI
environment variable as it’s set by default.npm-debug.log
from the .gitignore
file as npm v4.2.0+ doesn’t create it in the current working directory.keywords
field.main
field path.jsdoc-md
v10 automatically generates a Prettier formatted readme.test:jsdoc
script that checks the readme API docs are up to date with the source JSDoc.GraphQLUpload
code example to use @graphql-tools/schema
instead of graphql-tools
.apollo-upload-server
.Published by jaydenseric over 4 years ago
^10.13.0 || ^12.0.0 || >= 13.7.0
.exports
field with conditional exports to support native ESM in Node.js and keep internal code private, whilst avoiding the dual package hazard. Published files have been reorganized, so previously undocumented deep imports will need to be rewritten according to the newly documented paths.graphql
peer dependency to 0.13.1 - 15
, fixing #200 via #201.semi
to the default, true
.ignoreStream
function tests for Node.js v14 with a new CountReadableStream
test helper, fixing #209.Promise.allSettled
in the readme “Tips” section.Published by jaydenseric over 4 years ago
fs-capacitor
dependency to v6, which now requires Node.js v10+, via #179.tap
dev dependency with test-director
, coverage-node
, and 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+.processRequest
function.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 via #181.GraphQLUpload
scalar parseLiteral
and serialize
methods now throw GraphQLError
(instead of Error
) instances, with tweaked messages.createReadStream
function in resolved file uploads now accepts options to configure the encoding and high water mark, fixing #177 via #179.eslint-plugin-import-order-alphabetical
and express-async-handler
dev dependencies.husky
and lint-staged
.isobject
for checking if values are enumerable, non-array objects.GraphQLUpload
scalar.ignoreStream
function.Upload
class to its own file.Upload
class instance property file
.Upload
class.FileUpload
typedef description.eslint-disable-next-line
comments.Published by jaydenseric almost 5 years ago
eslint
dev dependency now supports. This is unlikely to be a breaking change for the published package.Upload
scalar promise resolved stream
property that has been deprecated since v7, along with associated tests.fs-capacitor
dependency to v4 to support Node.js v13, making required changes to the source and tests, via #166..github/funding.yml
to display a sponsor button in GitHub.package.json
funding
field to enable npm CLI funding features..nycrc.json
file:
tap
now ignores test files by default.lib/test-helpers
directory is now ignored using tap
CLI arguments due to tapjs/node-tap#612.esm
and mjs
package tags; they will be added back once native ESM is properly supported.fs-capacitor
implementation details such as temp file creation and cleanup.istanbul ignore next
comments.Published by jaydenseric about 5 years ago
processRequest
now throws an appropriate error when a multipart field value exceeds the configured size limit, fixing #159.processRequest
option to the graphqlUploadExpress
and graphqlUploadKoa
middleware, for improved testing without mocks or spies which are difficult to achieve with ESM.eslint-disable-next-line
comments, and regenerated the readme.koa-graphql
as known to be compatible, via #156.package-lock.json
from .gitignore
and .prettierignore
, as it’s disabled in .npmrc
anyway.export * from
) to prevent accidental public exposure of internal APIs.isObject
helper with a smarter and tested isEnumerableObject
.isString
helper.processRequest
internals and tests (including a new test using vanilla Node.js HTTP), fixing #130 via #162.startServer
test helper.ProcessRequestFunction
JSDoc type, and applied it to processRequest
.UploadOptions
JSDoc type to ProcessRequestOptions
.Published by jaydenseric over 5 years ago
map
multipart field entries, fixing #154.WriteStream
from fs-capacitor
as a named rather than default import.Published by jaydenseric over 5 years ago
JSON.stringify
.express-async-handler
for Express tests.maxFiles
config in certain tests.Published by jaydenseric over 5 years ago
operations
type.map
type.map
entry type.map
entry array item type.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
.watch
dev dependency and watch
script.prepublishOnly
script.classic
TAP reporter for tests.apollo-server-koa
and apollo-server-express
back to the compatible environments list in the readme, now that they use the current version of this package.Published by jaydenseric almost 6 years ago
fs-capacitor
dependency to v2, fixing #131 via #132.Published by jaydenseric almost 6 years ago
busboy
update contains a bug fix for .pipe()
on file streams.Published by jaydenseric almost 6 years ago