graphql_rails 1.2.1 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 66c6e2cd4ba018ee3af6aa4461b67b29ed202d21a93b5d0ea877d5fdfdecfbc7
4
- data.tar.gz: 5955a5e193a761dd3821107bb60c02db6aa8d72717b0288b4863b79920a8ad4e
3
+ metadata.gz: 4f7c503110a2423bb3e0b90154f9d0c4f6daeabc3315a1c49c1a832a29366ff2
4
+ data.tar.gz: bfc7779f2678094724d0d1c3368edaa792665493a32d5112c5864998879fe96c
5
5
  SHA512:
6
- metadata.gz: 9342f037b0b41b4a70621787f14188da08693fa773d0efd2e3148c8d6be7e6086e3ae8215d349e72ab3a7448643f49ca7ccc2fe9c3d5a911d152a9a06131d164
7
- data.tar.gz: c3ef9dda6a219e42394e3027fe4710af88360c8f699a13d8bc66a11c1bf8c31a25a295e6a217d8c1b04e6826899e24d73950a279d5f5505893601181e6da8d28
6
+ metadata.gz: 740f486bb00615a7b83a78a8d5dc6d72d7d57dc0a42385178d1cc87875e264f0370f3131ca1e327f8d510f2126b7956915ead75374b06c81e99c96f98b6d57b9
7
+ data.tar.gz: df08d0a84e9f505d25922d460677ddf2d34e5333258d111e9ee95090747612ccbb789d4f44d88f9cb1779a2afd4bbe4765b1ecabb1e88e2d75b777a05f94f3a4
@@ -0,0 +1,18 @@
1
+ name: Ruby
2
+ on: [push, pull_request]
3
+ jobs:
4
+ specs:
5
+ strategy:
6
+ matrix:
7
+ ruby-version: ['2.6', '2.7', '3.0']
8
+
9
+ runs-on: ubuntu-latest
10
+ env:
11
+ CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
12
+ steps:
13
+ - uses: actions/checkout@v2
14
+ - uses: ruby/setup-ruby@v1
15
+ with:
16
+ ruby-version: ${{ matrix.ruby-version }}
17
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
18
+ - run: bundle exec rake
data/.hound.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  rubocop:
2
2
  config_file: .rubocop.yml
3
- version: 0.91.0
3
+ version: 1.5.2
4
4
  fail_on_violations: true
data/.rubocop.yml CHANGED
@@ -35,6 +35,7 @@ Style/ClassAndModuleChildren:
35
35
  - spec/**/*_spec.rb
36
36
 
37
37
  AllCops:
38
+ NewCops: disable # TODO: enable
38
39
  TargetRubyVersion: 2.7
39
40
  Exclude:
40
41
  - bin/*
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.7.1
1
+ 3.0.1
data/CHANGELOG.md CHANGED
@@ -9,6 +9,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9
9
 
10
10
  * Added/Changed/Deprecated/Removed/Fixed/Security: YOUR CHANGE HERE
11
11
 
12
+ ## [1.2.4](2021-05-05)
13
+
14
+ * Fixed: Dynamic types definition where type A references type B referencing type A.
15
+
16
+ ## [1.2.3](2021-04-12)
17
+
18
+ * Fixed: Total count on paginated resources
19
+
20
+ ## [1.2.2](2021-02-19)
21
+
22
+ * Fixed: Incorrect type resolution for required list type fields in model declaration.
23
+
12
24
  ## [1.2.1](2021-02-17)
13
25
 
14
26
  * Fixed: Incorrect scalar types resolution is fixed. No more `type mismatch between ID / ID`
data/Gemfile CHANGED
@@ -5,9 +5,9 @@ source 'https://rubygems.org'
5
5
  git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
6
 
7
7
  group :development do
8
- gem 'rubocop', '0.91.0'
9
- gem 'rubocop-performance', '~> 1.8', '>= 1.8.1'
10
- gem 'rubocop-rspec', '~> 1.44', '>= 1.44.1'
8
+ gem 'rubocop', '1.5.2'
9
+ gem 'rubocop-performance'
10
+ gem 'rubocop-rspec'
11
11
  end
12
12
 
13
13
  group :test do
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- graphql_rails (1.2.1)
4
+ graphql_rails (1.2.6)
5
5
  activesupport (>= 4)
6
6
  graphql (~> 1.12, >= 1.12.4)
7
7
 
@@ -63,7 +63,7 @@ GEM
63
63
  minitest (~> 5.1)
64
64
  tzinfo (~> 1.1)
65
65
  zeitwerk (~> 2.2, >= 2.2.2)
66
- ast (2.4.1)
66
+ ast (2.4.2)
67
67
  bson (4.11.0)
68
68
  builder (3.2.4)
69
69
  byebug (11.1.3)
@@ -78,7 +78,7 @@ GEM
78
78
  erubi (1.9.0)
79
79
  globalid (0.4.2)
80
80
  activesupport (>= 4.2.0)
81
- graphql (1.12.4)
81
+ graphql (1.12.10)
82
82
  i18n (1.8.5)
83
83
  concurrent-ruby (~> 1.0)
84
84
  json (2.3.1)
@@ -90,9 +90,11 @@ GEM
90
90
  marcel (0.3.3)
91
91
  mimemagic (~> 0.3.2)
92
92
  method_source (1.0.0)
93
- mimemagic (0.3.5)
93
+ mimemagic (0.3.10)
94
+ nokogiri (~> 1)
95
+ rake
94
96
  mini_mime (1.0.2)
95
- mini_portile2 (2.5.0)
97
+ mini_portile2 (2.6.1)
96
98
  minitest (5.14.2)
97
99
  mongo (2.13.1)
98
100
  bson (>= 4.8.2, < 5.0.0)
@@ -100,11 +102,11 @@ GEM
100
102
  activemodel (>= 5.1, < 6.1)
101
103
  mongo (>= 2.7.0, < 3.0.0)
102
104
  nio4r (2.5.4)
103
- nokogiri (1.11.1)
104
- mini_portile2 (~> 2.5.0)
105
+ nokogiri (1.12.5)
106
+ mini_portile2 (~> 2.6.1)
105
107
  racc (~> 1.4)
106
- parallel (1.19.2)
107
- parser (2.7.2.0)
108
+ parallel (1.20.1)
109
+ parser (3.0.1.1)
108
110
  ast (~> 2.4.1)
109
111
  pry (0.13.1)
110
112
  coderay (~> 1.1)
@@ -144,8 +146,8 @@ GEM
144
146
  thor (>= 0.20.3, < 2.0)
145
147
  rainbow (3.0.0)
146
148
  rake (13.0.1)
147
- regexp_parser (1.8.2)
148
- rexml (3.2.4)
149
+ regexp_parser (2.1.1)
150
+ rexml (3.2.5)
149
151
  rspec (3.10.0)
150
152
  rspec-core (~> 3.10.0)
151
153
  rspec-expectations (~> 3.10.0)
@@ -159,24 +161,24 @@ GEM
159
161
  diff-lcs (>= 1.2.0, < 2.0)
160
162
  rspec-support (~> 3.10.0)
161
163
  rspec-support (3.10.0)
162
- rubocop (0.91.0)
164
+ rubocop (1.5.2)
163
165
  parallel (~> 1.10)
164
- parser (>= 2.7.1.1)
166
+ parser (>= 2.7.1.5)
165
167
  rainbow (>= 2.2.2, < 4.0)
166
- regexp_parser (>= 1.7)
168
+ regexp_parser (>= 1.8, < 3.0)
167
169
  rexml
168
- rubocop-ast (>= 0.4.0, < 1.0)
170
+ rubocop-ast (>= 1.2.0, < 2.0)
169
171
  ruby-progressbar (~> 1.7)
170
172
  unicode-display_width (>= 1.4.0, < 2.0)
171
- rubocop-ast (0.8.0)
172
- parser (>= 2.7.1.5)
173
+ rubocop-ast (1.5.0)
174
+ parser (>= 3.0.1.1)
173
175
  rubocop-performance (1.8.1)
174
176
  rubocop (>= 0.87.0)
175
177
  rubocop-ast (>= 0.4.0)
176
- rubocop-rspec (1.44.1)
177
- rubocop (~> 0.87)
178
- rubocop-ast (>= 0.7.1)
179
- ruby-progressbar (1.10.1)
178
+ rubocop-rspec (2.3.0)
179
+ rubocop (~> 1.0)
180
+ rubocop-ast (>= 1.1.0)
181
+ ruby-progressbar (1.11.0)
180
182
  simplecov (0.19.1)
181
183
  docile (~> 1.1)
182
184
  simplecov-html (~> 0.11)
@@ -211,9 +213,9 @@ DEPENDENCIES
211
213
  rails (~> 6)
212
214
  rake (~> 13.0)
213
215
  rspec (~> 3.0)
214
- rubocop (= 0.91.0)
215
- rubocop-performance (~> 1.8, >= 1.8.1)
216
- rubocop-rspec (~> 1.44, >= 1.44.1)
216
+ rubocop (= 1.5.2)
217
+ rubocop-performance
218
+ rubocop-rspec
217
219
  simplecov
218
220
 
219
221
  BUNDLED WITH
data/docs/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # GraphqlRails
2
2
 
3
- [![Build Status](https://travis-ci.org/samesystem/graphql_rails.svg?branch=master)](https://travis-ci.org/samesystem/graphql_rails)
3
+ ![Build Status](https://github.com/samesystem/graphql_rails/workflows/Ruby/badge.svg?branch=master)
4
4
  [![codecov](https://codecov.io/gh/samesystem/graphql_rails/branch/master/graph/badge.svg)](https://codecov.io/gh/samesystem/graphql_rails)
5
5
  [![Documentation](https://readthedocs.org/projects/ansicolortags/badge/?version=latest)](https://samesystem.github.io/graphql_rails)
6
6
 
@@ -21,11 +21,9 @@ module GraphqlRails
21
21
  end
22
22
 
23
23
  def required?
24
- if @required.nil?
25
- attribute_name_parser.required? || !initial_type.to_s[/!$/].nil?
26
- else
27
- @required
28
- end
24
+ return @required unless @required.nil?
25
+
26
+ attribute_name_parser.required? || !initial_type.to_s[/!$/].nil? || initial_type.is_a?(GraphQL::Schema::NonNull)
29
27
  end
30
28
 
31
29
  def required
@@ -3,9 +3,14 @@
3
3
  module GraphqlRails
4
4
  # contains configuration options related with inputs
5
5
  module InputConfigurable
6
- def permit(*no_type_attributes, **typed_attributes)
7
- no_type_attributes.each { |attribute| permit_input(attribute) }
8
- typed_attributes.each { |attribute, type| permit_input(attribute, type: type) }
6
+ def permit(*args)
7
+ args.each do |arg|
8
+ if arg.is_a? Hash
9
+ arg.each { |attribute, type| permit_input(attribute, type: type) }
10
+ else
11
+ permit_input(arg)
12
+ end
13
+ end
9
14
  self
10
15
  end
11
16
 
@@ -27,7 +27,7 @@ module GraphqlRails
27
27
  attr_reader :graphql_object
28
28
 
29
29
  def list
30
- graphql_object.nodes
30
+ graphql_object.items
31
31
  end
32
32
 
33
33
  def active_record?
@@ -33,7 +33,7 @@ module GraphqlRails
33
33
  field :total, Integer, null: false
34
34
 
35
35
  def total
36
- CountItems.call(self)
36
+ CountItems.call(object)
37
37
  end
38
38
  end
39
39
  end
@@ -5,6 +5,14 @@ module GraphqlRails
5
5
  # contains methods which are shared between various configurations
6
6
  # expects `default_name` to be defined
7
7
  module Configurable
8
+ def initialize_copy(other)
9
+ super
10
+ @name = nil
11
+ @type_name = nil
12
+ @description = nil
13
+ @attributes = other.attributes.transform_values(&:dup)
14
+ end
15
+
8
16
  def attributes
9
17
  @attributes ||= {}
10
18
  end
@@ -22,7 +22,6 @@ module GraphqlRails
22
22
  @connection_type = nil
23
23
  @graphql_type = nil
24
24
  @input = other.instance_variable_get(:@input)&.transform_values(&:dup)
25
- @attributes = other.instance_variable_get(:@attributes)&.transform_values(&:dup)
26
25
  end
27
26
 
28
27
  def attribute(attribute_name, **attribute_options)
@@ -68,6 +67,14 @@ module GraphqlRails
68
67
  @connection_type ||= BuildConnectionType.call(graphql_type)
69
68
  end
70
69
 
70
+ def with_ensured_fields!
71
+ return self if @graphql_type.blank?
72
+
73
+ reset_graphql_type if attributes.any? && graphql_type.fields.length != attributes.length
74
+
75
+ self
76
+ end
77
+
71
78
  private
72
79
 
73
80
  attr_reader :model_class
@@ -75,6 +82,16 @@ module GraphqlRails
75
82
  def default_name
76
83
  @default_name ||= model_class.name.split('::').last
77
84
  end
85
+
86
+ def reset_graphql_type
87
+ @graphql_type = FindOrBuildGraphqlType.call(
88
+ name: name,
89
+ description: description,
90
+ attributes: attributes,
91
+ type_name: type_name,
92
+ force_define_attributes: true
93
+ )
94
+ end
78
95
  end
79
96
  end
80
97
  end
@@ -10,20 +10,21 @@ module GraphqlRails
10
10
 
11
11
  include ::GraphqlRails::Service
12
12
 
13
- def initialize(name:, description:, attributes:, type_name:)
13
+ def initialize(name:, description:, attributes:, type_name:, force_define_attributes: false)
14
14
  @name = name
15
15
  @description = description
16
16
  @attributes = attributes
17
17
  @type_name = type_name
18
+ @force_define_attributes = force_define_attributes
18
19
  end
19
20
 
20
21
  def call
21
- klass.tap { add_fields_to_graphql_type if new_class? }
22
+ klass.tap { add_fields_to_graphql_type if new_class? || force_define_attributes }
22
23
  end
23
24
 
24
25
  private
25
26
 
26
- attr_reader :name, :description, :attributes, :type_name
27
+ attr_reader :name, :description, :attributes, :type_name, :force_define_attributes
27
28
 
28
29
  delegate :klass, :new_class?, to: :type_class_finder
29
30
 
@@ -14,11 +14,6 @@ module GraphqlRails
14
14
  @input_name_suffix = input_name_suffix
15
15
  end
16
16
 
17
- def initialize_copy(other)
18
- super
19
- @attributes = other.instance_variable_get(:@attributes)&.transform_values(&:dup)
20
- end
21
-
22
17
  def graphql_input_type
23
18
  @graphql_input_type ||= BuildGraphqlInputType.call(
24
19
  name: name, description: description, attributes: attributes
@@ -28,7 +28,7 @@ module GraphqlRails
28
28
 
29
29
  def graphql
30
30
  @graphql ||= Model::Configuration.new(self)
31
- yield(@graphql) if block_given?
31
+ @graphql.tap { |it| yield(it) }.with_ensured_fields! if block_given?
32
32
  @graphql
33
33
  end
34
34
  end
@@ -9,8 +9,8 @@ module GraphqlRails
9
9
 
10
10
  attr_reader :name
11
11
 
12
- def self.call(*args)
13
- new(*args).call
12
+ def self.call(**args)
13
+ new(**args).call
14
14
  end
15
15
 
16
16
  def initialize(name:)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GraphqlRails
4
- VERSION = '1.2.1'
4
+ VERSION = '1.2.6'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Povilas Jurčys
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-17 00:00:00.000000000 Z
11
+ date: 2021-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql
@@ -128,19 +128,19 @@ dependencies:
128
128
  - - "~>"
129
129
  - !ruby/object:Gem::Version
130
130
  version: '6'
131
- description:
131
+ description:
132
132
  email:
133
133
  - po.jurcys@gmail.com
134
134
  executables: []
135
135
  extensions: []
136
136
  extra_rdoc_files: []
137
137
  files:
138
+ - ".github/workflows/ruby.yml"
138
139
  - ".gitignore"
139
140
  - ".hound.yml"
140
141
  - ".rspec"
141
142
  - ".rubocop.yml"
142
143
  - ".ruby-version"
143
- - ".travis.yml"
144
144
  - CHANGELOG.md
145
145
  - CODE_OF_CONDUCT.md
146
146
  - Gemfile
@@ -232,7 +232,7 @@ homepage: https://github.com/samesystem/graphql_rails
232
232
  licenses:
233
233
  - MIT
234
234
  metadata: {}
235
- post_install_message:
235
+ post_install_message:
236
236
  rdoc_options: []
237
237
  require_paths:
238
238
  - lib
@@ -247,8 +247,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
247
247
  - !ruby/object:Gem::Version
248
248
  version: '0'
249
249
  requirements: []
250
- rubygems_version: 3.1.2
251
- signing_key:
250
+ rubygems_version: 3.2.15
251
+ signing_key:
252
252
  specification_version: 4
253
253
  summary: Rails style structure for GraphQL API.
254
254
  test_files: []
data/.travis.yml DELETED
@@ -1,5 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.7.1
5
- before_install: gem install bundler -v 2.1.4