Comments (6)
@tbarkley I have not seen someone trying to send GraphQL multipart requests like that before. There is no mention of this GraphQL multipart request spec in the eko/graphql-go-upload repo, so maybe it's not intended to be compliant?
For this spec, the way to do your example (free-hand, there might be typos):
curl http://localhost:8000/graphql \
-F operations='{ "query": "mutation DoUpload($file: Upload!, $title: String!) { upload(file: $file, title: $title) }", "variables": { "file": null, "title": "My content title" } }' \
-F map='{ "file": ["variables.file"] }' \
-F [email protected] \
Only file variables should be extracted into separate multipart file fields.
As for the general question of purposely sending extraneous multipart form fields, that is something I can't recall discussing; probably it was considered but in all these years we never encountered a use case. If such custom fields were to go anywhere, maybe at the end after the files? I'm not sure from memory what graphql-upload
will do if it encounters non file fields after all the expected file fields.
I think an extraneous file field after operations
and map
will be safely ignored:
Although, they will still count for the maxFiles
setting:
Potentially the wording of the spec could be updated, saying that operations
, map
, and mapped file fields must be in that order, but can have extraneous fields before, after or interspersed and that they should be ignored by server implementations. For performance though, the first fields should be operations
and map
so that resolvers can be run sooner.
from graphql-multipart-request-spec.
Thank you @jaydenseric for the explanation and help.
from graphql-multipart-request-spec.
This repo is for maintaining a specification, it sounds like you have a usage question about a particular (unspecified) implementation.
It looks like you are using the GraphQLUpload
scalar from a reasonably modern graphql-upload
version, probably your issue is that in variables
on the client you are using a File
incorrectly for your name
variable; probably you meant for the name to be a string. Also, run npm ls graphql-upload
and make sure you only have one version installed.
from graphql-multipart-request-spec.
No, Im tryng send other arg with the file. But dont work, and i try all types specifications and dont work.
from graphql-multipart-request-spec.
@jaydenseric thank you for your work, could you please clarify or reference how extra form data should be sent? I saw this example and was trying to do the same but not sure of the correct way;
https://medium.com/@vcomposieux/handle-file-uploads-using-a-graphql-middleware-11914ba05bfc
$ curl http://localhost:8000/graphql
-F operations='{ "query": "mutation DoUpload($file: Upload!, $title: String!) { upload(file: $file, title: $title) }",
"variables": { "file": null, "title": null } }'
-F map='{ "file": ["variables.file"], "title": ["variables.title"] }'
-F [email protected]
-F title="My content title
from graphql-multipart-request-spec.
For people only reading emails, I made a correction to my previous comment in an edit.
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
- 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
- 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.