graphiform 0.2.4 → 0.2.9
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/lib/graphiform.rb +1 -0
- data/lib/graphiform/core.rb +13 -1
- data/lib/graphiform/fields.rb +28 -3
- data/lib/graphiform/skeleton.rb +8 -7
- data/lib/graphiform/sort_enum.rb +8 -0
- data/lib/graphiform/version.rb +1 -1
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 841f7ddfa6fd9f56cda166df64e77ec0d94fac684c872ce44b5fc024afe3d433
|
4
|
+
data.tar.gz: 10c339a1f949bf05dfa2dcf94a8bf3332f3a1c468699c605ab8ac60966644fd0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e72009f747cf7bf8b6655940eb443900cf2c08e419cb25e1786aafc1b36347fb0f6916bc7d837a82681e46280a6bc5b6fe617b80ba081556f7acf319f01ed40b
|
7
|
+
data.tar.gz: d13b40bf891ccad27f83e7a23c55b20b5c94c594bc83d28ee07b762aca7a5740030aeaec20789d2cccc590ca701a566e0257555d5e0c2ee67fe02608e61c25ec
|
data/lib/graphiform.rb
CHANGED
data/lib/graphiform/core.rb
CHANGED
@@ -52,6 +52,15 @@ module Graphiform
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
+
def graphql_grouping
|
56
|
+
local_demodulized_name = demodulized_name
|
57
|
+
Helpers.get_const_or_create(local_demodulized_name, ::Inputs::Groupings) do
|
58
|
+
Class.new(::Inputs::Groupings::BaseGrouping) do
|
59
|
+
graphql_name "#{local_demodulized_name}Grouping"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
55
64
|
def graphql_edge
|
56
65
|
Helpers.get_const_or_create("#{demodulized_name}Edge", ::Types) do
|
57
66
|
node_type = graphql_type
|
@@ -99,9 +108,10 @@ module Graphiform
|
|
99
108
|
@value
|
100
109
|
end
|
101
110
|
|
102
|
-
def apply_built_ins(where: nil, sort: nil, **)
|
111
|
+
def apply_built_ins(where: nil, sort: nil, group: nil, **)
|
103
112
|
@value = @value.apply_filters(where.to_h) if where.present? && @value.respond_to?(:apply_filters)
|
104
113
|
@value = @value.apply_sorts(sort.to_h) if sort.present? && @value.respond_to?(:apply_sorts)
|
114
|
+
@value = @value.apply_groupings(group.to_h) if group.present? && @value.respond_to?(:apply_groupings)
|
105
115
|
|
106
116
|
@value
|
107
117
|
end
|
@@ -115,6 +125,7 @@ module Graphiform
|
|
115
125
|
|
116
126
|
local_graphql_filter = graphql_filter
|
117
127
|
local_graphql_sort = graphql_sort
|
128
|
+
local_graphql_grouping = graphql_grouping
|
118
129
|
|
119
130
|
model = self
|
120
131
|
@base_resolver.class_eval do
|
@@ -126,6 +137,7 @@ module Graphiform
|
|
126
137
|
|
127
138
|
argument :where, local_graphql_filter, required: false
|
128
139
|
argument :sort, local_graphql_sort, required: false unless local_graphql_sort.arguments.empty?
|
140
|
+
argument :group, local_graphql_grouping, required: false unless local_graphql_grouping.arguments.empty?
|
129
141
|
end
|
130
142
|
end
|
131
143
|
|
data/lib/graphiform/fields.rb
CHANGED
@@ -21,6 +21,7 @@ module Graphiform
|
|
21
21
|
|
22
22
|
graphql_add_scopes_to_filter(name, as || name)
|
23
23
|
graphql_field_to_sort(name, as || name)
|
24
|
+
graphql_field_to_grouping(name, as || name)
|
24
25
|
end
|
25
26
|
|
26
27
|
def graphql_writable_field(
|
@@ -120,9 +121,11 @@ module Graphiform
|
|
120
121
|
type = association_def.klass.graphql_filter
|
121
122
|
end
|
122
123
|
|
123
|
-
|
124
|
+
filter_only_by_scopes = added_scopes.select do |scope_def|
|
125
|
+
!scope_def.options || scope_def.options[:type].blank? || scope_def.options[:type] == :enum
|
126
|
+
end
|
124
127
|
|
125
|
-
|
128
|
+
filter_only_by_scopes.each do |added_scope|
|
126
129
|
scope_argument_type = type || added_scope.options[:argument_type]
|
127
130
|
if added_scope.options[:type] == :enum
|
128
131
|
enum = graphql_create_enum(name)
|
@@ -157,7 +160,7 @@ module Graphiform
|
|
157
160
|
column_def = column(as || name)
|
158
161
|
association_def = association(as || name)
|
159
162
|
|
160
|
-
type = ::
|
163
|
+
type = ::Graphiform::SortEnum if column_def.present?
|
161
164
|
type = association_def.klass.graphql_sort if Helpers.association_arguments_valid?(association_def, :graphql_sort)
|
162
165
|
|
163
166
|
return if type.blank?
|
@@ -175,6 +178,28 @@ module Graphiform
|
|
175
178
|
end
|
176
179
|
end
|
177
180
|
|
181
|
+
def graphql_field_to_grouping(name, as)
|
182
|
+
column_def = column(as || name)
|
183
|
+
association_def = association(as || name)
|
184
|
+
|
185
|
+
type = GraphQL::Types::Boolean if column_def.present?
|
186
|
+
type = association_def.klass.graphql_grouping if Helpers.association_arguments_valid?(association_def, :graphql_grouping)
|
187
|
+
|
188
|
+
return if type.blank?
|
189
|
+
|
190
|
+
local_graphql_grouping = graphql_grouping
|
191
|
+
|
192
|
+
local_graphql_grouping.class_eval do
|
193
|
+
argument(
|
194
|
+
name,
|
195
|
+
type,
|
196
|
+
required: false,
|
197
|
+
as: as,
|
198
|
+
method_access: false
|
199
|
+
)
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
178
203
|
def graphql_add_field_to_type(
|
179
204
|
field_name,
|
180
205
|
type,
|
data/lib/graphiform/skeleton.rb
CHANGED
@@ -45,6 +45,14 @@ module Graphiform
|
|
45
45
|
Class.new(::GraphQL::Schema::InputObject)
|
46
46
|
end
|
47
47
|
|
48
|
+
Helpers.get_const_or_create('Groupings', ::Inputs) do
|
49
|
+
Module.new
|
50
|
+
end
|
51
|
+
|
52
|
+
Helpers.get_const_or_create('BaseGrouping', ::Inputs::Groupings) do
|
53
|
+
Class.new(::GraphQL::Schema::InputObject)
|
54
|
+
end
|
55
|
+
|
48
56
|
# Resolvers
|
49
57
|
Helpers.get_const_or_create('Resolvers') do
|
50
58
|
Module.new
|
@@ -80,12 +88,5 @@ module Graphiform
|
|
80
88
|
Helpers.get_const_or_create('BaseEnum', ::Enums) do
|
81
89
|
Class.new(::GraphQL::Schema::Enum)
|
82
90
|
end
|
83
|
-
|
84
|
-
Helpers.get_const_or_create('Sort', ::Enums) do
|
85
|
-
Class.new(::Enums::BaseEnum) do
|
86
|
-
value 'ASC', 'Sort results in ascending order'
|
87
|
-
value 'DESC', 'Sort results in descending order'
|
88
|
-
end
|
89
|
-
end
|
90
91
|
end
|
91
92
|
end
|
data/lib/graphiform/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphiform
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jayce.pulsipher
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.2.
|
47
|
+
version: 0.2.7
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.2.
|
54
|
+
version: 0.2.7
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: appraisal
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -124,6 +124,7 @@ files:
|
|
124
124
|
- lib/graphiform/fields.rb
|
125
125
|
- lib/graphiform/helpers.rb
|
126
126
|
- lib/graphiform/skeleton.rb
|
127
|
+
- lib/graphiform/sort_enum.rb
|
127
128
|
- lib/graphiform/version.rb
|
128
129
|
- lib/tasks/graphiform_tasks.rake
|
129
130
|
homepage: https://github.com/3-form/graphiform
|
@@ -145,7 +146,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
146
|
- !ruby/object:Gem::Version
|
146
147
|
version: '0'
|
147
148
|
requirements: []
|
148
|
-
|
149
|
+
rubyforge_project:
|
150
|
+
rubygems_version: 2.7.7
|
149
151
|
signing_key:
|
150
152
|
specification_version: 4
|
151
153
|
summary: Generate GraphQL types, inputs, resolvers, queries, and connections based
|