Middleware and an Upload scalar to add support for GraphQL multipart requests (file uploads via queries and mutations) to various Node.js GraphQL servers. Clients implementing the GraphQL multipart request spec upload files as Upload scalar query or mutation variables. Their resolver values are promises that resolve file upload details for processing and storage. Files are typically streamed into cloud storage but may also be stored in the filesystem. Use the middleware graphqlUploadKoa or graphqlUploadExpress just before GraphQL middleware. Alternatively, use the function processRequest to create custom middleware. The process must have both read and write access to the directory identified by os.tmpdir(). The device requires sufficient disk space to buffer the expected number of concurrent upload requests. Promisify and await file upload streams in resolvers or the server will send a response to the client before uploads are complete, causing a disconnect.

Features

  • Handle file upload promise rejection and stream errors
  • Process multiple uploads asynchronously
  • Only use the function createReadStream before the resolver returns
  • The GraphQL multipart request spec allows a file to be used for multiple query or mutation variables fs-capacitor is used to buffer file uploads to the filesystem and coordinate simultaneous reading and writing
  • The npm package graphql-upload features optimal JavaScript module design
  • Middleware and an Upload scalar to add support for GraphQL multipart requests

Project Samples

Project Activity

See All Activity >

License

MIT License

Follow graphql-upload

graphql-upload Web Site

Other Useful Business Software
MongoDB Atlas runs apps anywhere Icon
MongoDB Atlas runs apps anywhere

Deploy in 115+ regions with the modern database for every enterprise.

MongoDB Atlas gives you the freedom to build and run modern applications anywhere—across AWS, Azure, and Google Cloud. With global availability in over 115 regions, Atlas lets you deploy close to your users, meet compliance needs, and scale with confidence across any geography.
Start Free
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of graphql-upload!

Additional Project Details

Programming Language

JavaScript

Related Categories

JavaScript Frameworks, JavaScript Web Development Software

Registered

2022-10-31