~sircmpwn/sr.ht-discuss

2 2

GraphQL rejects array -F operations=, but accepts objectified array, but rejects -F map= paths?

Details
Message ID
<20221031231236.c7waexidmb7n7g2x@tarta.nabijaczleweli.xyz>
DKIM signature
pass
Download raw message
Hi!

Far be it from me to be a GraphQL expert, but
  https://man.sr.ht/graphql.md#uploading-files
says
> Some GraphQL resolvers accept file uploads, via the Upload type. Our
> implementation is compatible with the GraphQL multipart request
> specification.

And following that link, I've gotten the following to work:
-- >8 --
$ curl -F operations='{
  "query": "mutation($file: Upload!) {uploadArtifact(repoId: 210654, revspec: \"test\", file: $file) { id, created, filename, checksum } }",
  "variables": { "file": null }
}' -F map='{
  "a": ["variables.file"]
}' -F a=@a https://git.sr.ht/query  | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   767  100   179  100   588    239    788 --:--:-- --:--:-- --:--:--  1028
{
  "data": {
    "uploadArtifact": {
      "id": 3234,
      "created": "2022-10-31T22:55:20.534686Z",
      "filename": "a",
      "checksum": "sha256:87428fc522803d31065e7bce3cf03fe475096631e5e07bbd7a0fde60c4cf25c7"
    }
  }
}
-- >8 --

This is great! However, 
  https://github.com/jaydenseric/graphql-multipart-request-spec#batching
delineates how to upload multiple files in a request.
Following this, I arrived at:
-- >8 --
$ curl -F operations='[
  {
    "query": "mutation($file: Upload!) {uploadArtifact(repoId: 210654, revspec: \"test\", file: $file) { id, created, filename, checksum } }",
    "variables": { "file": null }
  },
  {
    "query": "mutation($file: Upload!) {uploadArtifact(repoId: 210654, revspec: \"test\", file: $file) { id, created, filename, checksum } }",
    "variables": { "file": null }
  }
]' -F map='{
  "a": [
    "0.variables.file"
  ],
  "b": [
    "1.variables.file"
  ]
}' -F a=@a -F b=@b https://git.sr.ht/query  | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1062  100    81  100   981    196   2375 --:--:-- --:--:-- --:--:--  2565
{
  "errors": [
    {
      "message": "operations form field could not be decoded"
    }
  ],
  "data": null
}
-- >8 --

Hm. This is the same message you get when you make -Foperations= invalid
JSON, but I'm pretty sure (and jq(1) agrees) that it's valid, so..?

On a hunch, I tried spelling it
-- >8 --
{
  "0": {
    "query": "mutation($file: Upload!) {uploadArtifact(repoId: 210654, revspec: \"test\", file: $file) { id, created, filename, checksum } }",
    "variables": { "file": null }
  },
  "1": {
    "query": "mutation($file: Upload!) {uploadArtifact(repoId: 210654, revspec: \"test\", file: $file) { id, created, filename, checksum } }",
    "variables": { "file": null }
  }
}
-- >8 --
and that works, at least insofar as I got "invalid operations paths for
key a" instead. If this is the correct spelling of the operations (and
the one in the "spec" isn't), what's the path?

Please advise,
наб
Details
Message ID
<CO0TU6VLKGNN.OJ1XQDDVKUJW@taiga>
In-Reply-To
<20221031231236.c7waexidmb7n7g2x@tarta.nabijaczleweli.xyz> (view parent)
DKIM signature
pass
Download raw message
Not sure at a glance (I am not particularly good at decoding esoteric
curl invocations), but you may want to double check the spec against the
implementation we use and file a ticket with whoever appears to be in
the wrong.
Details
Message ID
<20221105221524.zxi2tkibxg75s6lc@tarta.nabijaczleweli.xyz>
In-Reply-To
<CO0TU6VLKGNN.OJ1XQDDVKUJW@taiga> (view parent)
DKIM signature
pass
Download raw message
Control: forwarded -1 https://github.com/99designs/gqlgen/issues/2416

On Tue, Nov 01, 2022 at 09:47:06AM +0100, Drew DeVault wrote:
> Not sure at a glance (I am not particularly good at decoding esoteric
> curl invocations), but you may want to double check the spec against the
> implementation we use and file a ticket with whoever appears to be in
> the wrong.

Seems it's fully in gqlgen's ball-park, since even their example server
explodes on this. Stellar UX.

наб
Reply to thread Export thread (mbox)