graphlient 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/.rubocop_todo.yml +32 -17
- data/.travis.yml +8 -2
- data/CHANGELOG.md +11 -0
- data/Dangerfile +1 -0
- data/Gemfile +5 -0
- data/README.md +200 -26
- data/RELEASING.md +1 -1
- data/Rakefile +1 -1
- data/graphlient.gemspec +3 -0
- data/lib/graphlient.rb +0 -5
- data/lib/graphlient/adapters/faraday_adapter.rb +43 -0
- data/lib/graphlient/client.rb +35 -20
- data/lib/graphlient/errors.rb +2 -1
- data/lib/graphlient/errors/client.rb +6 -0
- data/lib/graphlient/errors/error.rb +7 -0
- data/lib/graphlient/errors/server.rb +6 -0
- data/lib/graphlient/query.rb +13 -5
- data/lib/graphlient/version.rb +1 -1
- data/spec/graphlient/adapters/faraday_adapter_spec.rb +44 -0
- data/spec/graphlient/client_query_spec.rb +158 -0
- data/spec/graphlient/client_schema_spec.rb +19 -0
- data/spec/graphlient/extensions/query_spec.rb +6 -4
- data/spec/graphlient/query_spec.rb +72 -25
- data/spec/graphlient/static_client_query_spec.rb +39 -0
- data/spec/spec_helper.rb +3 -1
- data/spec/support/context/dummy_client.rb +26 -0
- data/spec/support/dummy_app.rb +25 -0
- data/spec/support/dummy_schema.rb +9 -0
- data/spec/support/mutations/create_invoice_mutation.rb +16 -0
- data/spec/support/mutations/mutation.rb +7 -0
- data/spec/support/queries/query.rb +16 -0
- data/spec/support/types/invoice_type.rb +6 -0
- metadata +61 -8
- data/.byebug_history +0 -23
- data/lib/graphlient/config.rb +0 -21
- data/lib/graphlient/errors/http.rb +0 -12
- data/spec/graphlient/client_spec.rb +0 -42
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Graphlient::Client do
|
4
|
-
let(:graphql_endpoint) { 'http://graph.biz/gprahql' }
|
5
|
-
let(:request_headers) do
|
6
|
-
{
|
7
|
-
'Authorization' => 'Bearer 1231',
|
8
|
-
'Content-Type' => 'application/json'
|
9
|
-
}
|
10
|
-
end
|
11
|
-
let(:graphql_client) { Graphlient::Client.new(graphql_endpoint, headers: request_headers) }
|
12
|
-
describe '#query' do
|
13
|
-
let(:response) do
|
14
|
-
graphql_client.query do
|
15
|
-
invoice(id: 10) do
|
16
|
-
line_items
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
describe 'success' do
|
21
|
-
let!(:graphql_post_request) { stub_request(:post, 'http://graph.biz/gprahql').to_return(body: {}.to_json) }
|
22
|
-
it 'returns expected query with block' do
|
23
|
-
expect(response).to eq({})
|
24
|
-
expect(graphql_post_request.with(
|
25
|
-
body: { query: "{ \ninvoice(id: 10){\n line_items\n }\n }" },
|
26
|
-
headers: { 'Content-Type' => 'application/json' }
|
27
|
-
)).to have_been_made.once
|
28
|
-
end
|
29
|
-
end
|
30
|
-
describe 'failure' do
|
31
|
-
let!(:graphql_post_request) { stub_request(:post, 'http://graph.biz/gprahql').to_return(status: [500, 'Internal Server Error']) }
|
32
|
-
it 'fails with an exception' do
|
33
|
-
expect do
|
34
|
-
response
|
35
|
-
end.to raise_error Graphlient::Errors::HTTP do |e|
|
36
|
-
expect(e.to_s).to eq 'Internal Server Error'
|
37
|
-
expect(e.response.code.to_i).to eq 500
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|