Sha256: 6b35fe000d13056399235b5a4824cffda386f23b9daa8caf4f00a9996e3ed77a

Contents?: true

Size: 1.4 KB

Versions: 15

Compression:

Stored size: 1.4 KB

Contents

# File uploads example

This example demonstrates uploading files via the [GraphQL Upload spec](https://github.com/jaydenseric/graphql-multipart-request-spec).

Try running it:

```shell
cd examples/file_uploads
bundle install
foreman start
```

This example is headless, but you can verify the stitched schema is running by querying a field from each graph location:

```shell
curl -X POST http://localhost:3000 \
  -H 'Content-Type: application/json' \
  -d '{"query":"{ gateway remote }"}'
```

Now try submitting a multipart form upload with a file attachment, per the [spec](https://github.com/jaydenseric/graphql-multipart-request-spec?tab=readme-ov-file#curl-request). The response will echo the uploaded file contents:

```shell
curl http://localhost:3000 \
  -H 'Content-Type: multipart/form-data' \
  -F operations='{ "query": "mutation ($file: Upload!) { gateway upload(file: $file) }", "variables": { "file": null } }' \
  -F map='{ "0": ["variables.file"] }' \
  -F 0=@file.txt
```

This workflow has:

1. Submitted a multipart form to the stitched gateway.
2. The gateway server unpacked the request using [apollo_upload_server](https://github.com/jetruby/apollo_upload_server-ruby).
3. Stitching delegated the `upload` field to its appropraite subgraph location.
4. `HttpExecutable` has re-encoded the subgraph request into a multipart form.
5. The subgraph location has recieved, unpacked, and resolved the uploaded file.

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
graphql-stitching-1.6.0 examples/file_uploads/README.md
graphql-stitching-1.5.2 examples/file_uploads/README.md
graphql-stitching-1.5.1 examples/file_uploads/README.md
graphql-stitching-1.5.0 examples/file_uploads/README.md
graphql-stitching-1.4.3 examples/file_uploads/README.md
graphql-stitching-1.4.2 examples/file_uploads/README.md
graphql-stitching-1.4.1 examples/file_uploads/README.md
graphql-stitching-1.4.0 examples/file_uploads/README.md
graphql-stitching-1.3.0 examples/file_uploads/README.md
graphql-stitching-1.2.5 examples/file_uploads/README.md
graphql-stitching-1.2.4 examples/file_uploads/README.md
graphql-stitching-1.2.3 examples/file_uploads/README.md
graphql-stitching-1.2.2 examples/file_uploads/README.md
graphql-stitching-1.2.1 examples/file_uploads/README.md
graphql-stitching-1.2.0 examples/file_uploads/README.md