Comments (2)
It looks like version 3 of graphql-upload (apollo-upload-server) introduced v2 of the spec, which means that you will have to deal with a field name change and a change in field ordering. From the perspective of the spec, this is a breaking change. It was released only a couple months after the first version was published, so I suspect that a migration path was not an important criteria (and honestly this is the first case of this that I've seen in the many years I've been following this).
The only real solution here without updating the clients is to add a layer that detects and translates the spec v1 request into a v2 spec request. You mentioned you're using the JS libraries so this should be quite practical to do, but certainly isn't trivial:
- detect a multipart GraphQL request
- take ownership of the request stream without yet calling
graphql-upload
- create a new stream in place of the real request stream
- begin consuming the request stream, buffering its contents into memory
- if you detect that the first part is named
operations
you know you have a v2 spec request:- replay the contents from your buffer into your replacement stream
- pipe the rest of the request stream into your replacement stream
- allow
graphql-upload
to proceed as normal
- if you detect that the first part is named
files
you know you have a v1 spec request:- buffer the entire
files
part into a new memory buffer - once you detect the second part (which should be named
operations
) send any contents from the initial buffer and begin streaming the contents of theoperations
part to your replacement stream - once the end of the
operations
part is reached, immediately replay the contents of thefiles
buffer into the replacement stream - pipe the remainder of the request into your replacement stream
- allow
graphql-upload
to proceed as normal
- buffer the entire
Again, this is non-trivial and probably represents a solid couple days of work, but is certainly doable if the scale of your operation demands it. This is obviously out of scope for the project at this point, but best of luck!
from graphql-multipart-request-spec.
It's a tricky situation; I've answered over here:
jaydenseric/graphql-upload#227 (comment)
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
- 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
- README graphic is *somewhat* misleading regarding buffering HOT 2
- 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.