graphlient 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +29 -0
- data/.github/workflows/danger.yml +20 -0
- data/.github/workflows/rubocop.yml +19 -0
- data/CHANGELOG.md +25 -20
- data/README.md +1 -2
- data/lib/graphlient/client.rb +1 -1
- data/lib/graphlient/version.rb +1 -1
- data/spec/graphlient/client_query_spec.rb +33 -3
- data/spec/support/mutations/create_invoice.rb +1 -0
- data/spec/support/queries/query.rb +23 -0
- data/spec/support/types/invoice_type.rb +6 -0
- metadata +6 -4
- data/.travis.yml +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b777ec75d94d228faa748cadb28c1687b16a377892138a9fc8d1048773b8853
|
4
|
+
data.tar.gz: a3bc9f948ffa5c4fe6368282834b7cd4e7addc00b7d1c90ced575ce41e8a8b3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc0080c0fab50ac5ecee6815fb24e6b216cba32558d010ebd3d9661581b55f3b3fca8b70e11f0e61f96eb471931645c12b3a3b8c2361909da31a15c650ab6bcb
|
7
|
+
data.tar.gz: feb39198706b8b9650da8f6f35f080744df668420d948f2b7d69d84dd3b812301542d5735d1a69f77d865706e5853703861fe440a1ab47ea2cfef3b91712f794
|
@@ -0,0 +1,29 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
permissions:
|
6
|
+
contents: read
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
test:
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
strategy:
|
12
|
+
matrix:
|
13
|
+
entry:
|
14
|
+
- { ruby: 2.7.2 }
|
15
|
+
- { ruby: 3.0.0 }
|
16
|
+
- { ruby: 3.1.2 }
|
17
|
+
- { ruby: "ruby-head", ignore: true }
|
18
|
+
- { ruby: "jruby-9.1.17", ignore: true }
|
19
|
+
- { ruby: "jruby-head", ignore: true }
|
20
|
+
steps:
|
21
|
+
- uses: actions/checkout@v3
|
22
|
+
- name: Set up Ruby
|
23
|
+
uses: ruby/setup-ruby@v1
|
24
|
+
with:
|
25
|
+
ruby-version: ${{ matrix.entry.ruby }}
|
26
|
+
bundler-cache: true
|
27
|
+
- name: Run tests
|
28
|
+
continue-on-error: ${{ matrix.entry.ignore || false }}
|
29
|
+
run: bundle exec rspec spec/
|
@@ -0,0 +1,20 @@
|
|
1
|
+
name: Danger
|
2
|
+
|
3
|
+
on: pull_request
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
danger:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
steps:
|
9
|
+
- uses: actions/checkout@v3
|
10
|
+
with:
|
11
|
+
fetch-depth: 0
|
12
|
+
- name: Set up Ruby
|
13
|
+
uses: ruby/setup-ruby@v1
|
14
|
+
with:
|
15
|
+
ruby-version: 2.7.2
|
16
|
+
bundler-cache: true
|
17
|
+
- run: |
|
18
|
+
# the personal token is public, this is ok, base64 encode to avoid tripping Github
|
19
|
+
TOKEN=$(echo -n NWY1ZmM5MzEyMzNlYWY4OTZiOGU3MmI3MWQ3Mzk0MzgxMWE4OGVmYwo= | base64 --decode)
|
20
|
+
DANGER_GITHUB_API_TOKEN=$TOKEN bundle exec danger --verbose
|
@@ -0,0 +1,19 @@
|
|
1
|
+
name: Rubocop
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
permissions:
|
6
|
+
contents: read
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
rubocop:
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
steps:
|
12
|
+
- uses: actions/checkout@v3
|
13
|
+
- name: Set up Ruby
|
14
|
+
uses: ruby/setup-ruby@v1
|
15
|
+
with:
|
16
|
+
ruby-version: 2.7.2
|
17
|
+
bundler-cache: true
|
18
|
+
- name: Run rubocop
|
19
|
+
run: bundle exec rubocop
|
data/CHANGELOG.md
CHANGED
@@ -1,74 +1,79 @@
|
|
1
|
-
### 0.6.0 (
|
2
|
-
* Your contribution here.
|
1
|
+
### 0.6.0 (2022/06/11)
|
3
2
|
|
4
|
-
|
3
|
+
* [#87](https://github.com/ashkan18/graphlient/pull/87): Raised `ExecutionError` with partial error response - [@QQism](https://github.com/QQism).
|
4
|
+
* [#90](https://github.com/ashkan18/graphlient/pull/90): Added support for Ruby 3.1 - [@QQism](https://github.com/QQism).
|
5
|
+
* [#90](https://github.com/ashkan18/graphlient/pull/90): Dropped support for Ruby 2.5 - [@QQism](https://github.com/QQism).
|
6
|
+
* [#91](https://github.com/ashkan18/graphlient/pull/91): Update GHA for `danger` with right permissions - [@QQism](https://github.com/QQism).
|
7
|
+
* [#89](https://github.com/ashkan18/graphlient/pull/89): Replace Travis CI with Github Actions - [@QQism](https://github.com/QQism).
|
8
|
+
|
9
|
+
### 0.5.0 (2020/12/28)
|
5
10
|
|
6
11
|
* [#81](https://github.com/ashkan18/graphlient/pull/81): Make graphlient run on ruby 3.0 - [@Burgestrand](https://github.com/Burgestrand).
|
7
12
|
* [#79](https://github.com/ashkan18/graphlient/pull/79): Added client testing docs - [@GabrielDzul](https://github.com/GabrielDzul).
|
8
13
|
|
9
|
-
### 0.4.0 (
|
14
|
+
### 0.4.0 (2020/05/22)
|
10
15
|
|
11
16
|
* [#72](https://github.com/ashkan18/graphlient/pull/72): Add http_options - [@neroleung](https://github.com/neroleung).
|
12
17
|
* [#71](https://github.com/ashkan18/graphlient/issues/70): Add `Graphlient::Errors::TimeoutError` - [@BenDrozdoff](https://github.com/BenDrozdoff).
|
13
18
|
* [#75](https://github.com/ashkan18/graphlient/pull/75): Support Faraday 1.x - [@jfhinchcliffe](https://github.com/jfhinchcliffe).
|
14
19
|
* [#78](https://github.com/ashkan18/graphlient/pull/78): Add description of timeout values - [@sap1enza](https://github.com/sap1enza).
|
15
20
|
|
16
|
-
### 0.3.7 (11/14
|
21
|
+
### 0.3.7 (2019/11/14)
|
17
22
|
|
18
23
|
* [#68](https://github.com/ashkan18/graphlient/pull/68): Add `Graphlient::Errors::ConnectionFailedError` - [@neroleung](https://github.com/neroleung).
|
19
24
|
|
20
|
-
### 0.3.6 (07/23
|
25
|
+
### 0.3.6 (2019/07/23)
|
21
26
|
|
22
27
|
* [#63](https://github.com/ashkan18/graphlient/pull/63): Remove unused method for attribute with typo - [@ashkan18](https://github.com/ashkan18).
|
23
28
|
* [#62](https://github.com/ashkan18/graphlient/pull/62): Fix typo preventing access to response object on error - [@jmondo](https://github.com/jmondo).
|
24
29
|
|
25
|
-
### 0.3.4 (01/31
|
30
|
+
### 0.3.4 (2019/01/31)
|
26
31
|
|
27
32
|
* [#56](https://github.com/ashkan18/graphlient/pull/56): Remove safe navigation usage to retain support for Ruby 2.2 - [@avinoth](https://github.com/avinoth).
|
28
33
|
* [#57](https://github.com/ashkan18/graphlient/pull/57): Add support for parsing queries from a String - [@ateamlunchbox](https://github.com/ateamlunchbox).
|
29
34
|
|
30
|
-
### 0.3.3 (09/23
|
35
|
+
### 0.3.3 (2018/09/23)
|
31
36
|
|
32
37
|
* [#50](https://github.com/ashkan18/graphlient/pull/50): More detailed error responses - [@ashkan18](https://github.com/ashkan18).
|
33
38
|
|
34
|
-
### 0.3.2 (07/03
|
39
|
+
### 0.3.2 (2018/07/03)
|
35
40
|
|
36
41
|
* [#46](https://github.com/ashkan18/graphlient/pull/46): Fix issue with gathering error details when trying `to_s` on `GraphQLError` - [@ashkan18](https://github.com/ashkan18).
|
37
42
|
* [#45](https://github.com/ashkan18/graphlient/pull/45): Drop Support for Ruby 2.2 and Lock RuboCop - [@jonallured](https://github.com/jonallured).
|
38
43
|
|
39
|
-
### 0.3.1 (04/17
|
44
|
+
### 0.3.1 (2018/04/17)
|
40
45
|
|
41
46
|
* [#43](https://github.com/ashkan18/graphlient/pull/43): Allow to load and dump schema to json - [@povilasjurcys](https://github.com/povilasjurcys).
|
42
47
|
|
43
|
-
### 0.3.0 (02/22
|
48
|
+
### 0.3.0 (2018/02/22)
|
44
49
|
|
45
50
|
* [#38](https://github.com/ashkan18/graphlient/pull/38): Add support for Ruby 2.5 - [@yuki24](https://github.com/yuki24).
|
46
51
|
* [#39](https://github.com/ashkan18/graphlient/pull/39): Add support for Ruby 2.2 - [@yuki24](https://github.com/yuki24).
|
47
52
|
* [#40](https://github.com/ashkan18/graphlient/pull/40): Add experimental support for JRuby - [@yuki24](https://github.com/yuki24).
|
48
53
|
|
49
|
-
### 0.2.0 (11/09
|
54
|
+
### 0.2.0 (2017/11/09)
|
50
55
|
|
51
56
|
* [#33](https://github.com/ashkan18/graphlient/pull/33): Added dsl for supporting parametrized queries/mutations - [@ashkan18](https://github.com/ashkan18).
|
52
57
|
* [#34](https://github.com/ashkan18/graphlient/issues/34): Fix: don't convert variables to `String` - [@dblock](https://github.com/dblock).
|
53
58
|
|
54
|
-
### 0.1.0 (10/27
|
59
|
+
### 0.1.0 (2017/10/27)
|
55
60
|
|
56
61
|
* [#31](https://github.com/ashkan18/graphlient/issues/31): Fix: catch execution errors that don't contain field names - [@dblock](https://github.com/dblock).
|
57
62
|
|
58
|
-
### 0.0.9 (10/26
|
63
|
+
### 0.0.9 (2017/10/26)
|
59
64
|
|
60
65
|
* [#28](https://github.com/ashkan18/graphlient/pull/28): Raise errors in `execute`, not only `query` - [@dblock](https://github.com/dblock).
|
61
66
|
* [#29](https://github.com/ashkan18/graphlient/pull/29): Added `Graphlient::Adapters::HTTP::HTTPAdapter` that replaces Faraday with `Net::HTTP` - [@dblock](https://github.com/dblock).
|
62
67
|
|
63
|
-
### 0.0.8 (10/26
|
68
|
+
### 0.0.8 (2017/10/26)
|
64
69
|
|
65
70
|
* [#27](https://github.com/ashkan18/graphlient/pull/27): Always raise an exception unless a query has succeeded - [@dblock](https://github.com/dblock).
|
66
71
|
|
67
|
-
### 0.0.7 (10/24
|
72
|
+
### 0.0.7 (2017/10/24)
|
68
73
|
|
69
74
|
* [#26](https://github.com/ashkan18/graphlient/pull/26): Support String queries - [@dblock](https://github.com/dblock).
|
70
75
|
|
71
|
-
### 0.0.6 (10/20
|
76
|
+
### 0.0.6 (2017/10/20)
|
72
77
|
|
73
78
|
* [#14](https://github.com/ashkan18/graphlient/pull/14): Switch to `graphql-client` for network calls and schema validation - [@ashkan18](https://github.com/ashkan18).
|
74
79
|
* [#17](https://github.com/ashkan18/graphlient/pull/17): Specialize server errors as `Graphlient::Errors::Server` - [@dblock](https://github.com/dblock).
|
@@ -79,16 +84,16 @@
|
|
79
84
|
* [#20](https://github.com/ashkan18/graphlient/pull/20): Added support for parameterized queries and mutations - [@dblock](https://github.com/dblock).
|
80
85
|
* [#25](https://github.com/ashkan18/graphlient/pull/25): Added `client.parse` and `client.execute` to parse and execute queries separately - [@dblock](https://github.com/dblock).
|
81
86
|
|
82
|
-
### 0.0.5 (10/
|
87
|
+
### 0.0.5 (2017/10/05)
|
83
88
|
|
84
89
|
* [#11](https://github.com/ashkan18/graphlient/pull/11): Fixed query argument types - [@ashkan18](https://github.com/ashkan18).
|
85
90
|
|
86
|
-
### 0.0.4 (10/
|
91
|
+
### 0.0.4 (2017/10/04)
|
87
92
|
|
88
93
|
* [#8](https://github.com/ashkan18/graphlient/pull/8): Handle HTTP errors and raise `Graphlient::Errors::HTTP` on failure - [@dblock](https://github.com/dblock).
|
89
94
|
* [#5](https://github.com/ashkan18/graphlient/pull/5): Added RuboCop, Ruby-style linter, CHANGELOG, CONTRIBUTING and RELEASING - [@dblock](https://github.com/dblock).
|
90
95
|
* [#4](https://github.com/ashkan18/graphlient/pull/4): Refactored Graphlient::Client to take a URL and options, moved extensions - [@dblock](https://github.com/dblock).
|
91
96
|
|
92
|
-
### 0.0.3 (10/
|
97
|
+
### 0.0.3 (2017/10/03)
|
93
98
|
|
94
99
|
* Initial public release - [@ashkan18](https://github.com/ashkan18).
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Graphlient
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/graphlient.svg)](https://badge.fury.io/rb/graphlient)
|
4
|
-
[![Build Status](https://
|
4
|
+
[![Build Status](https://github.com/ashkan18/graphlient/actions/workflows/ci.yml/badge.svg)](https://github.com/ashkan18/graphlient/actions/workflows/ci.yml)
|
5
5
|
|
6
6
|
A friendlier Ruby client for consuming GraphQL-based APIs. Built on top of your usual [graphql-client](https://github.com/github/graphql-client), but with better defaults, more consistent error handling, and using the [faraday](https://github.com/lostisland/faraday) HTTP client.
|
7
7
|
|
@@ -435,4 +435,3 @@ end
|
|
435
435
|
## License
|
436
436
|
|
437
437
|
MIT License, see [LICENSE](LICENSE)
|
438
|
-
|
data/lib/graphlient/client.rb
CHANGED
data/lib/graphlient/version.rb
CHANGED
@@ -80,6 +80,29 @@ describe Graphlient::Client do
|
|
80
80
|
GRAPHQL
|
81
81
|
end
|
82
82
|
|
83
|
+
let(:execution_error_query) do
|
84
|
+
<<-GRAPHQL
|
85
|
+
query($id: Int) {
|
86
|
+
executionErrorInvoice(id: $id) {
|
87
|
+
id
|
88
|
+
feeInCents
|
89
|
+
}
|
90
|
+
}
|
91
|
+
GRAPHQL
|
92
|
+
end
|
93
|
+
|
94
|
+
let(:partial_success_query) do
|
95
|
+
<<-GRAPHQL
|
96
|
+
query {
|
97
|
+
someInvoices {
|
98
|
+
id
|
99
|
+
feeInCents
|
100
|
+
createdAt
|
101
|
+
}
|
102
|
+
}
|
103
|
+
GRAPHQL
|
104
|
+
end
|
105
|
+
|
83
106
|
it '#execute' do
|
84
107
|
response = client.execute(query, id: 42)
|
85
108
|
invoice = response.data.invoice
|
@@ -97,10 +120,9 @@ describe Graphlient::Client do
|
|
97
120
|
|
98
121
|
it 'fails on an execution error' do
|
99
122
|
expect do
|
100
|
-
|
101
|
-
client.execute(query, id: 42)
|
123
|
+
client.execute(execution_error_query, id: 42)
|
102
124
|
end.to raise_error Graphlient::Errors::ExecutionError do |e|
|
103
|
-
expect(e.to_s).to eq '
|
125
|
+
expect(e.to_s).to eq 'executionErrorInvoice: Execution Error'
|
104
126
|
end
|
105
127
|
end
|
106
128
|
|
@@ -119,6 +141,14 @@ describe Graphlient::Client do
|
|
119
141
|
expect(e.response).to be_a GraphQL::Client::Response
|
120
142
|
end
|
121
143
|
end
|
144
|
+
|
145
|
+
it 'fails with a partial error response' do
|
146
|
+
expect do
|
147
|
+
client.execute(partial_success_query)
|
148
|
+
end.to raise_error Graphlient::Errors::ExecutionError do |e|
|
149
|
+
expect(e.response).to be_a GraphQL::Client::Response
|
150
|
+
end
|
151
|
+
end
|
122
152
|
end
|
123
153
|
|
124
154
|
context 'non-parameterized query' do
|
@@ -10,6 +10,15 @@ class Query < GraphQL::Schema::Object
|
|
10
10
|
argument :id, Integer, required: false
|
11
11
|
end
|
12
12
|
|
13
|
+
field :execution_error_invoice, InvoiceType, null: false, extras: [:execution_errors] do
|
14
|
+
description 'Find invoice'
|
15
|
+
argument :id, Integer, required: false
|
16
|
+
end
|
17
|
+
|
18
|
+
field :some_invoices, [InvoiceType], null: true do
|
19
|
+
description 'List of invoices'
|
20
|
+
end
|
21
|
+
|
13
22
|
def invoice(id: nil)
|
14
23
|
return nil if id.nil?
|
15
24
|
OpenStruct.new(
|
@@ -21,4 +30,18 @@ class Query < GraphQL::Schema::Object
|
|
21
30
|
def not_null_invoice(*)
|
22
31
|
nil
|
23
32
|
end
|
33
|
+
|
34
|
+
def execution_error_invoice(id: nil, execution_errors:)
|
35
|
+
execution_errors.add(GraphQL::ExecutionError.new('Execution Error'))
|
36
|
+
|
37
|
+
invoice(id: id)
|
38
|
+
end
|
39
|
+
|
40
|
+
def some_invoices
|
41
|
+
[
|
42
|
+
OpenStruct.new(id: 0, fee_in_cents: 20_000),
|
43
|
+
OpenStruct.new(id: 1, fee_in_cents: 20_000),
|
44
|
+
OpenStruct.new(id: 2, fee_in_cents: 20_000)
|
45
|
+
]
|
46
|
+
end
|
24
47
|
end
|
@@ -4,4 +4,10 @@ class InvoiceType < GraphQL::Schema::Object
|
|
4
4
|
|
5
5
|
field :id, ID, null: false
|
6
6
|
field :fee_in_cents, Integer, null: true
|
7
|
+
field :created_at, String, null: true, extras: [:execution_errors]
|
8
|
+
|
9
|
+
def created_at(execution_errors:)
|
10
|
+
execution_errors.add(GraphQL::ExecutionError.new('This is a partial error'))
|
11
|
+
Time.now.iso8601
|
12
|
+
end
|
7
13
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphlient
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ashkan Nasseri
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -58,11 +58,13 @@ executables: []
|
|
58
58
|
extensions: []
|
59
59
|
extra_rdoc_files: []
|
60
60
|
files:
|
61
|
+
- ".github/workflows/ci.yml"
|
62
|
+
- ".github/workflows/danger.yml"
|
63
|
+
- ".github/workflows/rubocop.yml"
|
61
64
|
- ".gitignore"
|
62
65
|
- ".rspec"
|
63
66
|
- ".rubocop.yml"
|
64
67
|
- ".rubocop_todo.yml"
|
65
|
-
- ".travis.yml"
|
66
68
|
- CHANGELOG.md
|
67
69
|
- CONTRIBUTING.md
|
68
70
|
- Dangerfile
|
@@ -140,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
142
|
- !ruby/object:Gem::Version
|
141
143
|
version: 1.3.6
|
142
144
|
requirements: []
|
143
|
-
rubygems_version: 3.
|
145
|
+
rubygems_version: 3.1.3
|
144
146
|
signing_key:
|
145
147
|
specification_version: 4
|
146
148
|
summary: A friendlier Ruby client for consuming GraphQL-based APIs.
|
data/.travis.yml
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
|
3
|
-
cache: bundler
|
4
|
-
|
5
|
-
rvm:
|
6
|
-
- 2.5.0
|
7
|
-
- 2.7.2
|
8
|
-
- 3.0.0
|
9
|
-
- ruby-head
|
10
|
-
- jruby-9.1.16.0
|
11
|
-
- jruby-head
|
12
|
-
|
13
|
-
before_install:
|
14
|
-
- gem update --system
|
15
|
-
|
16
|
-
matrix:
|
17
|
-
include:
|
18
|
-
- rvm: 2.7.2
|
19
|
-
script:
|
20
|
-
- bundle exec danger
|
21
|
-
allow_failures:
|
22
|
-
- rvm: ruby-head
|
23
|
-
- rvm: jruby-9.1.16.0
|
24
|
-
- rvm: jruby-head
|