graphiti 1.0.rc.21 → 1.0.rc.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.standard.yml +14 -0
- data/.travis.yml +31 -2
- data/Appraisals +16 -10
- data/Gemfile +5 -5
- data/Guardfile +2 -2
- data/README.md +1 -1
- data/Rakefile +4 -4
- data/exe/graphiti +1 -1
- data/gemfiles/rails_4.gemfile +0 -1
- data/gemfiles/rails_5.gemfile +0 -1
- data/gemfiles/rails_6.gemfile +19 -0
- data/graphiti.gemspec +15 -14
- data/lib/generators/graphiti/api_test_generator.rb +16 -16
- data/lib/generators/graphiti/generator_mixin.rb +7 -7
- data/lib/generators/graphiti/install_generator.rb +19 -19
- data/lib/generators/graphiti/resource_generator.rb +19 -19
- data/lib/generators/graphiti/resource_test_generator.rb +10 -10
- data/lib/graphiti.rb +24 -26
- data/lib/graphiti/adapters/abstract.rb +25 -39
- data/lib/graphiti/adapters/active_record.rb +43 -49
- data/lib/graphiti/adapters/active_record/many_to_many_sideload.rb +33 -11
- data/lib/graphiti/adapters/graphiti_api.rb +16 -16
- data/lib/graphiti/adapters/null.rb +0 -12
- data/lib/graphiti/cli.rb +7 -7
- data/lib/graphiti/configuration.rb +14 -15
- data/lib/graphiti/context.rb +1 -1
- data/lib/graphiti/debugger.rb +22 -26
- data/lib/graphiti/delegates/pagination.rb +9 -9
- data/lib/graphiti/deserializer.rb +7 -9
- data/lib/graphiti/errors.rb +119 -119
- data/lib/graphiti/extensions/boolean_attribute.rb +1 -1
- data/lib/graphiti/extensions/extra_attribute.rb +1 -1
- data/lib/graphiti/extensions/temp_id.rb +1 -1
- data/lib/graphiti/filter_operators.rb +6 -0
- data/lib/graphiti/hash_renderer.rb +15 -15
- data/lib/graphiti/jsonapi_serializable_ext.rb +1 -1
- data/lib/graphiti/query.rb +35 -35
- data/lib/graphiti/railtie.rb +14 -10
- data/lib/graphiti/renderer.rb +2 -2
- data/lib/graphiti/resource.rb +4 -6
- data/lib/graphiti/resource/configuration.rb +9 -13
- data/lib/graphiti/resource/documentation.rb +4 -2
- data/lib/graphiti/resource/dsl.rb +21 -25
- data/lib/graphiti/resource/interface.rb +3 -3
- data/lib/graphiti/resource/links.rb +14 -14
- data/lib/graphiti/resource/persistence.rb +9 -9
- data/lib/graphiti/resource/polymorphism.rb +3 -3
- data/lib/graphiti/resource/remote.rb +3 -3
- data/lib/graphiti/resource/sideloading.rb +5 -5
- data/lib/graphiti/resource_proxy.rb +12 -12
- data/lib/graphiti/schema.rb +27 -26
- data/lib/graphiti/schema_diff.rb +10 -10
- data/lib/graphiti/scope.rb +12 -16
- data/lib/graphiti/scoping/base.rb +5 -5
- data/lib/graphiti/scoping/default_filter.rb +1 -1
- data/lib/graphiti/scoping/filter.rb +15 -24
- data/lib/graphiti/scoping/filterable.rb +5 -5
- data/lib/graphiti/scoping/paginate.rb +1 -1
- data/lib/graphiti/scoping/sort.rb +7 -7
- data/lib/graphiti/serializer.rb +8 -4
- data/lib/graphiti/sideload.rb +23 -39
- data/lib/graphiti/sideload/belongs_to.rb +2 -2
- data/lib/graphiti/sideload/has_many.rb +1 -1
- data/lib/graphiti/sideload/many_to_many.rb +18 -2
- data/lib/graphiti/sideload/polymorphic_belongs_to.rb +14 -8
- data/lib/graphiti/stats/dsl.rb +7 -1
- data/lib/graphiti/tasks.rb +10 -10
- data/lib/graphiti/types.rb +98 -98
- data/lib/graphiti/util/attribute_check.rb +1 -1
- data/lib/graphiti/util/class.rb +3 -3
- data/lib/graphiti/util/field_params.rb +1 -1
- data/lib/graphiti/util/hash.rb +19 -1
- data/lib/graphiti/util/link.rb +15 -19
- data/lib/graphiti/util/persistence.rb +17 -22
- data/lib/graphiti/util/relationship_payload.rb +2 -2
- data/lib/graphiti/util/remote_params.rb +12 -12
- data/lib/graphiti/util/remote_serializer.rb +2 -2
- data/lib/graphiti/util/serializer_attributes.rb +20 -25
- data/lib/graphiti/util/serializer_relationships.rb +17 -18
- data/lib/graphiti/util/sideload.rb +1 -1
- data/lib/graphiti/util/transaction_hooks_recorder.rb +3 -2
- data/lib/graphiti/version.rb +1 -1
- metadata +22 -6
data/lib/graphiti/errors.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Graphiti
|
2
2
|
module Errors
|
3
|
-
class Base < StandardError;end
|
3
|
+
class Base < StandardError; end
|
4
4
|
|
5
5
|
class AdapterNotImplemented < Base
|
6
6
|
def initialize(adapter, attribute, method)
|
@@ -10,8 +10,8 @@ module Graphiti
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def message
|
13
|
-
|
14
|
-
The adapter #{@adapter.class} does not implement method '#{@method}', which was requested for attribute '#{@attribute}'. Add this method to your adapter to support this filter operator.
|
13
|
+
<<~MSG
|
14
|
+
The adapter #{@adapter.class} does not implement method '#{@method}', which was requested for attribute '#{@attribute}'. Add this method to your adapter to support this filter operator.
|
15
15
|
MSG
|
16
16
|
end
|
17
17
|
end
|
@@ -24,8 +24,8 @@ The adapter #{@adapter.class} does not implement method '#{@method}', which was
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def message
|
27
|
-
|
28
|
-
#{@parent_resource_class} sideload :#{@name} - #{@message}
|
27
|
+
<<~MSG
|
28
|
+
#{@parent_resource_class} sideload :#{@name} - #{@message}
|
29
29
|
MSG
|
30
30
|
end
|
31
31
|
end
|
@@ -53,8 +53,8 @@ The adapter #{@adapter.class} does not implement method '#{@method}', which was
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def message
|
56
|
-
|
57
|
-
#{@resource_class}: Tried to pass block to .#{@method_name}, which only accepts a method name.
|
56
|
+
<<~MSG
|
57
|
+
#{@resource_class}: Tried to pass block to .#{@method_name}, which only accepts a method name.
|
58
58
|
MSG
|
59
59
|
end
|
60
60
|
end
|
@@ -65,8 +65,8 @@ The adapter #{@adapter.class} does not implement method '#{@method}', which was
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def message
|
68
|
-
|
69
|
-
#{@resource_class}: Tried to perform write operation. Writes are not supported for remote resources - hit the endpoint directly.
|
68
|
+
<<~MSG
|
69
|
+
#{@resource_class}: Tried to perform write operation. Writes are not supported for remote resources - hit the endpoint directly.
|
70
70
|
MSG
|
71
71
|
end
|
72
72
|
end
|
@@ -80,8 +80,8 @@ The adapter #{@adapter.class} does not implement method '#{@method}', which was
|
|
80
80
|
end
|
81
81
|
|
82
82
|
def message
|
83
|
-
|
84
|
-
#{@resource.class}: Tried to filter #{@filter_name.inspect} on operator #{@operator.inspect}, but not supported! Supported operators are #{@supported}.
|
83
|
+
<<~MSG
|
84
|
+
#{@resource.class}: Tried to filter #{@filter_name.inspect} on operator #{@operator.inspect}, but not supported! Supported operators are #{@supported}.
|
85
85
|
MSG
|
86
86
|
end
|
87
87
|
end
|
@@ -93,8 +93,8 @@ The adapter #{@adapter.class} does not implement method '#{@method}', which was
|
|
93
93
|
end
|
94
94
|
|
95
95
|
def message
|
96
|
-
|
97
|
-
#{@resource.class}: Tried to persist association #{@sideload.name.inspect} but marked writable: false
|
96
|
+
<<~MSG
|
97
|
+
#{@resource.class}: Tried to persist association #{@sideload.name.inspect} but marked writable: false
|
98
98
|
MSG
|
99
99
|
end
|
100
100
|
end
|
@@ -106,14 +106,14 @@ The adapter #{@adapter.class} does not implement method '#{@method}', which was
|
|
106
106
|
end
|
107
107
|
|
108
108
|
def message
|
109
|
-
|
110
|
-
#{@sideload.parent_resource.class.name}: tried to sideload #{@sideload.name.inspect}, but more than one #{@sideload.parent_resource.model.name} was passed!
|
109
|
+
<<~MSG
|
110
|
+
#{@sideload.parent_resource.class.name}: tried to sideload #{@sideload.name.inspect}, but more than one #{@sideload.parent_resource.model.name} was passed!
|
111
111
|
|
112
|
-
This is because you marked the sideload #{@sideload.name.inspect} with single: true
|
112
|
+
This is because you marked the sideload #{@sideload.name.inspect} with single: true
|
113
113
|
|
114
|
-
You might have done this because the sideload can only be loaded from a :show endpoint, and :index would be too expensive.
|
114
|
+
You might have done this because the sideload can only be loaded from a :show endpoint, and :index would be too expensive.
|
115
115
|
|
116
|
-
Remove the single: true option to bypass this error.
|
116
|
+
Remove the single: true option to bypass this error.
|
117
117
|
MSG
|
118
118
|
end
|
119
119
|
end
|
@@ -127,8 +127,8 @@ Remove the single: true option to bypass this error.
|
|
127
127
|
end
|
128
128
|
|
129
129
|
def message
|
130
|
-
|
131
|
-
#{@resource.class.name}: tried to sort on attribute #{@attribute.inspect}, but passed #{@direction.inspect} when only #{@allowlist.inspect} is supported.
|
130
|
+
<<~MSG
|
131
|
+
#{@resource.class.name}: tried to sort on attribute #{@attribute.inspect}, but passed #{@direction.inspect} when only #{@allowlist.inspect} is supported.
|
132
132
|
MSG
|
133
133
|
end
|
134
134
|
end
|
@@ -140,8 +140,8 @@ Remove the single: true option to bypass this error.
|
|
140
140
|
end
|
141
141
|
|
142
142
|
def message
|
143
|
-
|
144
|
-
#{@resource_class.name}: called .on_extra_attribute #{@name.inspect}, but extra attribute #{@name.inspect} does not exist!
|
143
|
+
<<~MSG
|
144
|
+
#{@resource_class.name}: called .on_extra_attribute #{@name.inspect}, but extra attribute #{@name.inspect} does not exist!
|
145
145
|
MSG
|
146
146
|
end
|
147
147
|
end
|
@@ -156,8 +156,8 @@ Remove the single: true option to bypass this error.
|
|
156
156
|
def message
|
157
157
|
allow = @filter.values[0][:allow]
|
158
158
|
deny = @filter.values[0][:deny]
|
159
|
-
msg =
|
160
|
-
#{@resource.class.name}: tried to filter on #{@filter.keys[0].inspect}, but passed invalid value #{@value.inspect}.
|
159
|
+
msg = <<~MSG
|
160
|
+
#{@resource.class.name}: tried to filter on #{@filter.keys[0].inspect}, but passed invalid value #{@value.inspect}.
|
161
161
|
MSG
|
162
162
|
msg << "\nAllowlist: #{allow.inspect}" if allow
|
163
163
|
msg << "\nDenylist: #{deny.inspect}" if deny
|
@@ -173,12 +173,12 @@ Remove the single: true option to bypass this error.
|
|
173
173
|
end
|
174
174
|
|
175
175
|
def message
|
176
|
-
|
177
|
-
#{@resource_class.name}: Cannot link to sideload #{@sideload.name.inspect}!
|
176
|
+
<<~MSG
|
177
|
+
#{@resource_class.name}: Cannot link to sideload #{@sideload.name.inspect}!
|
178
178
|
|
179
|
-
Make sure the endpoint "#{@sideload.resource.endpoint[:full_path]}" exists with action #{@action.inspect}, or customize the endpoint for #{@sideload.resource.class.name}.
|
179
|
+
Make sure the endpoint "#{@sideload.resource.endpoint[:full_path]}" exists with action #{@action.inspect}, or customize the endpoint for #{@sideload.resource.class.name}.
|
180
180
|
|
181
|
-
If you do not wish to generate a link, pass link: false or set self.relationship_links_by_default = false.
|
181
|
+
If you do not wish to generate a link, pass link: false or set self.relationship_links_by_default = false.
|
182
182
|
MSG
|
183
183
|
end
|
184
184
|
end
|
@@ -191,10 +191,10 @@ If you do not wish to generate a link, pass link: false or set self.relationship
|
|
191
191
|
end
|
192
192
|
|
193
193
|
def message
|
194
|
-
|
195
|
-
#{@resource.class.name}: passed multiple values to filter #{@filter.keys[0].inspect}, which was marked single: true.
|
194
|
+
<<~MSG
|
195
|
+
#{@resource.class.name}: passed multiple values to filter #{@filter.keys[0].inspect}, which was marked single: true.
|
196
196
|
|
197
|
-
Value was: #{@value.inspect}
|
197
|
+
Value was: #{@value.inspect}
|
198
198
|
MSG
|
199
199
|
end
|
200
200
|
end
|
@@ -206,12 +206,12 @@ Value was: #{@value.inspect}
|
|
206
206
|
end
|
207
207
|
|
208
208
|
def message
|
209
|
-
|
210
|
-
#{@resource_class.name}: Tried to link sideload #{@sideload.name.inspect}, but cannot generate links!
|
209
|
+
<<~MSG
|
210
|
+
#{@resource_class.name}: Tried to link sideload #{@sideload.name.inspect}, but cannot generate links!
|
211
211
|
|
212
|
-
Graphiti.config.context_for_endpoint must be set to enable link generation:
|
212
|
+
Graphiti.config.context_for_endpoint must be set to enable link generation:
|
213
213
|
|
214
|
-
Graphiti.config.context_for_endpoint = ->(path, action) { ... }
|
214
|
+
Graphiti.config.context_for_endpoint = ->(path, action) { ... }
|
215
215
|
MSG
|
216
216
|
end
|
217
217
|
end
|
@@ -236,17 +236,17 @@ Graphiti.config.context_for_endpoint = ->(path, action) { ... }
|
|
236
236
|
def action
|
237
237
|
if @request
|
238
238
|
{
|
239
|
-
sortable:
|
240
|
-
filterable:
|
241
|
-
readable:
|
242
|
-
writable:
|
239
|
+
sortable: "sort on",
|
240
|
+
filterable: "filter on",
|
241
|
+
readable: "read",
|
242
|
+
writable: "write",
|
243
243
|
}[@flag]
|
244
244
|
else
|
245
245
|
{
|
246
|
-
sortable:
|
247
|
-
filterable:
|
248
|
-
readable:
|
249
|
-
writable:
|
246
|
+
sortable: "add sort",
|
247
|
+
filterable: "add filter",
|
248
|
+
readable: "read",
|
249
|
+
writable: "write",
|
250
250
|
}[@flag]
|
251
251
|
end
|
252
252
|
end
|
@@ -257,19 +257,19 @@ Graphiti.config.context_for_endpoint = ->(path, action) { ... }
|
|
257
257
|
else
|
258
258
|
@resource.name
|
259
259
|
end
|
260
|
-
name ||
|
260
|
+
name || "AnonymousResourceClass"
|
261
261
|
end
|
262
262
|
|
263
263
|
def message
|
264
264
|
msg = "#{resource_name}: Tried to #{action} attribute #{@name.inspect}"
|
265
|
-
if @exists
|
265
|
+
msg << if @exists
|
266
266
|
if @guard
|
267
|
-
|
267
|
+
", but the guard #{@guard.inspect} did not pass."
|
268
268
|
else
|
269
|
-
|
269
|
+
", but the attribute was marked #{@flag.inspect} => false."
|
270
270
|
end
|
271
271
|
else
|
272
|
-
|
272
|
+
", but could not find an attribute with that name."
|
273
273
|
end
|
274
274
|
msg
|
275
275
|
end
|
@@ -282,8 +282,8 @@ Graphiti.config.context_for_endpoint = ->(path, action) { ... }
|
|
282
282
|
end
|
283
283
|
|
284
284
|
def message
|
285
|
-
|
286
|
-
#{@resource.class.name}: passed filter with value #{@value.inspect}, and failed attempting to parse as JSON array.
|
285
|
+
<<~MSG
|
286
|
+
#{@resource.class.name}: passed filter with value #{@value.inspect}, and failed attempting to parse as JSON array.
|
287
287
|
MSG
|
288
288
|
end
|
289
289
|
end
|
@@ -296,18 +296,18 @@ Graphiti.config.context_for_endpoint = ->(path, action) { ... }
|
|
296
296
|
end
|
297
297
|
|
298
298
|
def message
|
299
|
-
|
300
|
-
#{@resource_class.name} cannot be called directly from endpoint #{@path}##{@action}!
|
299
|
+
<<~MSG
|
300
|
+
#{@resource_class.name} cannot be called directly from endpoint #{@path}##{@action}!
|
301
301
|
|
302
|
-
Either set a primary endpoint for this resource:
|
302
|
+
Either set a primary endpoint for this resource:
|
303
303
|
|
304
|
-
primary_endpoint '/my/url', [:index, :show, :create]
|
304
|
+
primary_endpoint '/my/url', [:index, :show, :create]
|
305
305
|
|
306
|
-
Or whitelist a secondary endpoint:
|
306
|
+
Or whitelist a secondary endpoint:
|
307
307
|
|
308
|
-
secondary_endoint '/my_url', [:index, :update]
|
308
|
+
secondary_endoint '/my_url', [:index, :update]
|
309
309
|
|
310
|
-
The current endpoints allowed for this resource are: #{@resource_class.endpoints.inspect}
|
310
|
+
The current endpoints allowed for this resource are: #{@resource_class.endpoints.inspect}
|
311
311
|
MSG
|
312
312
|
end
|
313
313
|
end
|
@@ -332,10 +332,10 @@ The current endpoints allowed for this resource are: #{@resource_class.endpoints
|
|
332
332
|
end
|
333
333
|
|
334
334
|
def message
|
335
|
-
|
336
|
-
Both '#{@resource_a}' and '#{@resource_b}' are associated to endpoint #{@path}##{@action}!
|
335
|
+
<<~MSG
|
336
|
+
Both '#{@resource_a}' and '#{@resource_b}' are associated to endpoint #{@path}##{@action}!
|
337
337
|
|
338
|
-
Only one resource can be associated to a given url/verb combination.
|
338
|
+
Only one resource can be associated to a given url/verb combination.
|
339
339
|
MSG
|
340
340
|
end
|
341
341
|
end
|
@@ -352,24 +352,24 @@ Only one resource can be associated to a given url/verb combination.
|
|
352
352
|
end
|
353
353
|
|
354
354
|
def model_message
|
355
|
-
|
356
|
-
#{@resource_class}: Tried to find Resource subclass with model #{@model.class}, but nothing found!
|
355
|
+
<<~MSG
|
356
|
+
#{@resource_class}: Tried to find Resource subclass with model #{@model.class}, but nothing found!
|
357
357
|
|
358
|
-
Make sure all your child classes are assigned and associated to the right models:
|
358
|
+
Make sure all your child classes are assigned and associated to the right models:
|
359
359
|
|
360
|
-
# One of these should be assocated to model #{@model.class}:
|
361
|
-
self.polymorphic = ['Subclass1Resource', 'Subclass2Resource']
|
360
|
+
# One of these should be assocated to model #{@model.class}:
|
361
|
+
self.polymorphic = ['Subclass1Resource', 'Subclass2Resource']
|
362
362
|
MSG
|
363
363
|
end
|
364
364
|
|
365
365
|
def type_message
|
366
|
-
|
367
|
-
#{@resource_class}: Tried to find Resource subclass with model #{@model.class}, but nothing found!
|
366
|
+
<<~MSG
|
367
|
+
#{@resource_class}: Tried to find Resource subclass with model #{@model.class}, but nothing found!
|
368
368
|
|
369
|
-
Make sure all your child classes are assigned and associated to the right models:
|
369
|
+
Make sure all your child classes are assigned and associated to the right models:
|
370
370
|
|
371
|
-
# One of these should be assocated to model #{@model.class}:
|
372
|
-
self.polymorphic = ['Subclass1Resource', 'Subclass2Resource']
|
371
|
+
# One of these should be assocated to model #{@model.class}:
|
372
|
+
self.polymorphic = ['Subclass1Resource', 'Subclass2Resource']
|
373
373
|
MSG
|
374
374
|
end
|
375
375
|
end
|
@@ -389,14 +389,14 @@ self.polymorphic = ['Subclass1Resource', 'Subclass2Resource']
|
|
389
389
|
end
|
390
390
|
|
391
391
|
def message
|
392
|
-
|
393
|
-
Tried to add filter-only attribute #{@name.inspect}, but type was missing!
|
392
|
+
<<~MSG
|
393
|
+
Tried to add filter-only attribute #{@name.inspect}, but type was missing!
|
394
394
|
|
395
|
-
If you are adding a filter that does not have a corresponding attribute, you must pass a type:
|
395
|
+
If you are adding a filter that does not have a corresponding attribute, you must pass a type:
|
396
396
|
|
397
|
-
filter :name, :string do <--- like this
|
398
|
-
|
399
|
-
end
|
397
|
+
filter :name, :string do <--- like this
|
398
|
+
# ... code ...
|
399
|
+
end
|
400
400
|
MSG
|
401
401
|
end
|
402
402
|
end
|
@@ -408,14 +408,14 @@ end
|
|
408
408
|
end
|
409
409
|
|
410
410
|
def message
|
411
|
-
|
412
|
-
Tried to add sort-only attribute #{@name.inspect}, but type was missing!
|
411
|
+
<<~MSG
|
412
|
+
Tried to add sort-only attribute #{@name.inspect}, but type was missing!
|
413
413
|
|
414
|
-
If you are adding a sort that does not have a corresponding attribute, you must pass a type:
|
414
|
+
If you are adding a sort that does not have a corresponding attribute, you must pass a type:
|
415
415
|
|
416
|
-
sort :name, :string do <--- like this
|
417
|
-
|
418
|
-
end
|
416
|
+
sort :name, :string do <--- like this
|
417
|
+
# ... code ...
|
418
|
+
end
|
419
419
|
MSG
|
420
420
|
end
|
421
421
|
end
|
@@ -429,12 +429,12 @@ end
|
|
429
429
|
end
|
430
430
|
|
431
431
|
def message
|
432
|
-
|
433
|
-
#{@resource.class}: Failed typecasting #{@name.inspect}! Given #{@value.inspect} but the following error was raised:
|
432
|
+
<<~MSG
|
433
|
+
#{@resource.class}: Failed typecasting #{@name.inspect}! Given #{@value.inspect} but the following error was raised:
|
434
434
|
|
435
|
-
#{@error.message}
|
435
|
+
#{@error.message}
|
436
436
|
|
437
|
-
#{@error.backtrace.join("\n")}
|
437
|
+
#{@error.backtrace.join("\n")}
|
438
438
|
MSG
|
439
439
|
end
|
440
440
|
end
|
@@ -445,10 +445,10 @@ end
|
|
445
445
|
end
|
446
446
|
|
447
447
|
def message
|
448
|
-
|
449
|
-
Could not find model for Resource '#{@resource_class}'
|
448
|
+
<<~MSG
|
449
|
+
Could not find model for Resource '#{@resource_class}'
|
450
450
|
|
451
|
-
Manually set model (self.model = MyModel) if it does not match name of the Resource.
|
451
|
+
Manually set model (self.model = MyModel) if it does not match name of the Resource.
|
452
452
|
MSG
|
453
453
|
end
|
454
454
|
end
|
@@ -461,10 +461,10 @@ Manually set model (self.model = MyModel) if it does not match name of the Resou
|
|
461
461
|
end
|
462
462
|
|
463
463
|
def message
|
464
|
-
|
465
|
-
Could not find type #{@type.inspect}! This was specified on attribute #{@attribute.inspect} within resource #{@resource.name}
|
464
|
+
<<~MSG
|
465
|
+
Could not find type #{@type.inspect}! This was specified on attribute #{@attribute.inspect} within resource #{@resource.name}
|
466
466
|
|
467
|
-
Valid types are: #{Graphiti::Types.map.keys.inspect}
|
467
|
+
Valid types are: #{Graphiti::Types.map.keys.inspect}
|
468
468
|
MSG
|
469
469
|
end
|
470
470
|
end
|
@@ -476,17 +476,17 @@ Valid types are: #{Graphiti::Types.map.keys.inspect}
|
|
476
476
|
end
|
477
477
|
|
478
478
|
def message
|
479
|
-
|
480
|
-
#{@sideload.parent_resource}: Found record with #{@sideload.grouper.field_name.inspect} == #{@name.inspect}, which is not registered!
|
479
|
+
<<~MSG
|
480
|
+
#{@sideload.parent_resource}: Found record with #{@sideload.grouper.field_name.inspect} == #{@name.inspect}, which is not registered!
|
481
481
|
|
482
|
-
Register the behavior of different types like so:
|
482
|
+
Register the behavior of different types like so:
|
483
483
|
|
484
|
-
polymorphic_belongs_to #{@sideload.name.inspect} do
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
end
|
484
|
+
polymorphic_belongs_to #{@sideload.name.inspect} do
|
485
|
+
group_by(#{@sideload.grouper.field_name.inspect}) do
|
486
|
+
on(#{@name.to_sym.inspect}) <---- this is what's missing
|
487
|
+
on(:foo).belongs_to :foo, resource: FooResource (long-hand example)
|
488
|
+
end
|
489
|
+
end
|
490
490
|
MSG
|
491
491
|
end
|
492
492
|
end
|
@@ -499,10 +499,10 @@ end
|
|
499
499
|
end
|
500
500
|
|
501
501
|
def message
|
502
|
-
|
503
|
-
#{@resource_class.name}: sideload #{@sideload.name.inspect} is associated with resource #{@sideload.resource.class.name}, but it does not have corresponding filter.
|
502
|
+
<<~MSG
|
503
|
+
#{@resource_class.name}: sideload #{@sideload.name.inspect} is associated with resource #{@sideload.resource.class.name}, but it does not have corresponding filter.
|
504
504
|
|
505
|
-
Expecting filter #{@filter.inspect} on #{@sideload.resource.class.name}.
|
505
|
+
Expecting filter #{@filter.inspect} on #{@sideload.resource.class.name}.
|
506
506
|
MSG
|
507
507
|
end
|
508
508
|
end
|
@@ -530,34 +530,34 @@ Expecting filter #{@filter.inspect} on #{@sideload.resource.class.name}.
|
|
530
530
|
end
|
531
531
|
|
532
532
|
def message
|
533
|
-
|
534
|
-
Could not find resource class for sideload '#{@sideload_name}' on Resource '#{@resource_class.name}'!
|
533
|
+
<<~MSG
|
534
|
+
Could not find resource class for sideload '#{@sideload_name}' on Resource '#{@resource_class.name}'!
|
535
535
|
|
536
|
-
Tried to find classes: #{@tried.join(
|
536
|
+
Tried to find classes: #{@tried.join(", ")}
|
537
537
|
|
538
|
-
If this follows a non-standard naming convention, use the :resource option to pass it directly:
|
538
|
+
If this follows a non-standard naming convention, use the :resource option to pass it directly:
|
539
539
|
|
540
|
-
has_many :comments, resource: SpecialCommentResource
|
540
|
+
has_many :comments, resource: SpecialCommentResource
|
541
541
|
MSG
|
542
542
|
end
|
543
543
|
end
|
544
544
|
|
545
545
|
class UnsupportedPagination < Base
|
546
546
|
def message
|
547
|
-
|
548
|
-
It looks like you are requesting pagination of a sideload, but there are > 1 parents.
|
547
|
+
<<~MSG
|
548
|
+
It looks like you are requesting pagination of a sideload, but there are > 1 parents.
|
549
549
|
|
550
|
-
This is not supported. In other words, you can do
|
550
|
+
This is not supported. In other words, you can do
|
551
551
|
|
552
|
-
/employees/1?include=positions&page[positions][size]=2
|
552
|
+
/employees/1?include=positions&page[positions][size]=2
|
553
553
|
|
554
|
-
But not
|
554
|
+
But not
|
555
555
|
|
556
|
-
/employees?include=positions&page[positions][size]=2
|
556
|
+
/employees?include=positions&page[positions][size]=2
|
557
557
|
|
558
|
-
This is a limitation of most datastores; the same issue exists in ActiveRecord.
|
558
|
+
This is a limitation of most datastores; the same issue exists in ActiveRecord.
|
559
559
|
|
560
|
-
Consider using a named relationship instead, e.g. 'has_one :top_comment'
|
560
|
+
Consider using a named relationship instead, e.g. 'has_one :top_comment'
|
561
561
|
MSG
|
562
562
|
end
|
563
563
|
end
|
@@ -579,7 +579,7 @@ Consider using a named relationship instead, e.g. 'has_one :top_comment'
|
|
579
579
|
end
|
580
580
|
|
581
581
|
def message
|
582
|
-
"#{@resource.class.name}: The requested included relationship \"#{@relationship}\" is not supported."
|
582
|
+
"#{@resource.class.name}: The requested included relationship \"#{@relationship}\" is not supported."
|
583
583
|
end
|
584
584
|
end
|
585
585
|
|
@@ -615,7 +615,7 @@ Consider using a named relationship instead, e.g. 'has_one :top_comment'
|
|
615
615
|
|
616
616
|
def message
|
617
617
|
if @attributes.length > 1
|
618
|
-
"The required filters \"#{@attributes.join(
|
618
|
+
"The required filters \"#{@attributes.join(", ")}\" on resource #{@resource.class} were not provided"
|
619
619
|
else
|
620
620
|
"The required filter \"#{@attributes[0]}\" on resource #{@resource.class} was not provided"
|
621
621
|
end
|