graphql_rails 0.5.1 → 0.5.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.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/CHANGELOG.md +20 -5
- data/Gemfile +0 -1
- data/Gemfile.lock +1 -1
- data/graphql_rails.gemspec +1 -0
- data/lib/graphql_rails/model/configuration.rb +2 -7
- data/lib/graphql_rails/model/configuration/count_items.rb +39 -0
- data/lib/graphql_rails/version.rb +1 -1
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d31436f40d036cd543c69a2b59e442d2498eb6349d61c4454dc9376e0caf4de0
|
4
|
+
data.tar.gz: 9b5041b648314fbff349e614e9b1f6be43f94bff32490f8de0dc4a23bb28c6a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72d4881a3aa604c19f38f53e4b77fdea562e7b804d8cec6a125789da32b6b215c298f5dcd1a747680a72c2e65571d0f30ab7b47597758fbb632bf21731f9bf70
|
7
|
+
data.tar.gz: 0a7ec0c5d6bf383c89b82109a4c120137e470f7e187ab8a3ab791840706abd6b0a49933b1bcead76437603fff546fc66ebd024fad8067bea6558d60499c587b0
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -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
|
4
|
-
|
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
|
-
*
|
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
data/Gemfile.lock
CHANGED
data/graphql_rails.gemspec
CHANGED
@@ -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:
|
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
|
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.
|
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-
|
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.
|
197
|
+
rubygems_version: 2.7.7
|
183
198
|
signing_key:
|
184
199
|
specification_version: 4
|
185
200
|
summary: GraphQL server and client for rails
|