Comments (4)
Thank you very much, your idea for making a new request in the resolver with the right field structure worked. Thanks! Best Regards!
from graphql-multipart-request-spec.
The spec has this to say on the naming of the file fields that follow the operations
and map
fields:
File fields: Each file extracted from the operations object with a unique, arbitrary field name.
— https://github.com/jaydenseric/graphql-multipart-request-spec#multipart-form-field-structure
You can use whatever you like for a file field name, as long as it's unique and valid for a HTTP multipart request.
I can't think of a good reason to go to trouble to create special names instead of just using a simple number sequence, but maybe you have a clever idea in mind.
from graphql-multipart-request-spec.
The reason for this question is that the payload is forwarded from the graphql server to a 2rd server which is expecting name="files" not name="0" and it gives 500 Internal server error.
If the same file is sent via REST the payload is:
Content-Disposition: form-data; name="files"; filename="a.txt"
Content-Type: text/plain
where the name="files" comes from <input name="files />
it does not change it to name="0"
So if there is a workaround it would be appreciated. Thanks!
from graphql-multipart-request-spec.
So if there is a workaround it would be appreciated.
Regarding the spec, no "workaround" is needed - what you want to do is perfectly valid.
The backend, or at least a spec-compliant implementation such as graphql-upload
, should be fine out of the box.
How to get the client to send the first file field with the files
name you want depends on the client. If you are using apollo-upload-client
, there is no option to configure file field names so you might need to fork it and hardcode what you like:
It seems a bit fragile to be forking things and hardcoding field names though; I'm not familiar enough with your infrastructure to comment on a better architecture but it could probably do with a redesign.
the payload is forwarded from the graphql server to a 2rd server
Why don't you forward the upload in your singleUpload
mutation resolver? Then you can construct a new request to your other server with whatever field structure you like. That way you don't need a special naming of fields in the original GraphQL multipart request.
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
- 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.