graphql-client 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/graphql/client/http.rb +11 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40e658148a8c85013b801639a0f476c7287db05a
|
4
|
+
data.tar.gz: 47fedb450c1456d4436ec983c11c4fc4000a2c89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37ac81a288e27b7f7e283a5ab650908e97a4eac6d4c0c0e839f9ad11d9e6611d2b4a132383f65c81f13065adf115b8de173df252dbbe456c555caf73c72e8fa7
|
7
|
+
data.tar.gz: 2249225df289e023f31be5c41a89a6b3ca8030ed7e2e1298162cb718a74b9dea9dcd7ae43921c071432ad5cc92e11d4b0829b7392c4536454b3e0311fb9652e9
|
data/lib/graphql/client/http.rb
CHANGED
@@ -55,9 +55,6 @@ module GraphQL
|
|
55
55
|
#
|
56
56
|
# Returns { "data" => ... , "errors" => ... } Hash.
|
57
57
|
def execute(document:, operation_name: nil, variables: {}, context: {})
|
58
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
59
|
-
http.use_ssl = uri.scheme == "https"
|
60
|
-
|
61
58
|
request = Net::HTTP::Post.new(uri.request_uri)
|
62
59
|
|
63
60
|
request["Accept"] = "application/json"
|
@@ -66,11 +63,11 @@ module GraphQL
|
|
66
63
|
|
67
64
|
body = {}
|
68
65
|
body["query"] = document.to_query_string
|
69
|
-
body["variables"] =
|
66
|
+
body["variables"] = variables if variables.any?
|
70
67
|
body["operationName"] = operation_name if operation_name
|
71
68
|
request.body = JSON.generate(body)
|
72
69
|
|
73
|
-
response =
|
70
|
+
response = connection.request(request)
|
74
71
|
case response
|
75
72
|
when Net::HTTPOK, Net::HTTPBadRequest
|
76
73
|
JSON.parse(response.body)
|
@@ -78,6 +75,15 @@ module GraphQL
|
|
78
75
|
{ "errors" => [{ "message" => "#{response.code} #{response.message}" }] }
|
79
76
|
end
|
80
77
|
end
|
78
|
+
|
79
|
+
# Public: Extension point for subclasses to customize the Net:HTTP client
|
80
|
+
#
|
81
|
+
# Returns a Net::HTTP object
|
82
|
+
def connection
|
83
|
+
Net::HTTP.new(uri.host, uri.port).tap do |client|
|
84
|
+
client.use_ssl = uri.scheme == "https"
|
85
|
+
end
|
86
|
+
end
|
81
87
|
end
|
82
88
|
end
|
83
89
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitHub
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|