graphql-upload adds an Upload scalar and middleware so Node.js GraphQL servers accept multipart requests. Clients send files as mutation or query variables per the multipart request spec.
Overview
graphql-upload is a Node.js library that implements file uploads for GraphQL servers following the GraphQL multipart request specification. It supplies middleware for common HTTP frameworks and an Upload scalar for schema authors.
Clients map uploaded files to GraphQL variables; resolvers receive promises that resolve to file metadata and streams for storage or processing. Middleware parses multipart bodies, wires Upload placeholders into operations, and passes executed queries to the GraphQL layer. Express and Koa integrations are provided, and a lower-level processRequest helper supports custom stacks.
The design handles deduplicated files, multiple variables referencing one upload, and concurrent resolver access through filesystem buffering. Uploaded streams are coordinated so resolvers can read independent streams from buffered content until the response completes.
The package ships as ES modules with deep imports for the scalar, middleware, and request processor. It expects a peer dependency on graphql and is commonly composed with schema tools that declare the Upload scalar in SDL.
Key features
- Upload scalar for GraphQL schemas
- Express and Koa middleware
- Multipart request spec support
- Custom middleware via processRequest
- Stream-based resolver file access
- Concurrent upload stream coordination
- ES module deep imports
- graphql peer dependency
Use cases
- File uploads through GraphQL mutations
- Node.js GraphQL server multipart support
- Express or Koa GraphQL APIs with files
- Cloud or filesystem upload pipelines
- Custom GraphQL HTTP middleware stacks