graphql-client 0.1.1 → 0.1.2

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/graphql/client/http.rb +11 -5
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1aa82bdba6a8574b9ef862cbcfa222935b945334
4
- data.tar.gz: 0031342b2a99551a01b5abfb0c590e5ea641d210
3
+ metadata.gz: 40e658148a8c85013b801639a0f476c7287db05a
4
+ data.tar.gz: 47fedb450c1456d4436ec983c11c4fc4000a2c89
5
5
  SHA512:
6
- metadata.gz: 28a03cd2bcb52c6e80f9650fa0cc3379722e017a75f099291cfe028ded2e8a1993f62de538d9b17ac156c95fbfcaed2bf99b1283a60abd92661435774d2f35b3
7
- data.tar.gz: aa3ca97cb51d6d0e5c160d1baa28b7b7e453bea00a2c703f57c7b368a30d4065988af885a189007d88db5f5c770bf268b02a3dc1b32ed75152f1deafd3672b19
6
+ metadata.gz: 37ac81a288e27b7f7e283a5ab650908e97a4eac6d4c0c0e839f9ad11d9e6611d2b4a132383f65c81f13065adf115b8de173df252dbbe456c555caf73c72e8fa7
7
+ data.tar.gz: 2249225df289e023f31be5c41a89a6b3ca8030ed7e2e1298162cb718a74b9dea9dcd7ae43921c071432ad5cc92e11d4b0829b7392c4536454b3e0311fb9652e9
@@ -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"] = JSON.generate(variables) if variables.any?
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 = http.request(request)
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.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-09-27 00:00:00.000000000 Z
11
+ date: 2016-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport