tapioca 0.10.1 → 0.10.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.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -3
  3. data/lib/tapioca/cli.rb +9 -10
  4. data/lib/tapioca/commands/annotations.rb +2 -2
  5. data/lib/tapioca/commands/check_shims.rb +2 -2
  6. data/lib/tapioca/commands/command.rb +2 -2
  7. data/lib/tapioca/commands/command_without_tracker.rb +18 -0
  8. data/lib/tapioca/commands/configure.rb +3 -3
  9. data/lib/tapioca/commands/dsl.rb +10 -10
  10. data/lib/tapioca/commands/gem.rb +5 -5
  11. data/lib/tapioca/commands/require.rb +2 -2
  12. data/lib/tapioca/commands/todo.rb +2 -2
  13. data/lib/tapioca/commands.rb +1 -0
  14. data/lib/tapioca/dsl/compiler.rb +3 -3
  15. data/lib/tapioca/dsl/compilers/aasm.rb +4 -4
  16. data/lib/tapioca/dsl/compilers/action_controller_helpers.rb +1 -1
  17. data/lib/tapioca/dsl/compilers/action_mailer.rb +1 -1
  18. data/lib/tapioca/dsl/compilers/active_job.rb +2 -2
  19. data/lib/tapioca/dsl/compilers/active_model_attributes.rb +1 -1
  20. data/lib/tapioca/dsl/compilers/active_record_associations.rb +13 -13
  21. data/lib/tapioca/dsl/compilers/active_record_columns.rb +22 -22
  22. data/lib/tapioca/dsl/compilers/active_record_fixtures.rb +1 -1
  23. data/lib/tapioca/dsl/compilers/active_record_relations.rb +49 -39
  24. data/lib/tapioca/dsl/compilers/active_record_scope.rb +3 -3
  25. data/lib/tapioca/dsl/compilers/active_record_typed_store.rb +2 -2
  26. data/lib/tapioca/dsl/compilers/active_storage.rb +2 -2
  27. data/lib/tapioca/dsl/compilers/active_support_current_attributes.rb +1 -1
  28. data/lib/tapioca/dsl/compilers/config.rb +2 -2
  29. data/lib/tapioca/dsl/compilers/graphql_input_object.rb +1 -0
  30. data/lib/tapioca/dsl/compilers/graphql_mutation.rb +1 -0
  31. data/lib/tapioca/dsl/compilers/identity_cache.rb +12 -12
  32. data/lib/tapioca/dsl/compilers/protobuf.rb +9 -9
  33. data/lib/tapioca/dsl/compilers/rails_generators.rb +2 -2
  34. data/lib/tapioca/dsl/compilers/sidekiq_worker.rb +1 -1
  35. data/lib/tapioca/dsl/compilers/smart_properties.rb +2 -2
  36. data/lib/tapioca/dsl/compilers/state_machines.rb +24 -24
  37. data/lib/tapioca/dsl/compilers/url_helpers.rb +1 -1
  38. data/lib/tapioca/dsl/compilers.rb +1 -1
  39. data/lib/tapioca/dsl/pipeline.rb +5 -4
  40. data/lib/tapioca/executor.rb +2 -2
  41. data/lib/tapioca/gem/events.rb +1 -1
  42. data/lib/tapioca/gem/listeners/foreign_constants.rb +3 -2
  43. data/lib/tapioca/gem/listeners/methods.rb +3 -3
  44. data/lib/tapioca/gem/listeners/mixins.rb +3 -7
  45. data/lib/tapioca/gem/listeners/source_location.rb +1 -1
  46. data/lib/tapioca/gem/listeners/subconstants.rb +1 -1
  47. data/lib/tapioca/gem/listeners/yard_doc.rb +1 -1
  48. data/lib/tapioca/gem/pipeline.rb +7 -3
  49. data/lib/tapioca/gemfile.rb +4 -4
  50. data/lib/tapioca/helpers/config_helper.rb +4 -4
  51. data/lib/tapioca/helpers/env_helper.rb +1 -0
  52. data/lib/tapioca/helpers/gem_helper.rb +17 -5
  53. data/lib/tapioca/helpers/rbi_files_helper.rb +3 -3
  54. data/lib/tapioca/helpers/rbi_helper.rb +1 -1
  55. data/lib/tapioca/helpers/sorbet_helper.rb +2 -2
  56. data/lib/tapioca/helpers/source_uri.rb +1 -1
  57. data/lib/tapioca/helpers/test/dsl_compiler.rb +1 -1
  58. data/lib/tapioca/loaders/dsl.rb +1 -1
  59. data/lib/tapioca/loaders/gem.rb +2 -2
  60. data/lib/tapioca/loaders/loader.rb +1 -1
  61. data/lib/tapioca/rbi_ext/model.rb +3 -3
  62. data/lib/tapioca/rbi_formatter.rb +2 -2
  63. data/lib/tapioca/runtime/generic_type_registry.rb +22 -2
  64. data/lib/tapioca/runtime/reflection.rb +8 -2
  65. data/lib/tapioca/runtime/trackers/autoload.rb +3 -0
  66. data/lib/tapioca/runtime/trackers/constant_definition.rb +13 -5
  67. data/lib/tapioca/runtime/trackers/mixin.rb +37 -36
  68. data/lib/tapioca/runtime/trackers/required_ancestor.rb +17 -4
  69. data/lib/tapioca/runtime/trackers/tracker.rb +45 -0
  70. data/lib/tapioca/runtime/trackers.rb +27 -1
  71. data/lib/tapioca/sorbet_ext/generic_name_patch.rb +17 -6
  72. data/lib/tapioca/version.rb +1 -1
  73. data/lib/tapioca.rb +0 -10
  74. metadata +4 -2
@@ -152,14 +152,14 @@ module Tapioca
152
152
  name: String,
153
153
  methods_to_add: T.nilable(T::Array[String]),
154
154
  return_type: String,
155
- parameters: T::Array[[String, String]]
155
+ parameters: T::Array[[String, String]],
156
156
  ).void
157
157
  end
158
158
  def add_method(klass, name, methods_to_add, return_type: "void", parameters: [])
159
159
  klass.create_method(
160
160
  name,
161
161
  parameters: parameters.map { |param, type| create_param(param, type: type) },
162
- return_type: return_type
162
+ return_type: return_type,
163
163
  ) if methods_to_add.nil? || methods_to_add.include?(name)
164
164
  end
165
165
 
@@ -168,7 +168,7 @@ module Tapioca
168
168
  klass: RBI::Scope,
169
169
  column_name: String,
170
170
  attribute_name: String,
171
- methods_to_add: T.nilable(T::Array[String])
171
+ methods_to_add: T.nilable(T::Array[String]),
172
172
  ).void
173
173
  end
174
174
  def add_methods_for_attribute(klass, column_name, attribute_name = column_name, methods_to_add = nil)
@@ -180,7 +180,7 @@ module Tapioca
180
180
  klass,
181
181
  attribute_name.to_s,
182
182
  methods_to_add,
183
- return_type: getter_type
183
+ return_type: getter_type,
184
184
  )
185
185
 
186
186
  # Added by ActiveRecord::AttributeMethods::Write
@@ -190,7 +190,7 @@ module Tapioca
190
190
  "#{attribute_name}=",
191
191
  methods_to_add,
192
192
  parameters: [["value", setter_type]],
193
- return_type: setter_type
193
+ return_type: setter_type,
194
194
  )
195
195
 
196
196
  # Added by ActiveRecord::AttributeMethods::Query
@@ -199,7 +199,7 @@ module Tapioca
199
199
  klass,
200
200
  "#{attribute_name}?",
201
201
  methods_to_add,
202
- return_type: "T::Boolean"
202
+ return_type: "T::Boolean",
203
203
  )
204
204
 
205
205
  # Added by ActiveRecord::AttributeMethods::Dirty
@@ -208,37 +208,37 @@ module Tapioca
208
208
  klass,
209
209
  "#{attribute_name}_before_last_save",
210
210
  methods_to_add,
211
- return_type: as_nilable_type(getter_type)
211
+ return_type: as_nilable_type(getter_type),
212
212
  )
213
213
  add_method(
214
214
  klass,
215
215
  "#{attribute_name}_change_to_be_saved",
216
216
  methods_to_add,
217
- return_type: "T.nilable([#{getter_type}, #{getter_type}])"
217
+ return_type: "T.nilable([#{getter_type}, #{getter_type}])",
218
218
  )
219
219
  add_method(
220
220
  klass,
221
221
  "#{attribute_name}_in_database",
222
222
  methods_to_add,
223
- return_type: as_nilable_type(getter_type)
223
+ return_type: as_nilable_type(getter_type),
224
224
  )
225
225
  add_method(
226
226
  klass,
227
227
  "saved_change_to_#{attribute_name}",
228
228
  methods_to_add,
229
- return_type: "T.nilable([#{getter_type}, #{getter_type}])"
229
+ return_type: "T.nilable([#{getter_type}, #{getter_type}])",
230
230
  )
231
231
  add_method(
232
232
  klass,
233
233
  "saved_change_to_#{attribute_name}?",
234
234
  methods_to_add,
235
- return_type: "T::Boolean"
235
+ return_type: "T::Boolean",
236
236
  )
237
237
  add_method(
238
238
  klass,
239
239
  "will_save_change_to_#{attribute_name}?",
240
240
  methods_to_add,
241
- return_type: "T::Boolean"
241
+ return_type: "T::Boolean",
242
242
  )
243
243
 
244
244
  # Added by ActiveModel::Dirty
@@ -247,47 +247,47 @@ module Tapioca
247
247
  klass,
248
248
  "#{attribute_name}_change",
249
249
  methods_to_add,
250
- return_type: "T.nilable([#{getter_type}, #{getter_type}])"
250
+ return_type: "T.nilable([#{getter_type}, #{getter_type}])",
251
251
  )
252
252
  add_method(
253
253
  klass,
254
254
  "#{attribute_name}_changed?",
255
255
  methods_to_add,
256
- return_type: "T::Boolean"
256
+ return_type: "T::Boolean",
257
257
  )
258
258
  add_method(
259
259
  klass,
260
260
  "#{attribute_name}_will_change!",
261
- methods_to_add
261
+ methods_to_add,
262
262
  )
263
263
  add_method(
264
264
  klass,
265
265
  "#{attribute_name}_was",
266
266
  methods_to_add,
267
- return_type: as_nilable_type(getter_type)
267
+ return_type: as_nilable_type(getter_type),
268
268
  )
269
269
  add_method(
270
270
  klass,
271
271
  "#{attribute_name}_previous_change",
272
272
  methods_to_add,
273
- return_type: "T.nilable([#{getter_type}, #{getter_type}])"
273
+ return_type: "T.nilable([#{getter_type}, #{getter_type}])",
274
274
  )
275
275
  add_method(
276
276
  klass,
277
277
  "#{attribute_name}_previously_changed?",
278
278
  methods_to_add,
279
- return_type: "T::Boolean"
279
+ return_type: "T::Boolean",
280
280
  )
281
281
  add_method(
282
282
  klass,
283
283
  "#{attribute_name}_previously_was",
284
284
  methods_to_add,
285
- return_type: as_nilable_type(getter_type)
285
+ return_type: as_nilable_type(getter_type),
286
286
  )
287
287
  add_method(
288
288
  klass,
289
289
  "restore_#{attribute_name}!",
290
- methods_to_add
290
+ methods_to_add,
291
291
  )
292
292
 
293
293
  # Added by ActiveRecord::AttributeMethods::BeforeTypeCast
@@ -296,13 +296,13 @@ module Tapioca
296
296
  klass,
297
297
  "#{attribute_name}_before_type_cast",
298
298
  methods_to_add,
299
- return_type: "T.untyped"
299
+ return_type: "T.untyped",
300
300
  )
301
301
  add_method(
302
302
  klass,
303
303
  "#{attribute_name}_came_from_user?",
304
304
  methods_to_add,
305
- return_type: "T::Boolean"
305
+ return_type: "T::Boolean",
306
306
  )
307
307
  end
308
308
  end
@@ -100,7 +100,7 @@ module Tapioca
100
100
  mod.create_method(
101
101
  name,
102
102
  parameters: [create_rest_param("fixture_names", type: "T.any(String, Symbol)")],
103
- return_type: "T.untyped"
103
+ return_type: "T.untyped",
104
104
  )
105
105
  end
106
106
  end
@@ -62,6 +62,16 @@ module Tapioca
62
62
  # `Model::PrivateRelation` modules, so that, for example, `find_by` and `all` can be chained off of the
63
63
  # `Model` class.
64
64
  #
65
+ # **A note on find**: `find` is typed as `T.untyped` by default.
66
+ #
67
+ # While it is often used in the manner of `Model.find(id)`, Rails does support pasing in an array to find, which
68
+ # would then return a `T::Enumerable[Model]`. This would force a static cast everywhere find is used to avoid type
69
+ # errors. This is not ideal considering very few users of find use the array syntax over a where. With untyped,
70
+ # this cast is optional and so it was decided to avoid typing it. If you need runtime guarentees when using `find`
71
+ # the best method of doing so is by casting the return value to the model: `T.cast(Model.find(id), Model)`.
72
+ # `find_by` does guarentee a return value of `Model`, so find can can be refactored accordingly:
73
+ # `Model.find_by!(id: id)`. This will avoid the cast requirement at runtime.
74
+ #
65
75
  # **CAUTION**: The generated relation classes are named `PrivateXXX` intentionally to reflect the fact
66
76
  # that they represent private subconstants of the Active Record model. As such, these types do not
67
77
  # exist at runtime, and their counterparts that do exist at runtime are marked `private_constant` anyway.
@@ -178,12 +188,12 @@ module Tapioca
178
188
  ASSOCIATION_METHODS = T.let(
179
189
  ::ActiveRecord::AssociationRelation.instance_methods -
180
190
  ::ActiveRecord::Relation.instance_methods,
181
- T::Array[Symbol]
191
+ T::Array[Symbol],
182
192
  )
183
193
  COLLECTION_PROXY_METHODS = T.let(
184
194
  ::ActiveRecord::Associations::CollectionProxy.instance_methods -
185
195
  ::ActiveRecord::AssociationRelation.instance_methods,
186
- T::Array[Symbol]
196
+ T::Array[Symbol],
187
197
  )
188
198
 
189
199
  QUERY_METHODS = T.let(begin
@@ -204,14 +214,14 @@ module Tapioca
204
214
  end, T::Array[Symbol])
205
215
  WHERE_CHAIN_QUERY_METHODS = T.let(
206
216
  ActiveRecord::QueryMethods::WhereChain.instance_methods(false),
207
- T::Array[Symbol]
217
+ T::Array[Symbol],
208
218
  )
209
219
  FINDER_METHODS = T.let(ActiveRecord::FinderMethods.instance_methods(false), T::Array[Symbol])
210
220
  CALCULATION_METHODS = T.let(ActiveRecord::Calculations.instance_methods(false), T::Array[Symbol])
211
221
  ENUMERABLE_QUERY_METHODS = T.let([:any?, :many?, :none?, :one?], T::Array[Symbol])
212
222
  FIND_OR_CREATE_METHODS = T.let(
213
223
  [:find_or_create_by, :find_or_create_by!, :find_or_initialize_by, :create_or_find_by, :create_or_find_by!],
214
- T::Array[Symbol]
224
+ T::Array[Symbol],
215
225
  )
216
226
  BUILDER_METHODS = T.let([:new, :build, :create, :create!], T::Array[Symbol])
217
227
 
@@ -292,7 +302,7 @@ module Tapioca
292
302
  def create_association_relation_where_chain_class(model)
293
303
  model.create_class(
294
304
  AssociationRelationWhereChainClassName,
295
- superclass_name: AssociationRelationClassName
305
+ superclass_name: AssociationRelationClassName,
296
306
  ) do |klass|
297
307
  create_where_chain_methods(klass, AssociationRelationClassName)
298
308
  klass.create_type_variable("Elem", type: "type_member", fixed: constant_name)
@@ -310,7 +320,7 @@ module Tapioca
310
320
  create_param("opts", type: "T.untyped"),
311
321
  create_rest_param("rest", type: "T.untyped"),
312
322
  ],
313
- return_type: return_type
323
+ return_type: return_type,
314
324
  )
315
325
  when :associated, :missing
316
326
  klass.create_method(
@@ -318,7 +328,7 @@ module Tapioca
318
328
  parameters: [
319
329
  create_rest_param("args", type: "T.untyped"),
320
330
  ],
321
- return_type: return_type
331
+ return_type: return_type,
322
332
  )
323
333
  end
324
334
  end
@@ -374,12 +384,12 @@ module Tapioca
374
384
  parameters: [
375
385
  create_rest_param("records", type: model_collection),
376
386
  ],
377
- return_type: AssociationsCollectionProxyClassName
387
+ return_type: AssociationsCollectionProxyClassName,
378
388
  )
379
389
  when :clear
380
390
  klass.create_method(
381
391
  method_name.to_s,
382
- return_type: AssociationsCollectionProxyClassName
392
+ return_type: AssociationsCollectionProxyClassName,
383
393
  )
384
394
  when :delete, :destroy
385
395
  klass.create_method(
@@ -387,12 +397,12 @@ module Tapioca
387
397
  parameters: [
388
398
  create_rest_param("records", type: model_or_id_collection),
389
399
  ],
390
- return_type: "T::Array[#{constant_name}]"
400
+ return_type: "T::Array[#{constant_name}]",
391
401
  )
392
402
  when :load_target
393
403
  klass.create_method(
394
404
  method_name.to_s,
395
- return_type: "T::Array[#{constant_name}]"
405
+ return_type: "T::Array[#{constant_name}]",
396
406
  )
397
407
  when :replace
398
408
  klass.create_method(
@@ -400,19 +410,19 @@ module Tapioca
400
410
  parameters: [
401
411
  create_param("other_array", type: model_collection),
402
412
  ],
403
- return_type: "T::Array[#{constant_name}]"
413
+ return_type: "T::Array[#{constant_name}]",
404
414
  )
405
415
  when :reset_scope
406
416
  # skip
407
417
  when :scope
408
418
  klass.create_method(
409
419
  method_name.to_s,
410
- return_type: AssociationRelationClassName
420
+ return_type: AssociationRelationClassName,
411
421
  )
412
422
  when :target
413
423
  klass.create_method(
414
424
  method_name.to_s,
415
- return_type: "T::Array[#{constant_name}]"
425
+ return_type: "T::Array[#{constant_name}]",
416
426
  )
417
427
  end
418
428
  end
@@ -441,7 +451,7 @@ module Tapioca
441
451
  parameters: [
442
452
  create_rest_param("args", type: "T.untyped"),
443
453
  create_block_param("blk", type: "T.untyped"),
444
- ]
454
+ ],
445
455
  )
446
456
  end
447
457
  end
@@ -467,7 +477,7 @@ module Tapioca
467
477
  association_relation_methods_module.create_method(
468
478
  method_name.to_s,
469
479
  parameters: parameters,
470
- return_type: "ActiveRecord::Result"
480
+ return_type: "ActiveRecord::Result",
471
481
  )
472
482
  when :insert, :insert!, :upsert
473
483
  parameters = [
@@ -483,7 +493,7 @@ module Tapioca
483
493
  association_relation_methods_module.create_method(
484
494
  method_name.to_s,
485
495
  parameters: parameters,
486
- return_type: "ActiveRecord::Result"
496
+ return_type: "ActiveRecord::Result",
487
497
  )
488
498
  when :proxy_association
489
499
  # skip - private method
@@ -496,7 +506,7 @@ module Tapioca
496
506
  create_common_method(
497
507
  "destroy_all",
498
508
  common_relation_methods_module,
499
- return_type: "T::Array[#{constant_name}]"
509
+ return_type: "T::Array[#{constant_name}]",
500
510
  )
501
511
 
502
512
  FINDER_METHODS.each do |method_name|
@@ -508,7 +518,7 @@ module Tapioca
508
518
  parameters: [
509
519
  create_opt_param("conditions", type: "T.untyped", default: ":none"),
510
520
  ],
511
- return_type: "T::Boolean"
521
+ return_type: "T::Boolean",
512
522
  )
513
523
  when :include?, :member?
514
524
  create_common_method(
@@ -517,7 +527,7 @@ module Tapioca
517
527
  parameters: [
518
528
  create_param("record", type: "T.untyped"),
519
529
  ],
520
- return_type: "T::Boolean"
530
+ return_type: "T::Boolean",
521
531
  )
522
532
  when :find
523
533
  create_common_method(
@@ -526,7 +536,7 @@ module Tapioca
526
536
  parameters: [
527
537
  create_rest_param("args", type: "T.untyped"),
528
538
  ],
529
- return_type: "T.untyped"
539
+ return_type: "T.untyped",
530
540
  )
531
541
  when :find_by
532
542
  create_common_method(
@@ -535,7 +545,7 @@ module Tapioca
535
545
  parameters: [
536
546
  create_rest_param("args", type: "T.untyped"),
537
547
  ],
538
- return_type: as_nilable_type(constant_name)
548
+ return_type: as_nilable_type(constant_name),
539
549
  )
540
550
  when :find_by!
541
551
  create_common_method(
@@ -544,7 +554,7 @@ module Tapioca
544
554
  parameters: [
545
555
  create_rest_param("args", type: "T.untyped"),
546
556
  ],
547
- return_type: constant_name
557
+ return_type: constant_name,
548
558
  )
549
559
  when :find_sole_by
550
560
  create_common_method(
@@ -554,14 +564,14 @@ module Tapioca
554
564
  create_param("arg", type: "T.untyped"),
555
565
  create_rest_param("args", type: "T.untyped"),
556
566
  ],
557
- return_type: constant_name
567
+ return_type: constant_name,
558
568
  )
559
569
  when :sole
560
570
  create_common_method(
561
571
  "sole",
562
572
  common_relation_methods_module,
563
573
  parameters: [],
564
- return_type: constant_name
574
+ return_type: constant_name,
565
575
  )
566
576
  when :first, :last, :take
567
577
  create_common_method(
@@ -570,7 +580,7 @@ module Tapioca
570
580
  parameters: [
571
581
  create_opt_param("limit", type: "T.untyped", default: "nil"),
572
582
  ],
573
- return_type: "T.untyped"
583
+ return_type: "T.untyped",
574
584
  )
575
585
  when :raise_record_not_found_exception!
576
586
  # skip
@@ -584,7 +594,7 @@ module Tapioca
584
594
  create_common_method(
585
595
  method_name,
586
596
  common_relation_methods_module,
587
- return_type: return_type
597
+ return_type: return_type,
588
598
  )
589
599
  end
590
600
  end
@@ -598,7 +608,7 @@ module Tapioca
598
608
  parameters: [
599
609
  create_param("column_name", type: "T.any(String, Symbol)"),
600
610
  ],
601
- return_type: "T.untyped"
611
+ return_type: "T.untyped",
602
612
  )
603
613
  when :calculate
604
614
  create_common_method(
@@ -608,7 +618,7 @@ module Tapioca
608
618
  create_param("operation", type: "Symbol"),
609
619
  create_param("column_name", type: "T.any(String, Symbol)"),
610
620
  ],
611
- return_type: "T.untyped"
621
+ return_type: "T.untyped",
612
622
  )
613
623
  when :count
614
624
  create_common_method(
@@ -617,7 +627,7 @@ module Tapioca
617
627
  parameters: [
618
628
  create_opt_param("column_name", type: "T.untyped", default: "nil"),
619
629
  ],
620
- return_type: "T.untyped"
630
+ return_type: "T.untyped",
621
631
  )
622
632
  when :ids
623
633
  create_common_method("ids", common_relation_methods_module, return_type: "Array")
@@ -628,7 +638,7 @@ module Tapioca
628
638
  parameters: [
629
639
  create_rest_param("column_names", type: "T.untyped"),
630
640
  ],
631
- return_type: "T.untyped"
641
+ return_type: "T.untyped",
632
642
  )
633
643
  when :sum
634
644
  create_common_method(
@@ -638,7 +648,7 @@ module Tapioca
638
648
  create_opt_param("column_name", type: "T.nilable(T.any(String, Symbol))", default: "nil"),
639
649
  create_block_param("block", type: "T.nilable(T.proc.params(record: T.untyped).returns(T.untyped))"),
640
650
  ],
641
- return_type: "T.untyped"
651
+ return_type: "T.untyped",
642
652
  )
643
653
  end
644
654
  end
@@ -651,7 +661,7 @@ module Tapioca
651
661
  parameters: [
652
662
  create_block_param("block", type: block_type),
653
663
  ],
654
- return_type: "T::Boolean"
664
+ return_type: "T::Boolean",
655
665
  )
656
666
  end
657
667
 
@@ -664,7 +674,7 @@ module Tapioca
664
674
  create_param("attributes", type: "T.untyped"),
665
675
  create_block_param("block", type: block_type),
666
676
  ],
667
- return_type: constant_name
677
+ return_type: constant_name,
668
678
  )
669
679
  end
670
680
 
@@ -676,7 +686,7 @@ module Tapioca
676
686
  create_opt_param("attributes", type: "T.untyped", default: "nil"),
677
687
  create_block_param("block", type: "T.nilable(T.proc.params(object: #{constant_name}).void)"),
678
688
  ],
679
- return_type: constant_name
689
+ return_type: constant_name,
680
690
  )
681
691
  end
682
692
  end
@@ -686,14 +696,14 @@ module Tapioca
686
696
  name: T.any(Symbol, String),
687
697
  common_relation_methods_module: RBI::Scope,
688
698
  parameters: T::Array[RBI::TypedParam],
689
- return_type: T.nilable(String)
699
+ return_type: T.nilable(String),
690
700
  ).void
691
701
  end
692
702
  def create_common_method(name, common_relation_methods_module, parameters: [], return_type: nil)
693
703
  common_relation_methods_module.create_method(
694
704
  name.to_s,
695
705
  parameters: parameters,
696
- return_type: return_type || "void"
706
+ return_type: return_type || "void",
697
707
  )
698
708
  end
699
709
 
@@ -718,12 +728,12 @@ module Tapioca
718
728
  relation_methods_module.create_method(
719
729
  name.to_s,
720
730
  parameters: parameters,
721
- return_type: relation_return_type
731
+ return_type: relation_return_type,
722
732
  )
723
733
  association_relation_methods_module.create_method(
724
734
  name.to_s,
725
735
  parameters: parameters,
726
- return_type: association_return_type
736
+ return_type: association_return_type,
727
737
  )
728
738
  end
729
739
  end
@@ -64,7 +64,7 @@ module Tapioca
64
64
  generate_scope_method(
65
65
  relation_methods_module,
66
66
  scope_method.to_s,
67
- relations_enabled ? RelationClassName : "T.untyped"
67
+ relations_enabled ? RelationClassName : "T.untyped",
68
68
  )
69
69
 
70
70
  next unless relations_enabled
@@ -72,7 +72,7 @@ module Tapioca
72
72
  generate_scope_method(
73
73
  assoc_relation_methods_mod,
74
74
  scope_method.to_s,
75
- AssociationRelationClassName
75
+ AssociationRelationClassName,
76
76
  )
77
77
  end
78
78
 
@@ -112,7 +112,7 @@ module Tapioca
112
112
  params(
113
113
  mod: RBI::Scope,
114
114
  scope_method: String,
115
- return_type: String
115
+ return_type: String,
116
116
  ).void
117
117
  end
118
118
  def generate_scope_method(mod, scope_method, return_type)
@@ -147,7 +147,7 @@ module Tapioca
147
147
  params(
148
148
  klass: RBI::Scope,
149
149
  name: String,
150
- type: String
150
+ type: String,
151
151
  )
152
152
  .void
153
153
  end
@@ -155,7 +155,7 @@ module Tapioca
155
155
  klass.create_method(
156
156
  "#{name}=",
157
157
  parameters: [create_param(name, type: type)],
158
- return_type: type
158
+ return_type: type,
159
159
  )
160
160
  klass.create_method(name, return_type: type)
161
161
  klass.create_method("#{name}?", return_type: "T::Boolean")
@@ -63,12 +63,12 @@ module Tapioca
63
63
  name = reflection.name.to_s
64
64
  scope.create_method(
65
65
  name,
66
- return_type: type
66
+ return_type: type,
67
67
  )
68
68
  scope.create_method(
69
69
  "#{name}=",
70
70
  parameters: [create_param("attachable", type: "T.untyped")],
71
- return_type: "T.untyped"
71
+ return_type: "T.untyped",
72
72
  )
73
73
  end
74
74
  end
@@ -117,7 +117,7 @@ module Tapioca
117
117
  method,
118
118
  class_method: class_method,
119
119
  parameters: [parameter],
120
- return_type: "T.untyped"
120
+ return_type: "T.untyped",
121
121
  )
122
122
  else
123
123
  klass.create_method(method, class_method: class_method, return_type: "T.untyped")
@@ -83,14 +83,14 @@ module Tapioca
83
83
  # Create getter method
84
84
  mod.create_method(
85
85
  method_name.to_s,
86
- return_type: "T.untyped"
86
+ return_type: "T.untyped",
87
87
  )
88
88
 
89
89
  # Create setter method
90
90
  mod.create_method(
91
91
  "#{method_name}=",
92
92
  parameters: [create_param("value", type: "T.untyped")],
93
- return_type: "T.untyped"
93
+ return_type: "T.untyped",
94
94
  )
95
95
  end
96
96
  end
@@ -2,6 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  begin
5
+ gem("graphql", ">= 1.13")
5
6
  require "graphql"
6
7
  rescue LoadError
7
8
  return
@@ -2,6 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  begin
5
+ gem("graphql", ">= 1.13")
5
6
  require "graphql"
6
7
  rescue LoadError
7
8
  return