graphiti 1.3.1 → 1.3.5
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/graphiti/resource/dsl.rb +11 -3
- data/lib/graphiti/schema.rb +6 -4
- data/lib/graphiti/serializer.rb +2 -1
- data/lib/graphiti/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4add496faa756dcfd1d5980628d722b0d41bc9acfdf27d04cb55db15d7e3bba7
|
4
|
+
data.tar.gz: a991debe7ba1204c30388b4b3174e7fdfaf7446e7d777f3030d18296975a096e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6e1253418d35ce742bc1365e1f18268548ac62f180d6c606420df18f75261d3a562495e2b0213788993bdb34102b5450664e6f5124cdf713cdb3ad40af71b1f
|
7
|
+
data.tar.gz: dd65210486a8b212571184d71c28feaaeb3540e85a3964ed54248a193034ebece099bba186672488642093a727d47d021210ee56f26d6e37739cc72f6d52a414
|
@@ -9,7 +9,11 @@ module Graphiti
|
|
9
9
|
opts = args.extract_options!
|
10
10
|
type_override = args[0]
|
11
11
|
|
12
|
-
if (att =
|
12
|
+
if (att = (attributes[name] || extra_attributes[name]))
|
13
|
+
# We're opting in to filtering, so force this
|
14
|
+
# UNLESS the filter is guarded at the attribute level
|
15
|
+
att[:filterable] = true if att[:filterable] == false
|
16
|
+
|
13
17
|
aliases = [name, opts[:aliases]].flatten.compact
|
14
18
|
operators = FilterOperators.build(self, att[:type], opts, &blk)
|
15
19
|
|
@@ -23,6 +27,8 @@ module Graphiti
|
|
23
27
|
end
|
24
28
|
|
25
29
|
required = att[:filterable] == :required || !!opts[:required]
|
30
|
+
schema = !!opts[:via_attribute_dsl] ? att[:schema] : opts[:schema] != false
|
31
|
+
|
26
32
|
config[:filters][name.to_sym] = {
|
27
33
|
aliases: aliases,
|
28
34
|
name: name.to_sym,
|
@@ -32,6 +38,7 @@ module Graphiti
|
|
32
38
|
single: !!opts[:single],
|
33
39
|
dependencies: opts[:dependent],
|
34
40
|
required: required,
|
41
|
+
schema: schema,
|
35
42
|
operators: operators.to_hash,
|
36
43
|
allow_nil: opts.fetch(:allow_nil, filters_accept_nil_by_default),
|
37
44
|
deny_empty: opts.fetch(:deny_empty, filters_deny_empty_by_default)
|
@@ -130,7 +137,7 @@ module Graphiti
|
|
130
137
|
options[:sortable] ? sort(name) : config[:sorts].delete(name)
|
131
138
|
|
132
139
|
if options[:filterable]
|
133
|
-
filter(name, allow: options[:allow])
|
140
|
+
filter(name, allow: options[:allow], via_attribute_dsl: true)
|
134
141
|
else
|
135
142
|
config[:filters].delete(name)
|
136
143
|
end
|
@@ -144,7 +151,8 @@ module Graphiti
|
|
144
151
|
readable: true,
|
145
152
|
writable: false,
|
146
153
|
sortable: false,
|
147
|
-
filterable: false
|
154
|
+
filterable: false,
|
155
|
+
schema: true
|
148
156
|
}
|
149
157
|
options = defaults.merge(options)
|
150
158
|
attribute_option(options, :readable)
|
data/lib/graphiti/schema.rb
CHANGED
@@ -153,6 +153,8 @@ module Graphiti
|
|
153
153
|
def extra_attributes(resource)
|
154
154
|
{}.tap do |attrs|
|
155
155
|
resource.extra_attributes.each_pair do |name, config|
|
156
|
+
next unless config[:schema]
|
157
|
+
|
156
158
|
attrs[name] = {
|
157
159
|
type: config[:type].to_s,
|
158
160
|
readable: flag(config[:readable]),
|
@@ -181,11 +183,11 @@ module Graphiti
|
|
181
183
|
def sorts(resource)
|
182
184
|
{}.tap do |s|
|
183
185
|
resource.sorts.each_pair do |name, sort|
|
184
|
-
|
186
|
+
attr = resource.all_attributes[name]
|
187
|
+
next unless attr[:schema]
|
185
188
|
|
186
189
|
config = {}
|
187
190
|
config[:only] = sort[:only] if sort[:only]
|
188
|
-
attr = resource.attributes[name]
|
189
191
|
if attr[:sortable].is_a?(Symbol)
|
190
192
|
config[:guard] = true
|
191
193
|
end
|
@@ -197,7 +199,7 @@ module Graphiti
|
|
197
199
|
def filters(resource)
|
198
200
|
{}.tap do |f|
|
199
201
|
resource.filters.each_pair do |name, filter|
|
200
|
-
next unless resource.
|
202
|
+
next unless resource.filters[name][:schema]
|
201
203
|
|
202
204
|
config = {
|
203
205
|
type: filter[:type].to_s,
|
@@ -209,7 +211,7 @@ module Graphiti
|
|
209
211
|
config[:deny] = filter[:deny].map(&:to_s) if filter[:deny]
|
210
212
|
config[:dependencies] = filter[:dependencies].map(&:to_s) if filter[:dependencies]
|
211
213
|
|
212
|
-
attr = resource.
|
214
|
+
attr = resource.all_attributes[name]
|
213
215
|
if attr[:filterable].is_a?(Symbol)
|
214
216
|
if attr[:filterable] == :required
|
215
217
|
config[:required] = true
|
data/lib/graphiti/serializer.rb
CHANGED
@@ -25,8 +25,9 @@ module Graphiti
|
|
25
25
|
|
26
26
|
# See #requested_relationships
|
27
27
|
def self.relationship(name, options = {}, &block)
|
28
|
+
prev = Util::Hash.deep_dup(field_condition_blocks)
|
28
29
|
super
|
29
|
-
field_condition_blocks
|
30
|
+
self.field_condition_blocks = prev
|
30
31
|
_register_condition(relationship_condition_blocks, name, options)
|
31
32
|
end
|
32
33
|
|
data/lib/graphiti/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphiti
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lee Richmond
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jsonapi-serializable
|