graphql_activerecord_resolvers 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f60bace7ac91068af1d90a02898469eab96572bd
4
+ data.tar.gz: 0ba1d470d3e34304bb2e007e0ec5c2a8ea40ac5f
5
+ SHA512:
6
+ metadata.gz: 52137d2b8f781cc2c0c3200766ce6b726c6fc3fca6f7e2e1f21a4a312e3ca867a421654f2a8779abfa2f26a9baca127973813ebe1d854bb2b5a5a02eb62e7f3e
7
+ data.tar.gz: 7e3df25124d976177d4d38bd26c9eada577308182c10614c84d5e91de1b29e479d3d304857a12ccdc138fd9312f610357ffad2fae268f64834fa0c55801aaf9f
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/.rubocop.yml ADDED
@@ -0,0 +1,639 @@
1
+ AllCops:
2
+ Exclude:
3
+ - "*.gemspec"
4
+
5
+ Naming/AccessorMethodName:
6
+ Description: Check the naming of accessor methods for get_/set_.
7
+ Enabled: false
8
+
9
+ Style/Alias:
10
+ Description: 'Use alias_method instead of alias.'
11
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#alias-method'
12
+ Enabled: false
13
+
14
+ Style/ArrayJoin:
15
+ Description: 'Use Array#join instead of Array#*.'
16
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#array-join'
17
+ Enabled: false
18
+
19
+ Style/AsciiComments:
20
+ Description: 'Use only ascii symbols in comments.'
21
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#english-comments'
22
+ Enabled: false
23
+
24
+ Naming/AsciiIdentifiers:
25
+ Description: 'Use only ascii symbols in identifiers.'
26
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#english-identifiers'
27
+ Enabled: false
28
+
29
+ Style/Attr:
30
+ Description: 'Checks for uses of Module#attr.'
31
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#attr'
32
+ Enabled: false
33
+
34
+ Metrics/BlockNesting:
35
+ Description: 'Avoid excessive block nesting'
36
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#three-is-the-number-thou-shalt-count'
37
+ Enabled: false
38
+
39
+ Style/CaseEquality:
40
+ Description: 'Avoid explicit use of the case equality operator(===).'
41
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-case-equality'
42
+ Enabled: false
43
+
44
+ Style/CharacterLiteral:
45
+ Description: 'Checks for uses of character literals.'
46
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-character-literals'
47
+ Enabled: false
48
+
49
+ Style/ClassAndModuleChildren:
50
+ Description: 'Checks style of children classes and modules.'
51
+ Enabled: true
52
+ EnforcedStyle: nested
53
+
54
+ Metrics/ClassLength:
55
+ Description: 'Avoid classes longer than 100 lines of code.'
56
+ Enabled: false
57
+
58
+ Metrics/ModuleLength:
59
+ Description: 'Avoid modules longer than 100 lines of code.'
60
+ Enabled: false
61
+
62
+ Style/ClassVars:
63
+ Description: 'Avoid the use of class variables.'
64
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-class-vars'
65
+ Enabled: false
66
+
67
+ Style/CollectionMethods:
68
+ Enabled: true
69
+ PreferredMethods:
70
+ find: detect
71
+ inject: reduce
72
+ collect: map
73
+ find_all: select
74
+
75
+ Style/ColonMethodCall:
76
+ Description: 'Do not use :: for method call.'
77
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#double-colons'
78
+ Enabled: false
79
+
80
+ Style/CommentAnnotation:
81
+ Description: >-
82
+ Checks formatting of special comments
83
+ (TODO, FIXME, OPTIMIZE, HACK, REVIEW).
84
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#annotate-keywords'
85
+ Enabled: false
86
+
87
+ Metrics/AbcSize:
88
+ Description: >-
89
+ A calculated magnitude based on number of assignments,
90
+ branches, and conditions.
91
+ Enabled: false
92
+
93
+ Metrics/BlockLength:
94
+ CountComments: true # count full line comments?
95
+ Max: 25
96
+ ExcludedMethods: []
97
+ Exclude:
98
+ - "spec/**/*"
99
+ - "config/**/*"
100
+
101
+ Metrics/CyclomaticComplexity:
102
+ Description: >-
103
+ A complexity metric that is strongly correlated to the number
104
+ of test cases needed to validate a method.
105
+ Enabled: false
106
+
107
+ Rails/Delegate:
108
+ Description: 'Prefer delegate method for delegations.'
109
+ Enabled: false
110
+
111
+ Style/PreferredHashMethods:
112
+ Description: 'Checks use of `has_key?` and `has_value?` Hash methods.'
113
+ StyleGuide: '#hash-key'
114
+ Enabled: false
115
+
116
+ Style/Documentation:
117
+ Description: 'Document classes and non-namespace modules.'
118
+ Enabled: false
119
+
120
+ Style/DoubleNegation:
121
+ Description: 'Checks for uses of double negation (!!).'
122
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-bang-bang'
123
+ Enabled: false
124
+
125
+ Style/EachWithObject:
126
+ Description: 'Prefer `each_with_object` over `inject` or `reduce`.'
127
+ Enabled: false
128
+
129
+ Style/EmptyLiteral:
130
+ Description: 'Prefer literals to Array.new/Hash.new/String.new.'
131
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#literal-array-hash'
132
+ Enabled: false
133
+
134
+ # Checks whether the source file has a utf-8 encoding comment or not
135
+ # AutoCorrectEncodingComment must match the regex
136
+ # /#.*coding\s?[:=]\s?(?:UTF|utf)-8/
137
+ Style/Encoding:
138
+ Enabled: false
139
+
140
+ Style/EvenOdd:
141
+ Description: 'Favor the use of Fixnum#even? && Fixnum#odd?'
142
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#predicate-methods'
143
+ Enabled: false
144
+
145
+ Naming/FileName:
146
+ Description: 'Use snake_case for source file names.'
147
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#snake-case-files'
148
+ Enabled: false
149
+
150
+ Style/FrozenStringLiteralComment:
151
+ Description: >-
152
+ Add the frozen_string_literal comment to the top of files
153
+ to help transition from Ruby 2.3.0 to Ruby 3.0.
154
+ Enabled: false
155
+
156
+ Style/FlipFlop:
157
+ Description: 'Checks for flip flops'
158
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-flip-flops'
159
+ Enabled: false
160
+
161
+ Style/FormatString:
162
+ Description: 'Enforce the use of Kernel#sprintf, Kernel#format or String#%.'
163
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#sprintf'
164
+ Enabled: false
165
+
166
+ Style/GlobalVars:
167
+ Description: 'Do not introduce global variables.'
168
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#instance-vars'
169
+ Reference: 'http://www.zenspider.com/Languages/Ruby/QuickRef.html'
170
+ Enabled: false
171
+
172
+ Style/GuardClause:
173
+ Description: 'Check for conditionals that can be replaced with guard clauses'
174
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals'
175
+ Enabled: false
176
+
177
+ Style/IfUnlessModifier:
178
+ Description: >-
179
+ Favor modifier if/unless usage when you have a
180
+ single-line body.
181
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier'
182
+ Enabled: false
183
+
184
+ Style/IfWithSemicolon:
185
+ Description: 'Do not use if x; .... Use the ternary operator instead.'
186
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-semicolon-ifs'
187
+ Enabled: false
188
+
189
+ Style/InlineComment:
190
+ Description: 'Avoid inline comments.'
191
+ Enabled: false
192
+
193
+ Style/Lambda:
194
+ Description: 'Use the new lambda literal syntax for single-line blocks.'
195
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#lambda-multi-line'
196
+ Enabled: false
197
+
198
+ Style/LambdaCall:
199
+ Description: 'Use lambda.call(...) instead of lambda.(...).'
200
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#proc-call'
201
+ Enabled: false
202
+
203
+ Style/LineEndConcatenation:
204
+ Description: >-
205
+ Use \ instead of + or << to concatenate two string literals at
206
+ line end.
207
+ Enabled: false
208
+
209
+ Metrics/LineLength:
210
+ Enabled: false
211
+
212
+ Metrics/MethodLength:
213
+ Description: 'Avoid methods longer than 10 lines of code.'
214
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#short-methods'
215
+ Enabled: false
216
+
217
+ Style/ModuleFunction:
218
+ Description: 'Checks for usage of `extend self` in modules.'
219
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#module-function'
220
+ Enabled: false
221
+
222
+ Style/MultilineBlockChain:
223
+ Description: 'Avoid multi-line chains of blocks.'
224
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#single-line-blocks'
225
+ Enabled: false
226
+
227
+ Style/NegatedIf:
228
+ Description: >-
229
+ Favor unless over if for negative conditions
230
+ (or control flow or).
231
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#unless-for-negatives'
232
+ Enabled: false
233
+
234
+ Style/NegatedWhile:
235
+ Description: 'Favor until over while for negative conditions.'
236
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#until-for-negatives'
237
+ Enabled: false
238
+
239
+ Style/Next:
240
+ Description: 'Use `next` to skip iteration instead of a condition at the end.'
241
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals'
242
+ Enabled: false
243
+
244
+ Style/NilComparison:
245
+ Description: 'Prefer x.nil? to x == nil.'
246
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#predicate-methods'
247
+ Enabled: false
248
+
249
+ Style/Not:
250
+ Description: 'Use ! instead of not.'
251
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#bang-not-not'
252
+ Enabled: false
253
+
254
+ Style/NumericLiterals:
255
+ Description: >-
256
+ Add underscores to large numeric literals to improve their
257
+ readability.
258
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#underscores-in-numerics'
259
+ Enabled: false
260
+
261
+ Style/OneLineConditional:
262
+ Description: >-
263
+ Favor the ternary operator(?:) over
264
+ if/then/else/end constructs.
265
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#ternary-operator'
266
+ Enabled: false
267
+
268
+ Naming/BinaryOperatorParameterName:
269
+ Description: 'When defining binary operators, name the argument other.'
270
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#other-arg'
271
+ Enabled: false
272
+
273
+ Metrics/ParameterLists:
274
+ Description: 'Avoid parameter lists longer than three or four parameters.'
275
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#too-many-params'
276
+ Enabled: false
277
+
278
+ Style/PercentLiteralDelimiters:
279
+ Description: 'Use `%`-literal delimiters consistently'
280
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-literal-braces'
281
+ Enabled: false
282
+
283
+ Style/PerlBackrefs:
284
+ Description: 'Avoid Perl-style regex back references.'
285
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers'
286
+ Enabled: false
287
+
288
+ Naming/PredicateName:
289
+ Description: 'Check the names of predicate methods.'
290
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark'
291
+ NamePrefixBlacklist:
292
+ - is_
293
+ Exclude:
294
+ - spec/**/*
295
+
296
+ Style/Proc:
297
+ Description: 'Use proc instead of Proc.new.'
298
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#proc'
299
+ Enabled: false
300
+
301
+ Style/RaiseArgs:
302
+ Description: 'Checks the arguments passed to raise/fail.'
303
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#exception-class-messages'
304
+ Enabled: false
305
+
306
+ Style/RegexpLiteral:
307
+ Description: 'Use / or %r around regular expressions.'
308
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-r'
309
+ Enabled: false
310
+
311
+ Style/SelfAssignment:
312
+ Description: >-
313
+ Checks for places where self-assignment shorthand should have
314
+ been used.
315
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#self-assignment'
316
+ Enabled: false
317
+
318
+ Style/SingleLineBlockParams:
319
+ Description: 'Enforces the names of some block params.'
320
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#reduce-blocks'
321
+ Enabled: false
322
+
323
+ Style/SingleLineMethods:
324
+ Description: 'Avoid single-line methods.'
325
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-single-line-methods'
326
+ Enabled: false
327
+
328
+ Style/SignalException:
329
+ Description: 'Checks for proper usage of fail and raise.'
330
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#fail-method'
331
+ Enabled: false
332
+
333
+ Style/SpecialGlobalVars:
334
+ Description: 'Avoid Perl-style global variables.'
335
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms'
336
+ Enabled: false
337
+
338
+ Style/StringLiterals:
339
+ Description: 'Checks if uses of quotes match the configured preference.'
340
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#consistent-string-literals'
341
+ EnforcedStyle: double_quotes
342
+ Enabled: true
343
+
344
+ Style/TrailingCommaInArguments:
345
+ Description: 'Checks for trailing comma in argument lists.'
346
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
347
+ EnforcedStyleForMultiline: comma
348
+ SupportedStylesForMultiline:
349
+ - comma
350
+ - consistent_comma
351
+ - no_comma
352
+ Enabled: true
353
+
354
+ Style/TrailingCommaInLiteral:
355
+ Description: 'Checks for trailing comma in array and hash literals.'
356
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
357
+ EnforcedStyleForMultiline: comma
358
+ SupportedStylesForMultiline:
359
+ - comma
360
+ - consistent_comma
361
+ - no_comma
362
+ Enabled: true
363
+
364
+ Style/TrivialAccessors:
365
+ Description: 'Prefer attr_* methods to trivial readers/writers.'
366
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#attr_family'
367
+ Enabled: false
368
+
369
+ Style/VariableInterpolation:
370
+ Description: >-
371
+ Don't interpolate global, instance and class variables
372
+ directly in strings.
373
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#curlies-interpolate'
374
+ Enabled: false
375
+
376
+ Style/WhenThen:
377
+ Description: 'Use when x then ... for one-line cases.'
378
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#one-line-cases'
379
+ Enabled: false
380
+
381
+ Style/WhileUntilModifier:
382
+ Description: >-
383
+ Favor modifier while/until usage when you have a
384
+ single-line body.
385
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#while-as-a-modifier'
386
+ Enabled: false
387
+
388
+ Style/WordArray:
389
+ Description: 'Use %w or %W for arrays of words.'
390
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-w'
391
+ Enabled: false
392
+
393
+ # Layout
394
+
395
+ Layout/AlignParameters:
396
+ Description: 'Here we check if the parameters on a multi-line method call or definition are aligned.'
397
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-double-indent'
398
+ Enabled: false
399
+
400
+ Layout/DotPosition:
401
+ Description: 'Checks the position of the dot in multi-line method calls.'
402
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains'
403
+ EnforcedStyle: trailing
404
+
405
+ Layout/ExtraSpacing:
406
+ Description: 'Do not use unnecessary spacing.'
407
+ Enabled: true
408
+
409
+ Layout/MultilineOperationIndentation:
410
+ Description: >-
411
+ Checks indentation of binary operations that span more than
412
+ one line.
413
+ Enabled: true
414
+ EnforcedStyle: indented
415
+
416
+ Layout/MultilineMethodCallIndentation:
417
+ Description: >-
418
+ Checks indentation of method calls with the dot operator
419
+ that span more than one line.
420
+ Enabled: true
421
+ EnforcedStyle: indented
422
+
423
+ Layout/InitialIndentation:
424
+ Description: >-
425
+ Checks the indentation of the first non-blank non-comment line in a file.
426
+ Enabled: false
427
+
428
+ # Lint
429
+
430
+ Lint/AmbiguousOperator:
431
+ Description: >-
432
+ Checks for ambiguous operators in the first argument of a
433
+ method invocation without parentheses.
434
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#parens-as-args'
435
+ Enabled: false
436
+
437
+ Lint/AmbiguousRegexpLiteral:
438
+ Description: >-
439
+ Checks for ambiguous regexp literals in the first argument of
440
+ a method invocation without parenthesis.
441
+ Enabled: false
442
+
443
+ Lint/AssignmentInCondition:
444
+ Description: "Don't use assignment in conditions."
445
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition'
446
+ Enabled: false
447
+
448
+ Lint/CircularArgumentReference:
449
+ Description: "Don't refer to the keyword argument in the default value."
450
+ Enabled: false
451
+
452
+ Lint/ConditionPosition:
453
+ Description: >-
454
+ Checks for condition placed in a confusing position relative to
455
+ the keyword.
456
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#same-line-condition'
457
+ Enabled: false
458
+
459
+ Lint/DeprecatedClassMethods:
460
+ Description: 'Check for deprecated class method calls.'
461
+ Enabled: false
462
+
463
+ Lint/DuplicatedKey:
464
+ Description: 'Check for duplicate keys in hash literals.'
465
+ Enabled: false
466
+
467
+ Lint/EachWithObjectArgument:
468
+ Description: 'Check for immutable argument given to each_with_object.'
469
+ Enabled: false
470
+
471
+ Lint/ElseLayout:
472
+ Description: 'Check for odd code arrangement in an else block.'
473
+ Enabled: false
474
+
475
+ Lint/FormatParameterMismatch:
476
+ Description: 'The number of parameters to format/sprint must match the fields.'
477
+ Enabled: false
478
+
479
+ Lint/HandleExceptions:
480
+ Description: "Don't suppress exception."
481
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions'
482
+ Enabled: false
483
+
484
+ Lint/LiteralAsCondition:
485
+ Description: 'Checks of literals used in conditions.'
486
+ Enabled: false
487
+
488
+ Lint/LiteralInInterpolation:
489
+ Description: 'Checks for literals used in interpolation.'
490
+ Enabled: false
491
+
492
+ Lint/Loop:
493
+ Description: >-
494
+ Use Kernel#loop with break rather than begin/end/until or
495
+ begin/end/while for post-loop tests.
496
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#loop-with-break'
497
+ Enabled: false
498
+
499
+ Lint/NestedMethodDefinition:
500
+ Description: 'Do not use nested method definitions.'
501
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-methods'
502
+ Enabled: false
503
+
504
+ Lint/NonLocalExitFromIterator:
505
+ Description: 'Do not use return in iterator to cause non-local exit.'
506
+ Enabled: false
507
+
508
+ Lint/ParenthesesAsGroupedExpression:
509
+ Description: >-
510
+ Checks for method calls with a space before the opening
511
+ parenthesis.
512
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#parens-no-spaces'
513
+ Enabled: false
514
+
515
+ Lint/RequireParentheses:
516
+ Description: >-
517
+ Use parentheses in the method call to avoid confusion
518
+ about precedence.
519
+ Enabled: false
520
+
521
+ Lint/UnderscorePrefixedVariableName:
522
+ Description: 'Do not use prefix `_` for a variable that is used.'
523
+ Enabled: false
524
+
525
+ Lint/UnneededDisable:
526
+ Description: >-
527
+ Checks for rubocop:disable comments that can be removed.
528
+ Note: this cop is not disabled when disabling all cops.
529
+ It must be explicitly disabled.
530
+ Enabled: false
531
+
532
+ Lint/Void:
533
+ Description: 'Possible use of operator/literal/variable in void context.'
534
+ Enabled: false
535
+
536
+ # Performance
537
+
538
+ Performance/CaseWhenSplat:
539
+ Description: >-
540
+ Place `when` conditions that use splat at the end
541
+ of the list of `when` branches.
542
+ Enabled: false
543
+
544
+ Performance/Count:
545
+ Description: >-
546
+ Use `count` instead of `select...size`, `reject...size`,
547
+ `select...count`, `reject...count`, `select...length`,
548
+ and `reject...length`.
549
+ Enabled: false
550
+
551
+ Performance/Detect:
552
+ Description: >-
553
+ Use `detect` instead of `select.first`, `find_all.first`,
554
+ `select.last`, and `find_all.last`.
555
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerabledetect-vs-enumerableselectfirst-code'
556
+ Enabled: false
557
+
558
+ Performance/FlatMap:
559
+ Description: >-
560
+ Use `Enumerable#flat_map`
561
+ instead of `Enumerable#map...Array#flatten(1)`
562
+ or `Enumberable#collect..Array#flatten(1)`
563
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerablemaparrayflatten-vs-enumerableflat_map-code'
564
+ Enabled: false
565
+
566
+ Performance/ReverseEach:
567
+ Description: 'Use `reverse_each` instead of `reverse.each`.'
568
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerablereverseeach-vs-enumerablereverse_each-code'
569
+ Enabled: false
570
+
571
+ Performance/Sample:
572
+ Description: >-
573
+ Use `sample` instead of `shuffle.first`,
574
+ `shuffle.last`, and `shuffle[Fixnum]`.
575
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#arrayshufflefirst-vs-arraysample-code'
576
+ Enabled: false
577
+
578
+ Performance/Size:
579
+ Description: >-
580
+ Use `size` instead of `count` for counting
581
+ the number of elements in `Array` and `Hash`.
582
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#arraycount-vs-arraysize-code'
583
+ Enabled: false
584
+
585
+ Performance/StringReplacement:
586
+ Description: >-
587
+ Use `tr` instead of `gsub` when you are replacing the same
588
+ number of characters. Use `delete` instead of `gsub` when
589
+ you are deleting characters.
590
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringgsub-vs-stringtr-code'
591
+ Enabled: false
592
+
593
+ # Rails
594
+
595
+ Rails/ActionFilter:
596
+ Description: 'Enforces consistent use of action filter methods.'
597
+ Enabled: false
598
+
599
+ Rails/Date:
600
+ Description: >-
601
+ Checks the correct usage of date aware methods,
602
+ such as Date.today, Date.current etc.
603
+ Enabled: false
604
+
605
+ Rails/FindBy:
606
+ Description: 'Prefer find_by over where.first.'
607
+ Enabled: false
608
+
609
+ Rails/FindEach:
610
+ Description: 'Prefer all.find_each over all.find.'
611
+ Enabled: false
612
+
613
+ Rails/HasAndBelongsToMany:
614
+ Description: 'Prefer has_many :through to has_and_belongs_to_many.'
615
+ Enabled: false
616
+
617
+ Rails/Output:
618
+ Description: 'Checks for calls to puts, print, etc.'
619
+ Enabled: false
620
+
621
+ Rails/ReadWriteAttribute:
622
+ Description: >-
623
+ Checks for read_attribute(:attr) and
624
+ write_attribute(:attr, val).
625
+ Enabled: false
626
+
627
+ Rails/ScopeArgs:
628
+ Description: 'Checks the arguments of ActiveRecord scopes.'
629
+ Enabled: false
630
+
631
+ Rails/TimeZone:
632
+ Description: 'Checks the correct usage of time zone aware methods.'
633
+ StyleGuide: 'https://github.com/bbatsov/rails-style-guide#time'
634
+ Reference: 'http://danilenko.org/2012/7/6/rails_timezones'
635
+ Enabled: false
636
+
637
+ Rails/Validation:
638
+ Description: 'Use validates :attribute, hash of validations.'
639
+ Enabled: false
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in graphql_activerecord_resolvers.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,65 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ graphql_activerecord_resolvers (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ activemodel (5.1.5)
10
+ activesupport (= 5.1.5)
11
+ activerecord (5.1.5)
12
+ activemodel (= 5.1.5)
13
+ activesupport (= 5.1.5)
14
+ arel (~> 8.0)
15
+ activesupport (5.1.5)
16
+ concurrent-ruby (~> 1.0, >= 1.0.2)
17
+ i18n (~> 0.7)
18
+ minitest (~> 5.1)
19
+ tzinfo (~> 1.1)
20
+ arel (8.0.0)
21
+ ast (2.3.0)
22
+ coderay (1.1.2)
23
+ concurrent-ruby (1.0.5)
24
+ graphql (0.19.4)
25
+ i18n (0.9.5)
26
+ concurrent-ruby (~> 1.0)
27
+ method_source (0.9.0)
28
+ minitest (5.11.3)
29
+ parallel (1.12.1)
30
+ parser (2.4.0.2)
31
+ ast (~> 2.3)
32
+ powerpack (0.1.1)
33
+ pry (0.11.3)
34
+ coderay (~> 1.1.0)
35
+ method_source (~> 0.9.0)
36
+ rainbow (3.0.0)
37
+ rake (10.4.2)
38
+ rubocop (0.52.1)
39
+ parallel (~> 1.10)
40
+ parser (>= 2.4.0.2, < 3.0)
41
+ powerpack (~> 0.1)
42
+ rainbow (>= 2.2.2, < 4.0)
43
+ ruby-progressbar (~> 1.7)
44
+ unicode-display_width (~> 1.0, >= 1.0.1)
45
+ ruby-progressbar (1.9.0)
46
+ thread_safe (0.3.6)
47
+ tzinfo (1.2.5)
48
+ thread_safe (~> 0.1)
49
+ unicode-display_width (1.3.0)
50
+
51
+ PLATFORMS
52
+ ruby
53
+
54
+ DEPENDENCIES
55
+ activerecord (~> 5.1)
56
+ bundler (~> 1.16)
57
+ graphql (~> 0.19)
58
+ graphql_activerecord_resolvers!
59
+ minitest (~> 5.0)
60
+ pry (~> 0.11)
61
+ rake (~> 10.0)
62
+ rubocop (~> 0.52)
63
+
64
+ BUNDLED WITH
65
+ 1.16.0
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Steven Petryk
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,70 @@
1
+ # GraphQL ActiveRecord Resolvers
2
+
3
+ Build a GraphQL API on Rails, without the N+1's.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem "graphql_activerecord_resolvers"
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install graphql_activerecord_resolvers
20
+
21
+ ## Usage
22
+
23
+ GraphQL marks a new era in API development, one in which the clients dictate what the server
24
+ should deliver. But, due to N+1 queries, using GraphQL with Rails is a pain. That's where this gem
25
+ comes in.
26
+
27
+ `graphql_activerecord_resolvers` works with [graphql-ruby](http://graphql-ruby.org/). It allows you
28
+ to easily substitute your own resolvers for supercharged ones. These resolvers take a look at the
29
+ schema, the query, and the context, and automatically build up an `eager_load` instruction that
30
+ Rails understands.
31
+
32
+ To use it, simply make the following change to every **root field** in your Query:
33
+
34
+ ```diff
35
+ module Types
36
+ QueryType = GraphQL::ObjectType.define do
37
+ name "Query"
38
+
39
+ field :countries do
40
+ type types[Types::CountryType]
41
+
42
+ - resolve ->(obj, ctx, args) { Country.all }
43
+ + resolve GraphQLActiveRecordResolvers::BaseResolver.resolve(Country)
44
+ end
45
+
46
+ field :locations do
47
+ type types[Types::LocationType]
48
+
49
+ - resolve ->(obj, ctx, args) { Location.all }
50
+ + resolve GraphQLActiveRecordResolvers::BaseResolver.resolve(Location)
51
+ end
52
+ end
53
+ end
54
+ ```
55
+
56
+ That's all you need to do.
57
+
58
+ ## Development
59
+
60
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
61
+
62
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
63
+
64
+ ## Contributing
65
+
66
+ Bug reports and pull requests are welcome on GitHub at https://github.com/stevenpetryk/graphql_activerecord_resolvers.
67
+
68
+ ## License
69
+
70
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task default: :test
data/bin/console ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "graphql_activerecord_resolvers"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ require "pry"
10
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,36 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "graphql_activerecord_resolvers/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "graphql_activerecord_resolvers"
7
+ spec.version = GraphQLActiveRecordResolvers::VERSION
8
+ spec.authors = ["Steven Petryk"]
9
+ spec.email = ["petryk.steven@gmail.com"]
10
+
11
+ spec.summary = %q{GraphQL on Rails, without the N+1's.}
12
+ spec.homepage = "https://github.com/stevenpetryk/graphql_activerecord_resolvers"
13
+ spec.license = "MIT"
14
+
15
+ if spec.respond_to?(:metadata)
16
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
17
+ else
18
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
19
+ end
20
+
21
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
22
+ f.match(%r{^(test|spec|features)/})
23
+ end
24
+ spec.bindir = "exe"
25
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
+ spec.require_paths = ["lib"]
27
+
28
+ spec.add_development_dependency "bundler", "~> 1.16"
29
+ spec.add_development_dependency "rake", "~> 10.0"
30
+ spec.add_development_dependency "minitest", "~> 5.0"
31
+ spec.add_development_dependency "rubocop", "~> 0.52"
32
+ spec.add_development_dependency "pry", "~> 0.11"
33
+
34
+ spec.add_development_dependency "activerecord", "~> 5.1"
35
+ spec.add_development_dependency "graphql", "~> 0.19"
36
+ end
@@ -0,0 +1,7 @@
1
+ require "graphql_activerecord_resolvers/base_resolver"
2
+ require "graphql_activerecord_resolvers/graphql_association"
3
+ require "graphql_activerecord_resolvers/version"
4
+
5
+ module GraphQLActiveRecordResolvers
6
+ # Your code goes here...
7
+ end
@@ -0,0 +1,57 @@
1
+ module GraphQLActiveRecordResolvers
2
+ class BaseResolver
3
+ attr_reader :ctx, :schema, :query
4
+
5
+ def self.resolve_collection(klass)
6
+ ->(_obj, _args, ctx) do
7
+ new(klass, ctx).resolve
8
+ end
9
+ end
10
+
11
+ def initialize(klass, ctx)
12
+ @klass = klass
13
+ @ctx = ctx
14
+ @schema = ctx.schema
15
+ @query = ctx.query
16
+ end
17
+
18
+ def resolve
19
+ if includes_tree
20
+ klass.includes(includes_tree)
21
+ else
22
+ klass.all
23
+ end
24
+ end
25
+
26
+ def includes_tree
27
+ @includes_tree ||=
28
+ GraphQLAssociation.
29
+ new(
30
+ schema: schema,
31
+ klass: klass,
32
+ field: root_field,
33
+ selections: root_selections,
34
+ root: true,
35
+ ).
36
+ build_includes_tree
37
+ end
38
+
39
+ private
40
+
41
+ def root_field
42
+ schema.query.get_field(ctx.key)
43
+ end
44
+
45
+ def root_selections
46
+ ctx.ast_node.selections
47
+ end
48
+
49
+ def klass
50
+ if @klass.is_a? String
51
+ @klass.constantize
52
+ else
53
+ @klass
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,67 @@
1
+ module GraphQLActiveRecordResolvers
2
+ class GraphQLAssociation
3
+ attr_reader :klass, :schema, :field, :selections, :root
4
+
5
+ def initialize(schema:, klass:, field:, selections:, root:)
6
+ @klass = klass
7
+ @schema = schema
8
+ @field = field
9
+ @selections = selections
10
+ @root = root
11
+ end
12
+
13
+ def build_includes_tree
14
+ if root
15
+ child_associations.map(&:build_includes_tree)
16
+ elsif child_associations.any?
17
+ {
18
+ field.name => child_associations.map(&:build_includes_tree),
19
+ }
20
+ else
21
+ field.name
22
+ end
23
+ end
24
+
25
+ private
26
+
27
+ def child_fields
28
+ selections.map do |selection|
29
+ [selection, schema.get_field(field_type, selection.name)]
30
+ end
31
+ end
32
+
33
+ def child_fields_that_are_also_associations
34
+ child_fields.select do |_, field|
35
+ association_names.map(&:to_s).include?(field.name.to_s)
36
+ end
37
+ end
38
+
39
+ def child_associations
40
+ child_fields_that_are_also_associations.map do |(selection, field)|
41
+ GraphQLAssociation.new(
42
+ schema: schema,
43
+ klass: klass_for_association_name(field.name),
44
+ field: field,
45
+ selections: selection.selections,
46
+ root: false,
47
+ )
48
+ end
49
+ end
50
+
51
+ def field_type
52
+ field.type.unwrap
53
+ end
54
+
55
+ def associations
56
+ klass.reflect_on_all_associations
57
+ end
58
+
59
+ def association_names
60
+ associations.map(&:name)
61
+ end
62
+
63
+ def klass_for_association_name(name)
64
+ associations.detect { |association| association.name.to_s == name.to_s }.klass
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,3 @@
1
+ module GraphQLActiveRecordResolvers
2
+ VERSION = "0.1.0".freeze
3
+ end
metadata ADDED
@@ -0,0 +1,157 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: graphql_activerecord_resolvers
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Steven Petryk
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-03-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.52'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.52'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.11'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.11'
83
+ - !ruby/object:Gem::Dependency
84
+ name: activerecord
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '5.1'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '5.1'
97
+ - !ruby/object:Gem::Dependency
98
+ name: graphql
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.19'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.19'
111
+ description:
112
+ email:
113
+ - petryk.steven@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".rubocop.yml"
120
+ - Gemfile
121
+ - Gemfile.lock
122
+ - LICENSE.txt
123
+ - README.md
124
+ - Rakefile
125
+ - bin/console
126
+ - bin/setup
127
+ - graphql_activerecord_resolvers.gemspec
128
+ - lib/graphql_activerecord_resolvers.rb
129
+ - lib/graphql_activerecord_resolvers/base_resolver.rb
130
+ - lib/graphql_activerecord_resolvers/graphql_association.rb
131
+ - lib/graphql_activerecord_resolvers/version.rb
132
+ homepage: https://github.com/stevenpetryk/graphql_activerecord_resolvers
133
+ licenses:
134
+ - MIT
135
+ metadata:
136
+ allowed_push_host: https://rubygems.org
137
+ post_install_message:
138
+ rdoc_options: []
139
+ require_paths:
140
+ - lib
141
+ required_ruby_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ required_rubygems_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ requirements: []
152
+ rubyforge_project:
153
+ rubygems_version: 2.6.14
154
+ signing_key:
155
+ specification_version: 4
156
+ summary: GraphQL on Rails, without the N+1's.
157
+ test_files: []