Giter VIP home page Giter VIP logo

Comments (14)

giautm avatar giautm commented on June 11, 2024 8

@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.

jaydenseric avatar jaydenseric commented on June 11, 2024

In the meantime, you might find the apollo-upload-server tests to be a handy reference.

from graphql-multipart-request-spec.

jaydenseric avatar jaydenseric commented on June 11, 2024

Done! The examples now match those of apollo-upload-examples, and they each display a cURL request.

from graphql-multipart-request-spec.

gustavomc avatar gustavomc commented on June 11, 2024

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.

jaydenseric avatar jaydenseric commented on June 11, 2024

@gustavomc No solid ideas, but are you sure apollo-upload-server is setup correctly?

from graphql-multipart-request-spec.

gohelkiran30 avatar gohelkiran30 commented on June 11, 2024

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.

jaydenseric avatar jaydenseric commented on June 11, 2024

@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.

gohelkiran30 avatar gohelkiran30 commented on June 11, 2024

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.

jaydenseric avatar jaydenseric commented on June 11, 2024

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.

gohelkiran30 avatar gohelkiran30 commented on June 11, 2024

ok, I will create a new issue
thanks

from graphql-multipart-request-spec.

yfyfyfyfyfyf avatar yfyfyfyfyfyf commented on June 11, 2024

@gustavomc
I'm running into the same issue. Any luck solving this one? Thanks a lot!

from graphql-multipart-request-spec.

sunapi386 avatar sunapi386 commented on June 11, 2024

@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.

jaydenseric avatar jaydenseric commented on June 11, 2024

@sunapi386 follow the example in the spec: https://github.com/jaydenseric/graphql-multipart-request-spec#curl-request-1

from graphql-multipart-request-spec.

sunapi386 avatar sunapi386 commented on June 11, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.