Comments (14)
@lunchboxer Here is an example, I copied from Postman. ^_^
curl -X POST \
http://localhost:3001/graphql \
-H 'Cache-Control: no-cache' \
-H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
-F 'operations={"query":"mutation ($files: [Upload!]!) {multipleUpload(files: $files) {id filename encoding mimetype path __typename}}","variables":{}}' \
-F 'map={"0":["variables.files.0"],"1":["variables.files.1"]}' \
-F '"0"=@/Users/giautm/Devel/IMG_0636.JPG' \
-F '"1"=@/Users/giautm/Devel/IMG_0637.JPG'
Ps: Replace files 0
, 1
path with your files.
from graphql-multipart-request-spec.
In the meantime, you might find the apollo-upload-server
tests to be a handy reference.
from graphql-multipart-request-spec.
Done! The examples now match those of apollo-upload-examples, and they each display a cURL request.
from graphql-multipart-request-spec.
im getting:
Error: Must provide document
at invariant (/app/node_modules/graphql/jsutils/invariant.js:19:11)
at Object.validate (/app/node_modules/graphql/validation/validate.js:59:34)
at doRunQuery (/app/node_modules/apollo-server-core/src/runQuery.ts:137:30)
at /app/node_modules/apollo-server-core/src/runQuery.ts:70:39
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:228:7)
when executing curl
any idea? @jaydenseric
from graphql-multipart-request-spec.
@gustavomc No solid ideas, but are you sure apollo-upload-server
is setup correctly?
from graphql-multipart-request-spec.
I am getting below error with above curl command
curl -X POST \
http://localhost:3001/graphql \
-H 'Cache-Control: no-cache' \
-H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
-F 'operations={"query":"mutation ($files: [Upload!]!) {multipleUpload(files: $files) {id filename encoding mimetype path __typename}}","variables":{}}' \
-F 'map={"0":["variables.files.0"],"1":["variables.files.1"]}' \
-F '"0"=@/Users/giautm/Devel/IMG_0636.JPG' \
-F '"1"=@/Users/giautm/Devel/IMG_0637.JPG'
{"errors":[{"message":"GraphQL Request must include at least one of those two parameters: "query" or "queryId"","category":"request"}]}
from graphql-multipart-request-spec.
@gohelkiran30 that might be because the server is not configured to handle multipart requests. Have you setup the apollo-upload-server
middleware?
from graphql-multipart-request-spec.
I havn't used any middleware, I am firing a request from console using a curl command hence no middleware required.
from graphql-multipart-request-spec.
The GraphQL server that you are sending the request to (http://localhost:3001/graphql) needs to support GraphQL multipart requests, typically via middleware. Comments in existing issues in this repo is not the right place to asking such usage questions.
from graphql-multipart-request-spec.
ok, I will create a new issue
thanks
from graphql-multipart-request-spec.
@gustavomc
I'm running into the same issue. Any luck solving this one? Thanks a lot!
from graphql-multipart-request-spec.
@gohelkiran30 @giautm I noticed you both are using "variables":{}
in a multipleUpload
query. This didn't work for me, I get this error:
file-upload> curl localhost:4000 \
-F operations='{ "query": "mutation ($files: [Upload!]!) { multipleUpload(files: $files) { id } }", "variables": { } }' \
-F map='{ "0": ["variables.file.0"], "1": ["variables.file.1"] }' \
-F [email protected] \
-F [email protected]
{"errors":[{"message":"Variable \"$files\" of required type \"[Upload!]!\" was not provided.","locations":[{"line":1,"column":11}]}]}⏎
and actually in the curl example given, you can remove the variable part for singleUpload
and it'll still work
file-upload> curl localhost:4000 \
-F operations='{ "query": "mutation ($file: Upload!) { singleUpload(file: $file) { id } }" }' \
-F map='{ "0": ["variables.file"] }' \
-F [email protected]
{"data":{"singleUpload":{"id":"TLoQ9s44G"}}}⏎
but multipleUpload
won't
file-upload> curl localhost:4000 \
-F operations='{ "query": "mutation ($files: [Upload!]!) { multipleUpload(files: $files) { id } }" }' \
-F map='{ "0": ["variables.file.0"], "1": ["variables.file.1"] }' \
-F [email protected] \
-F [email protected]
{"errors":[{"message":"Variable \"$files\" of required type \"[Upload!]!\" was not provided.","locations":[{"line":1,"column":11}]}]}⏎
from graphql-multipart-request-spec.
@sunapi386 follow the example in the spec: https://github.com/jaydenseric/graphql-multipart-request-spec#curl-request-1
from graphql-multipart-request-spec.
@jaydenseric my bad, I mistyped variables.file.1
when it should have been variables.files.1
Very subtle error.
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
- 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.