graphql_rails 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f63b8e5d3c98d472ff1ec382261d772e83d70d7d8af6df29da806b72f8563858
4
- data.tar.gz: d075ad40f236b39d0f57e7a47469c6de5a7a3b5ebba5ab62fff30981b7e536ce
3
+ metadata.gz: d31436f40d036cd543c69a2b59e442d2498eb6349d61c4454dc9376e0caf4de0
4
+ data.tar.gz: 9b5041b648314fbff349e614e9b1f6be43f94bff32490f8de0dc4a23bb28c6a7
5
5
  SHA512:
6
- metadata.gz: 5edf95451b857f27d304701402e8a18c771150385cf1fbc7a72db0d446ee7848c4de6ff0c85466fc6129e9adde4e14057c9b11b244cc388d2f6ee692547511e2
7
- data.tar.gz: dfd50167b6c86ee5f371e0183eac93bb8b32d6a3572c85b2cdc1b218c3ca026afc501a44d4534728b45dd0594c4fb9ad451d8d240e1ad9a8fbf12246b2200091
6
+ metadata.gz: 72d4881a3aa604c19f38f53e4b77fdea562e7b804d8cec6a125789da32b6b215c298f5dcd1a747680a72c2e65571d0f30ab7b47597758fbb632bf21731f9bf70
7
+ data.tar.gz: 0a7ec0c5d6bf383c89b82109a4c120137e470f7e187ab8a3ab791840706abd6b0a49933b1bcead76437603fff546fc66ebd024fad8067bea6558d60499c587b0
@@ -30,6 +30,10 @@ Naming/UncommunicativeMethodParamName:
30
30
  - 'in'
31
31
  - 'as'
32
32
 
33
+ Style/ClassAndModuleChildren:
34
+ Exclude:
35
+ - spec/**/*_spec.rb
36
+
33
37
  AllCops:
34
38
  TargetRubyVersion: 2.5
35
39
  Exclude:
@@ -1,10 +1,25 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
1
8
  ## [Unreleased]
2
9
 
3
- * Fixed controller action hooks context [@povilasjurcys](https://github.com/povilasjurcys).
4
- * Added options for controller actions [@vastas1996](https://github.com/vastas1996).
10
+ * Added/Changed/Deprecated/Removed/Fixed/Security: YOUR CHANGE HERE
11
+
12
+ ## 0.5.2 (2019-04-24)
13
+
14
+ * Fixed: do not crash when using Connection types in non Ruby on Rails project [@povilasjurcys](https://github.com/povilasjurcys).
15
+
16
+ ## 0.5.1 (2019-04-10)
17
+
18
+ * Fixed: controller action hooks context [@povilasjurcys](https://github.com/povilasjurcys).
19
+ * Added: options for controller actions [@vastas1996](https://github.com/vastas1996).
5
20
 
6
21
  ## 0.5.0 (2019-04-03)
7
22
 
8
- * [#56](https://github.com/ashkan18/graphlient/pull/56) Added GraphQL input type generators [@povilasjurcys](https://github.com/povilasjurcys).
9
- * Added CHANGELOG [@povilasjurcys](https://github.com/povilasjurcys).
10
- * Fixed GraphQL word typos in documentation and code [@povilasjurcys](https://github.com/povilasjurcys).
23
+ * Added: GraphQL input type generators [@povilasjurcys](https://github.com/povilasjurcys).
24
+ * Added: CHANGELOG [@povilasjurcys](https://github.com/povilasjurcys).
25
+ * Fixed: GraphQL word typos in documentation and code [@povilasjurcys](https://github.com/povilasjurcys).
data/Gemfile CHANGED
@@ -10,7 +10,6 @@ group :development do
10
10
  end
11
11
 
12
12
  group :test do
13
- gem 'activerecord'
14
13
  gem 'codecov', require: false
15
14
  gem 'mongoid'
16
15
  gem 'simplecov', require: false
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- graphql_rails (0.5.1)
4
+ graphql_rails (0.5.2)
5
5
  activesupport (>= 4)
6
6
  graphql (~> 1)
7
7
 
@@ -26,5 +26,6 @@ Gem::Specification.new do |spec|
26
26
  spec.add_development_dependency 'bundler', '~> 1.16'
27
27
  spec.add_development_dependency 'rake', '~> 10.0'
28
28
  spec.add_development_dependency 'rspec', '~> 3.0'
29
+ spec.add_development_dependency 'activerecord'
29
30
  spec.add_development_dependency 'pry-byebug'
30
31
  end
@@ -4,6 +4,7 @@ require 'graphql_rails/attribute'
4
4
  require 'graphql_rails/model/graphql_type_builder'
5
5
  require 'graphql_rails/model/input'
6
6
  require 'graphql_rails/model/configurable'
7
+ require 'graphql_rails/model/configuration/count_items'
7
8
 
8
9
  module GraphqlRails
9
10
  module Model
@@ -11,12 +12,6 @@ module GraphqlRails
11
12
  class Configuration
12
13
  include Configurable
13
14
 
14
- COUNT_TOTAL_ITEMS = lambda do |obj, _args, _ctx|
15
- obj_nodes = obj.nodes
16
- obj_nodes = obj_nodes.except(:offset) if obj_nodes.is_a?(ActiveRecord::Relation)
17
- obj_nodes.size
18
- end
19
-
20
15
  def initialize(model_class)
21
16
  @model_class = model_class
22
17
  end
@@ -53,7 +48,7 @@ module GraphqlRails
53
48
  def connection_type
54
49
  @connection_type ||= begin
55
50
  graphql_type.define_connection do
56
- field :total, types.Int, resolve: COUNT_TOTAL_ITEMS
51
+ field :total, types.Int, resolve: CountItems
57
52
  end
58
53
  end
59
54
  end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GraphqlRails
4
+ module Model
5
+ class Configuration
6
+ # Used when generating ConnectionType.
7
+ # It handles all the logic which is related with counting total items
8
+ class CountItems
9
+ def self.call(*args)
10
+ new(*args).call
11
+ end
12
+
13
+ def initialize(graphql_object, _args, _ctx)
14
+ @graphql_object = graphql_object
15
+ end
16
+
17
+ def call
18
+ if active_record?
19
+ list.except(:offset).size
20
+ else
21
+ list.size
22
+ end
23
+ end
24
+
25
+ private
26
+
27
+ attr_reader :graphql_object
28
+
29
+ def list
30
+ graphql_object.nodes
31
+ end
32
+
33
+ def active_record?
34
+ defined?(ActiveRecord) && list.is_a?(ActiveRecord::Relation)
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GraphqlRails
4
- VERSION = '0.5.1'
4
+ VERSION = '0.5.2'
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: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Povilas Jurčys
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-04-10 00:00:00.000000000 Z
11
+ date: 2019-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '3.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: activerecord
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: pry-byebug
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -147,6 +161,7 @@ files:
147
161
  - lib/graphql_rails/model.rb
148
162
  - lib/graphql_rails/model/configurable.rb
149
163
  - lib/graphql_rails/model/configuration.rb
164
+ - lib/graphql_rails/model/configuration/count_items.rb
150
165
  - lib/graphql_rails/model/graphql_input_type_builder.rb
151
166
  - lib/graphql_rails/model/graphql_type_builder.rb
152
167
  - lib/graphql_rails/model/input.rb
@@ -179,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
179
194
  version: '0'
180
195
  requirements: []
181
196
  rubyforge_project:
182
- rubygems_version: 2.7.6
197
+ rubygems_version: 2.7.7
183
198
  signing_key:
184
199
  specification_version: 4
185
200
  summary: GraphQL server and client for rails