simple_graphql_client 0.1.0 → 0.3.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a96e1ad94b231b6129ecdc7bf494fd68d42ac70337dbb69669807dedf8d4d3d8
4
- data.tar.gz: 2ee556a6a36d50b2220533ab46153226dce3e4cebc2025c338dbacb1db614d03
3
+ metadata.gz: 7ed8067b4019cd32cefc33b4b49517d9bc0d614e3d629f6477ceeafa75df2f1b
4
+ data.tar.gz: 4eb81ee42cadb0ab19a1ecf88c4312098e97fc07268382cf591fde20826d37eb
5
5
  SHA512:
6
- metadata.gz: cfa413605f565ae4118c872a3b2318a2a83f3b23990da38047f9104296c276c842f673feb4e9c6173f22543fc48448c091be4ace86b9728a416a69c4aff1849c
7
- data.tar.gz: ef3b02d3b582e5ff0ec55e7cb1e572d5de00cdd94286015ffa7e99db5c66859f86ab840e458b7e93f4bdaef017439969310990f86fccab1ec8b8b780b606f181
6
+ metadata.gz: f934090545eff7c223b0ea9280fdbf77647b2eae72d061f0ad42761e1508c78ac4f73f04ba86d34bfdc23e613342d4e2a224aa6f86807f393313745030f47932
7
+ data.tar.gz: 9ff08d5fd01911f8c6d879c33a5944cf1d71b02f3b1a891d82718dc9f2b78725eee34057f4c14f6c5728cb4b95294276f611397f9f5cc1b827486aef3b169cac
data/Changelog.md CHANGED
@@ -1,3 +1,12 @@
1
- 0.1.0 - 08/13/2021
1
+ 0.3.1 - 09/06/2022
2
+ fix handling
3
+
4
+ 0.3.0 - 09/06/2022
5
+ Allow specifying the parsing class
2
6
 
7
+ 0.2.0 - 08/13/2021
8
+ Use openstruct
9
+
10
+ 0.1.0 - 08/13/2021
11
+ ------------------
3
12
  Initial release
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- simple_graphql_client (0.1.0)
4
+ simple_graphql_client (0.3.1)
5
5
  rest-client (~> 2.1)
6
6
 
7
7
  GEM
@@ -61,13 +61,14 @@ GEM
61
61
  unicode-display_width (1.7.0)
62
62
 
63
63
  PLATFORMS
64
+ ruby
64
65
  x86_64-linux
65
66
 
66
67
  DEPENDENCIES
67
- simple_graphql_client!
68
68
  rake (~> 13.0)
69
69
  rspec (~> 3.0)
70
70
  rubocop (~> 0.80)
71
+ simple_graphql_client!
71
72
 
72
73
  BUNDLED WITH
73
74
  2.2.3
@@ -5,9 +5,12 @@ require "json"
5
5
 
6
6
  module SimpleGraphqlClient
7
7
  class Client
8
- def initialize(url:, &block)
8
+ attr_reader :options
9
+
10
+ def initialize(url:, options: {}, &block)
9
11
  @url = url
10
- @options = block
12
+ @options = options
13
+ @request_options = block
11
14
  end
12
15
 
13
16
  def query(gql:, variables: {})
@@ -15,21 +18,22 @@ module SimpleGraphqlClient
15
18
  query: gql,
16
19
  variables: variables
17
20
  }.to_json, request_options)
18
- handle_response(JSON.parse(response.body))
21
+ handle_response(JSON.parse(response.body, object_class: options.fetch(:parsing_class, OpenStruct)))
19
22
  end
20
23
 
21
24
  private
22
25
 
23
26
  def request_options
24
27
  base_options = { content_type: :json }
25
- options = @options ? @options.call : {}
28
+ options = @request_options ? @request_options.call : {}
26
29
  base_options.merge(options)
27
30
  end
28
31
 
29
32
  def handle_response(body)
30
- raise SimpleGraphqlClient::Errors::QueryError, body["errors"] if body.key?("errors")
33
+ errors = body.is_a?(Hash) ? body["errors"] : body.errors
34
+ raise SimpleGraphqlClient::Errors::QueryError, errors if errors
31
35
 
32
- body["data"]
36
+ body.is_a?(Hash) ? body["data"] : body.data
33
37
  end
34
38
  end
35
39
  end
@@ -12,9 +12,7 @@ module SimpleGraphqlClient
12
12
 
13
13
  def message
14
14
  str = "#{errors.count} error(s) found in your query: "
15
- str + errors.map do |error|
16
- error["message"]
17
- end.join(', \n')
15
+ str + errors.map(&:message).join(', \n')
18
16
  end
19
17
  end
20
18
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SimpleGraphqlClient
4
- VERSION = "0.1.0"
4
+ VERSION = "0.3.1"
5
5
  end
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
 
17
17
  spec.metadata["homepage_uri"] = spec.homepage
18
18
  spec.metadata["source_code_uri"] = "https://github.com/djpate/simple-graphql-client"
19
- spec.metadata["changelog_uri"] = "https://github.com/djpate/simple-graphql-client/changelog.md"
19
+ spec.metadata["changelog_uri"] = "https://github.com/djpate/simple-graphql-client/blob/main/Changelog.md"
20
20
 
21
21
  # Specify which files should be added to the gem when it is released.
22
22
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_graphql_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christophe Verbinnen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-13 00:00:00.000000000 Z
11
+ date: 2022-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -55,7 +55,7 @@ licenses:
55
55
  metadata:
56
56
  homepage_uri: https://github.com/djpate/simple-graphql-client
57
57
  source_code_uri: https://github.com/djpate/simple-graphql-client
58
- changelog_uri: https://github.com/djpate/simple-graphql-client/changelog.md
58
+ changelog_uri: https://github.com/djpate/simple-graphql-client/blob/main/Changelog.md
59
59
  post_install_message:
60
60
  rdoc_options: []
61
61
  require_paths:
@@ -71,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
71
  - !ruby/object:Gem::Version
72
72
  version: '0'
73
73
  requirements: []
74
- rubygems_version: 3.2.3
74
+ rubygems_version: 3.1.6
75
75
  signing_key:
76
76
  specification_version: 4
77
77
  summary: Dead simple GQL client