graphql_connector 1.4.0 → 2.0.0

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: 99e1add1eb99f9dd85020d90caf9b0cc73e9c8aca660fb8e56f425aa059254f3
4
- data.tar.gz: 7300a5b796cfd0f0ecba9d5af17d365504e722b759bd97bb2914c2623dfdaa32
3
+ metadata.gz: 81e604778c1aab26ebebc224ef71b2843f91bc3b51f7098066cb515f9437d300
4
+ data.tar.gz: 9d0f5e40ed50fbcd52974dba215ffda51678a2d334f8fa8321b720d554e683fb
5
5
  SHA512:
6
- metadata.gz: 9a46cbb39e8f3ccc7a79dbf47bd1437e1bc775f6a4b592dc1b52dec21a9ebca72e1ebb4a78c781ce2ed69ef35702f725480b20ba22765da9aea4a965a9f99700
7
- data.tar.gz: 4ae66cde11f69d1f4c8c4bab379a8251516f4b63562c427246b62044c2a26bc9e31be6bb13fd41435879c4693260f4b653b25b98f78dc88f5e2c52fc7a69ccd1
6
+ metadata.gz: bc5edb75f96dbf575d2bef6e70d7d0980a02c5c7071df2960e40a83f113ad7c85060da3bbd50885c46ac4dbc86306f8db5394a476839a66132c994de0b50925d
7
+ data.tar.gz: d4737485bc2f8c94db473f605f19e33d570aa5688a90230ee81284980c59b76991290ebef57a446ae8a93ceaf8c26983e96b49e86f48d6e4f9b4878d1d971615
@@ -7,7 +7,7 @@ jobs:
7
7
  runs-on: ubuntu-latest
8
8
  strategy:
9
9
  matrix:
10
- ruby: ['2.4', '2.5', '2.6', '2.7', '3.0', '3.1']
10
+ ruby: ['2.5', '2.6', '2.7', '3.0', '3.1']
11
11
  name: "ruby ${{ matrix.ruby }}"
12
12
  steps:
13
13
  - uses: actions/checkout@v1
@@ -24,14 +24,35 @@ jobs:
24
24
  name: Rubocop
25
25
  runs-on: ubuntu-latest
26
26
  steps:
27
- - uses: actions/checkout@v2
28
- - uses: ruby/setup-ruby@v1
29
- with:
30
- ruby-version: 2.7.3
31
- - name: Install dependencies
32
- run: |
33
- gem install bundler
34
- bundle install
35
- - name: Build and test
36
- run: |
37
- bundle exec rubocop
27
+ - uses: actions/checkout@v2
28
+ - uses: ruby/setup-ruby@v1
29
+ with:
30
+ ruby-version: 2.7
31
+ - name: Install dependencies
32
+ run: |
33
+ gem install bundler
34
+ bundle install
35
+ - name: Build and test
36
+ run: |
37
+ bundle exec rubocop
38
+ coverage:
39
+ name: coverage
40
+ runs-on: ubuntu-latest
41
+ steps:
42
+ - uses: actions/checkout@v1
43
+ - uses: ruby/setup-ruby@v1
44
+ with:
45
+ ruby-version: 2.7
46
+ - name: Setup Code Climate test-reporter
47
+ run: |
48
+ curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
49
+ chmod +x ./cc-test-reporter
50
+ ./cc-test-reporter before-build
51
+ - name: Build and test with RSpec
52
+ run: |
53
+ gem install bundler
54
+ bundle install
55
+ bundle exec rspec
56
+ - name: Publish code coverage
57
+ run: |
58
+ ./cc-test-reporter after-build -r ${{ secrets.CC_TEST_REPORTER_ID }}
data/.gitignore CHANGED
@@ -0,0 +1 @@
1
+ coverage/**
data/.rubocop.yml CHANGED
@@ -1,4 +1,7 @@
1
1
  inherit_from: .rubocop_todo.yml
2
2
 
3
+ AllCops:
4
+ TargetRubyVersion: 2.4
5
+
3
6
  Layout/LineLength:
4
7
  Max: 100
data/.rubocop_todo.yml CHANGED
@@ -3,4 +3,5 @@ Lint/DuplicateMethods:
3
3
  - lib/graphql_connector.rb
4
4
  Metrics/BlockLength:
5
5
  Exclude:
6
+ - "*.gemspec"
6
7
  - spec/graphql_connector/**/*.rb
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## 2.0.0 (TBD)
2
+
3
+ ### Features
4
+
5
+ Write here
6
+
7
+ ### Breaking changes
8
+
9
+ * query results are now transformed to OpenStructs recursively, so nested attributes are no longer a hash but another OpenStruct
10
+ * Set minimum Ruby version to `2.4` or higher
11
+
1
12
  ## 1.4.0 (2022-03-17)
2
13
 
3
14
  * Add config for `httparty_adapter_options` allowing forwarding options to `httparty`
data/Gemfile.lock CHANGED
@@ -10,6 +10,7 @@ GEM
10
10
  ast (2.4.0)
11
11
  coderay (1.1.2)
12
12
  diff-lcs (1.5.0)
13
+ docile (1.4.0)
13
14
  httparty (0.18.1)
14
15
  mime-types (~> 3.0)
15
16
  multi_xml (>= 0.5.2)
@@ -49,6 +50,12 @@ GEM
49
50
  ruby-progressbar (~> 1.7)
50
51
  unicode-display_width (>= 1.4.0, < 2.0)
51
52
  ruby-progressbar (1.10.1)
53
+ simplecov (0.21.2)
54
+ docile (~> 1.1)
55
+ simplecov-html (~> 0.11)
56
+ simplecov_json_formatter (~> 0.1)
57
+ simplecov-html (0.12.3)
58
+ simplecov_json_formatter (0.1.4)
52
59
  unicode-display_width (1.7.0)
53
60
 
54
61
  PLATFORMS
@@ -60,6 +67,7 @@ DEPENDENCIES
60
67
  pry (~> 0.10)
61
68
  rspec (~> 3.8)
62
69
  rubocop (~> 0.75)
70
+ simplecov (~> 0.21.2)
63
71
 
64
72
  BUNDLED WITH
65
73
  2.3.9
data/README.md CHANGED
@@ -5,6 +5,7 @@
5
5
  Version](https://badge.fury.io/rb/graphql_connector.svg)](https://badge.fury.io/rb/graphql_connector)
6
6
  [![CI](https://github.com/Garllon/graphql_connector/workflows/CI/badge.svg)](https://github.com/Garllon/graphql_connector/actions?query=workflow%3ACI)
7
7
  [![Maintainability](https://api.codeclimate.com/v1/badges/548db3cf0d078b379c84/maintainability)](https://codeclimate.com/github/Garllon/graphql_connector/maintainability)
8
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/548db3cf0d078b379c84/test_coverage)](https://codeclimate.com/github/Garllon/graphql_connector/test_coverage)
8
9
 
9
10
  An easy connector to call your `graphql` server. Currently there is no schema
10
11
  check in the code, but i will add it.
@@ -118,11 +119,6 @@ GraphqlConnector::<name>.query('products', { id: [1,2] } , ['id','name'], httpa
118
119
  | selected_fields | Yes | Array of Strings/Hashes | ['id', 'name', productCategory: ['id']] |
119
120
  | httparty_adapter_options | No | Hash | { timeout: 3 } |
120
121
 
121
- :warning:
122
- > You get an OpenStruct back. Currently only the first level attributes are
123
- > supported with OpenStruct, associated objects are still a normal array of
124
- > hashes.
125
-
126
122
  See also [here](examples/query_examples.rb) for example usage
127
123
 
128
124
  #### selected_fields
@@ -31,10 +31,13 @@ Gem::Specification.new do |spec|
31
31
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
32
32
  spec.require_paths = ['lib']
33
33
 
34
+ spec.required_ruby_version = '>= 2.4.0'
35
+
34
36
  spec.add_dependency 'httparty', '~> 0.16'
35
37
 
36
38
  spec.add_development_dependency 'bundler', '~> 2.0'
37
39
  spec.add_development_dependency 'pry', '~> 0.10'
38
40
  spec.add_development_dependency 'rspec', '~> 3.8'
39
41
  spec.add_development_dependency 'rubocop', '~> 0.75'
42
+ spec.add_development_dependency 'simplecov', '~> 0.21.2'
40
43
  end
@@ -47,9 +47,19 @@ module GraphqlConnector
47
47
  def format_body(query_string, model, httparty_adapter_options)
48
48
  parsed_body = raw_query(query_string, httparty_adapter_options: httparty_adapter_options)
49
49
  response_body = parsed_body['data'][model.to_s]
50
- return OpenStruct.new(response_body) unless response_body.is_a? Array
50
+ transform_data(response_body)
51
+ end
51
52
 
52
- response_body.map { |entry| OpenStruct.new(entry) }
53
+ def transform_data(data)
54
+ case data
55
+ when Array
56
+ data.map { |element| transform_data(element) }
57
+ when Hash
58
+ data = data.transform_values { |value| transform_data(value) }
59
+ OpenStruct.new(data)
60
+ else
61
+ data
62
+ end
53
63
  end
54
64
 
55
65
  def verify_response!(parsed_body)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GraphqlConnector
4
- VERSION = '1.4.0'
4
+ VERSION = '2.0.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql_connector
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garllon
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2022-04-08 00:00:00.000000000 Z
12
+ date: 2023-08-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
@@ -81,6 +81,20 @@ dependencies:
81
81
  - - "~>"
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0.75'
84
+ - !ruby/object:Gem::Dependency
85
+ name: simplecov
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: 0.21.2
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: 0.21.2
84
98
  description: Grahql client to query with your own raw string, with the small helper
85
99
  method query or with service class inclusion.
86
100
  email:
@@ -137,14 +151,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
137
151
  requirements:
138
152
  - - ">="
139
153
  - !ruby/object:Gem::Version
140
- version: '0'
154
+ version: 2.4.0
141
155
  required_rubygems_version: !ruby/object:Gem::Requirement
142
156
  requirements:
143
157
  - - ">="
144
158
  - !ruby/object:Gem::Version
145
159
  version: '0'
146
160
  requirements: []
147
- rubygems_version: 3.2.7
161
+ rubygems_version: 3.4.1
148
162
  signing_key:
149
163
  specification_version: 4
150
164
  summary: GraphQL client