Comments (2)
Closing as per the answer above, #68 (comment) .
from graphql-multipart-request-spec.
It's a bit tricky to communicate the nuances in a single graphic, but the general idea of the graphic is that there tends to be two distinct approaches for file upload middleware:
- The middleware awaits all the files to have finished uploading, and it stores them all somewhere. Once that is done, the middleware hands-off to the next middleware metadata about all the received files (typically a list of filesystem paths to where they are all stored). This is the "sync" scenario in the graphic. This is how a lot of the Express and Koa middleware (not specific to GraphQL requests) for processing multipart request file uploads available on npm works.
- The middleware passes a promise for each file upload stream on to the next middleware. How that is achieved under the hood varies;
graphql-upload
does in fact buffer each of the streams to the filesystem usingfs-capacitor
, but that's an implementation detail that doesn't render the timings in the graphic as inaccurate. There is the alternative packagegraphql-upload-minimal
that achieves a similar API, but it doesn't buffer the file upload streams to disk; it really works as you would intuit from the graphic. The raw file upload streams are passed onto the next middleware as promises. The downside with that naive approach is that you can't have same file referenced twice in a GraphQL query/mutation, because the resolvers for each place it's used would compete to consume the same readable stream.
I think it should be made clearer that this is a limitation of multipart, you just can't get concurrent streams of files.
The graphic doesn't show the file streams happening in parallel though; they are received one after another in the timeline. The main difference between the “sync” and “async” scenarios is when the resolvers run.
Do you have a specific suggestion for rewording a particular part of the graphic?
The main purpose of that graphic is to get people to consider some of the technical requirements for achieving the “async” scenario, that justify the spec mandated fields like map
.
from graphql-multipart-request-spec.
Related Issues (20)
- createReadStream is not a function HOT 1
- Request payload has no file content HOT 1
- Variable * got invalid value {}; String cannot represent a non string value: {} HOT 5
- ‘operations’ multipart field HOT 4
- I cant send one file and other data, like a string. HOT 6
- Ordered fields? HOT 1
- `map` field in context of backward compatibility HOT 2
- Payload modification HOT 4
- Simple alternative if you are not tied to the JS graphql ecosystem. HOT 3
- Spec Improvement for the broader GraphQL Ecosystem HOT 4
- Switch to the JSON Pointer standard for `map` field operations paths HOT 2
- Where I am wrong when I am using axios to upload file, Please help me. HOT 2
- You have to solve my problem. Please help me. HOT 3
- In your example you only show not nullable file upload system? HOT 1
- Issues with multiple file list example? HOT 3
- Conside using JsonPath for defining fiile field path. HOT 2
- Not able to upload image from React Ant to Node.js server via GraphQL HOT 1
- Not able to upload image from React Ant to Node.js server via GraphQL HOT 1
- Content-Length or arbitrary headers HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphql-multipart-request-spec.