graphql-models_connect 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 64da9a68fd9997f53eef17ed0a1288019d515b423224200f3bcd4c0c1cf2d8e5
4
+ data.tar.gz: 9aa63d18f382e1b939ced756159f1c88480ef2ca9bbebfb691cb1763ddde1647
5
+ SHA512:
6
+ metadata.gz: dd2bea7f7ee51a1f60fc7e3faf623d9974e94ab9b67984a270ada607bcfd93a70c4045c0aaa49e599371d2c90a4c4cbf7f300709ffb9b62b53740ea130a527a3
7
+ data.tar.gz: 8801edf4b01c755b7dee4d370bbcd988af30479b2759b940dae80c76d49c0b9e5e94fe74f6cf077eaa1e7d5c3686280854e08167f8d20f0636af8119d434631a
data/.rubocop.yml ADDED
@@ -0,0 +1,452 @@
1
+ AllCops:
2
+ NewCops: enable
3
+ Exclude:
4
+ - 'bin/**'
5
+
6
+ Gemspec/DeprecatedAttributeAssignment:
7
+ Enabled: true
8
+
9
+ Gemspec/DevelopmentDependencies:
10
+ Enabled: true
11
+
12
+ Gemspec/RequireMFA:
13
+ Enabled: false
14
+
15
+ Layout/AccessModifierIndentation:
16
+ EnforcedStyle: outdent
17
+
18
+ Layout/BeginEndAlignment:
19
+ EnforcedStyleAlignWith: begin
20
+
21
+ Layout/BlockAlignment:
22
+ EnforcedStyleAlignWith: start_of_block
23
+
24
+ Layout/CommentIndentation:
25
+ AllowForAlignment: true
26
+
27
+ Layout/EmptyLineAfterMultilineCondition:
28
+ Enabled: true
29
+
30
+ Layout/EndOfLine:
31
+ EnforcedStyle: lf
32
+
33
+ Layout/ExtraSpacing:
34
+ AllowForAlignment: true
35
+ AllowBeforeTrailingComments: true
36
+
37
+ Layout/HashAlignment:
38
+ EnforcedHashRocketStyle: table
39
+ EnforcedColonStyle: table
40
+ EnforcedLastArgumentHashStyle: ignore_implicit
41
+
42
+ Layout/LineContinuationLeadingSpace:
43
+ Enabled: true
44
+
45
+ Layout/LineContinuationSpacing:
46
+ Enabled: true
47
+
48
+ Layout/LineEndStringConcatenationIndentation:
49
+ Enabled: true
50
+
51
+ Layout/MultilineArrayLineBreaks:
52
+ Enabled: true
53
+
54
+ Layout/MultilineAssignmentLayout:
55
+ Enabled: true
56
+ EnforcedStyle: same_line
57
+
58
+ Layout/MultilineHashKeyLineBreaks:
59
+ Enabled: true
60
+
61
+ Layout/MultilineMethodArgumentLineBreaks:
62
+ Enabled: true
63
+
64
+ Layout/MultilineMethodCallIndentation:
65
+ EnforcedStyle: indented_relative_to_receiver
66
+
67
+ Layout/SingleLineBlockChain:
68
+ Enabled: true
69
+
70
+ Layout/SpaceAroundEqualsInParameterDefault:
71
+ EnforcedStyle: no_space
72
+
73
+ Layout/SpaceAroundOperators:
74
+ EnforcedStyleForExponentOperator: space
75
+
76
+ Layout/SpaceBeforeBrackets:
77
+ Enabled: true
78
+
79
+ Layout/SpaceInsideHashLiteralBraces:
80
+ EnforcedStyle: no_space
81
+
82
+ Layout/TrailingWhitespace:
83
+ AllowInHeredoc: true
84
+
85
+ Lint/AmbiguousAssignment:
86
+ Enabled: true
87
+
88
+ Lint/AmbiguousOperatorPrecedence:
89
+ Enabled: true
90
+
91
+ Lint/AmbiguousRange:
92
+ Enabled: true
93
+ RequireParenthesesForMethodChains: true
94
+
95
+ Lint/AssignmentInCondition:
96
+ AllowSafeAssignment: false
97
+
98
+ Lint/ConstantOverwrittenInRescue:
99
+ Enabled: true
100
+
101
+ Lint/DeprecatedConstants:
102
+ Enabled: true
103
+
104
+ Lint/DuplicateBranch:
105
+ Enabled: true
106
+ IgnoreLiteralBranches: true
107
+ IgnoreConstantBranches: true
108
+
109
+ Lint/DuplicateMagicComment:
110
+ Enabled: true
111
+
112
+ Lint/DuplicateRegexpCharacterClassElement:
113
+ Enabled: true
114
+
115
+ Lint/EmptyBlock:
116
+ Enabled: true
117
+
118
+ Lint/EmptyClass:
119
+ Enabled: true
120
+ AllowComments: true
121
+
122
+ Lint/EmptyInPattern:
123
+ Enabled: true
124
+
125
+ Lint/HeredocMethodCallPosition:
126
+ Enabled: true
127
+
128
+ Lint/IncompatibleIoSelectWithFiberScheduler:
129
+ Enabled: false
130
+
131
+ Lint/LambdaWithoutLiteralBlock:
132
+ Enabled: true
133
+
134
+ Lint/NoReturnInBeginEndBlocks:
135
+ Enabled: true
136
+
137
+ Lint/NonAtomicFileOperation:
138
+ Enabled: true
139
+
140
+ Lint/NumberedParameterAssignment:
141
+ Enabled: true
142
+
143
+ Lint/OrAssignmentToConstant:
144
+ Enabled: true
145
+
146
+ Lint/RedundantDirGlobSort:
147
+ Enabled: true
148
+
149
+ Lint/RedundantSplatExpansion:
150
+ AllowPercentLiteralArrayArgument: false
151
+
152
+ Lint/RefinementImportMethods:
153
+ Enabled: true
154
+
155
+ Lint/RequireRangeParentheses:
156
+ Enabled: true
157
+
158
+ Lint/RequireRelativeSelfPath:
159
+ Enabled: true
160
+
161
+ Lint/SymbolConversion:
162
+ Enabled: true
163
+
164
+ Lint/ToEnumArguments:
165
+ Enabled: true
166
+
167
+ Lint/TripleQuotes:
168
+ Enabled: true
169
+
170
+ Lint/UnexpectedBlockArity:
171
+ Enabled: true
172
+
173
+ Lint/UnmodifiedReduceAccumulator:
174
+ Enabled: true
175
+
176
+ Lint/UnusedBlockArgument:
177
+ AutoCorrect: false
178
+
179
+ Lint/UnusedMethodArgument:
180
+ AutoCorrect: false
181
+
182
+ Lint/UselessRescue:
183
+ Enabled: true
184
+
185
+ Lint/UselessRuby2Keywords:
186
+ Enabled: true
187
+
188
+ Metrics:
189
+ Enabled: false
190
+
191
+ Naming/BlockForwarding:
192
+ Enabled: true
193
+
194
+ Naming/InclusiveLanguage:
195
+ Enabled: false
196
+
197
+ Security/CompoundHash:
198
+ Enabled: true
199
+
200
+ Security/Eval:
201
+ Enabled: false
202
+
203
+ Security/IoMethods:
204
+ Enabled: true
205
+
206
+ Style/AccessorGrouping:
207
+ EnforcedStyle: separated
208
+
209
+ Style/ArgumentsForwarding:
210
+ Enabled: false
211
+
212
+ Style/ArrayIntersect:
213
+ Enabled: true
214
+
215
+ Style/AutoResourceCleanup:
216
+ Enabled: true
217
+
218
+ Style/CollectionCompact:
219
+ Enabled: true
220
+
221
+ Style/CollectionMethods:
222
+ Enabled: true
223
+
224
+ Style/ComparableClamp:
225
+ Enabled: true
226
+
227
+ Style/ConcatArrayLiterals:
228
+ Enabled: true
229
+
230
+ Style/DirEmpty:
231
+ Enabled: true
232
+
233
+ Style/DocumentDynamicEvalDefinition:
234
+ Enabled: false
235
+
236
+ Style/Documentation:
237
+ Enabled: false
238
+
239
+ Style/DocumentationMethod:
240
+ Enabled: false
241
+
242
+ Style/DoubleNegation:
243
+ EnforcedStyle: forbidden
244
+
245
+ Style/EmptyHeredoc:
246
+ Enabled: true
247
+
248
+ Style/EmptyMethod:
249
+ EnforcedStyle: expanded
250
+
251
+ Style/EndlessMethod:
252
+ Enabled: true
253
+ EnforcedStyle: disallow
254
+
255
+ Style/EnvHome:
256
+ Enabled: true
257
+
258
+ Style/FetchEnvVar:
259
+ Enabled: false
260
+
261
+ Style/FileEmpty:
262
+ Enabled: true
263
+
264
+ Style/FileRead:
265
+ Enabled: true
266
+
267
+ Style/FileWrite:
268
+ Enabled: true
269
+
270
+ Style/FormatString:
271
+ EnforcedStyle: percent
272
+
273
+ Style/FrozenStringLiteralComment:
274
+ Enabled: false
275
+
276
+ Style/HashConversion:
277
+ Enabled: true
278
+
279
+ Style/HashExcept:
280
+ Enabled: true
281
+
282
+ Style/HashSyntax:
283
+ EnforcedShorthandSyntax: never
284
+
285
+ Style/IfWithBooleanLiteralBranches:
286
+ Enabled: true
287
+
288
+ Style/ImplicitRuntimeError:
289
+ Enabled: true
290
+
291
+ Style/InPatternThen:
292
+ Enabled: true
293
+
294
+ Style/IpAddresses:
295
+ Enabled: true
296
+
297
+ Style/MagicCommentFormat:
298
+ Enabled: true
299
+
300
+ Style/MapCompactWithConditionalBlock:
301
+ Enabled: true
302
+
303
+ Style/MapToHash:
304
+ Enabled: true
305
+
306
+ Style/MapToSet:
307
+ Enabled: true
308
+
309
+ Style/MethodCallWithArgsParentheses:
310
+ Enabled: true
311
+ EnforcedStyle: omit_parentheses
312
+ AllowParenthesesInMultilineCall: true
313
+ AllowParenthesesInChaining: true
314
+ AllowParenthesesInCamelCaseMethod: true
315
+
316
+ Style/MethodDefParentheses:
317
+ EnforcedStyle: require_no_parentheses_except_multiline
318
+
319
+ Style/MinMaxComparison:
320
+ Enabled: true
321
+
322
+ Style/MultilineBlockChain:
323
+ Enabled: false
324
+
325
+ Style/MultilineInPatternThen:
326
+ Enabled: true
327
+
328
+ Style/NegatedIfElseCondition:
329
+ Enabled: true
330
+
331
+ Style/NestedFileDirname:
332
+ Enabled: true
333
+
334
+ Style/NestedParenthesizedCalls:
335
+ Enabled: false
336
+
337
+ Style/NilLambda:
338
+ Enabled: true
339
+
340
+ Style/NonNilCheck:
341
+ Enabled: false
342
+
343
+ Style/NumberedParameters:
344
+ Enabled: true
345
+
346
+ Style/NumberedParametersLimit:
347
+ Enabled: true
348
+ Max: 2
349
+
350
+ Style/ObjectThen:
351
+ Enabled: true
352
+
353
+ Style/OpenStructUse:
354
+ Enabled: false
355
+
356
+ Style/OperatorMethodCall:
357
+ Enabled: true
358
+
359
+ Style/OptionHash:
360
+ Enabled: true
361
+
362
+ Style/QuotedSymbols:
363
+ Enabled: true
364
+
365
+ Style/RedundantArgument:
366
+ Enabled: false
367
+
368
+ Style/RedundantConstantBase:
369
+ Enabled: false
370
+
371
+ Style/RedundantDoubleSplatHashBraces:
372
+ Enabled: true
373
+
374
+ Style/RedundantEach:
375
+ Enabled: true
376
+
377
+ Style/RedundantException:
378
+ Enabled: false
379
+
380
+ Style/RedundantHeredocDelimiterQuotes:
381
+ Enabled: true
382
+
383
+ Style/RedundantInitialize:
384
+ Enabled: true
385
+
386
+ Style/RedundantParentheses:
387
+ Enabled: false
388
+
389
+ Style/RedundantSelfAssignmentBranch:
390
+ Enabled: true
391
+
392
+ Style/RedundantStringEscape:
393
+ Enabled: true
394
+
395
+ Style/RegexpLiteral:
396
+ EnforcedStyle: percent_r
397
+
398
+ Style/ReturnNil:
399
+ Enabled: true
400
+
401
+ Style/SelectByRegexp:
402
+ Enabled: true
403
+
404
+ Style/SingleLineMethods:
405
+ AllowIfMethodIsEmpty: false
406
+
407
+ Style/StaticClass:
408
+ Enabled: true
409
+
410
+ Style/StringChars:
411
+ Enabled: true
412
+
413
+ Style/StringHashKeys:
414
+ Enabled: false
415
+
416
+ Style/SwapValues:
417
+ Enabled: true
418
+
419
+ Style/SymbolArray:
420
+ EnforcedStyle: brackets
421
+
422
+ Style/TernaryParentheses:
423
+ EnforcedStyle: require_parentheses_when_complex
424
+ AllowSafeAssignment: false
425
+
426
+ Style/TopLevelMethodDefinition:
427
+ Enabled: true
428
+
429
+ Style/TrailingCommaInArguments:
430
+ Enabled: true
431
+ EnforcedStyleForMultiline: no_comma
432
+
433
+ Style/TrailingCommaInArrayLiteral:
434
+ Enabled: true
435
+ EnforcedStyleForMultiline: no_comma
436
+
437
+ Style/TrailingCommaInBlockArgs:
438
+ Enabled: true
439
+
440
+ Style/TrailingCommaInHashLiteral:
441
+ Enabled: true
442
+ EnforcedStyleForMultiline: no_comma
443
+
444
+ Style/UnlessLogicalOperators:
445
+ EnforcedStyle: forbid_logical_operators
446
+
447
+ Style/WordArray:
448
+ EnforcedStyle: brackets
449
+
450
+ Style/YodaCondition:
451
+ Enabled: true
452
+ EnforcedStyle: forbid_for_all_comparison_operators
data/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # Changelog
2
+
3
+ <!--[//]: # (
4
+ ## <Release number> <Date YYYY-MM-DD>
5
+ ### Breaking changes
6
+ ### Deprecations
7
+ ### New features
8
+ ### Bug fixes
9
+ )-->
10
+
11
+ ## 1.0.0 2024-10-09
12
+
13
+ First release. Refer to [README.md](README.md) for the full documentation.
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in graphql-filters.gemspec
4
+ gemspec
5
+
6
+ gem 'rake', '~> 13.0'
7
+
8
+ gem 'rubocop', '~> 1.21'
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Moku S.r.l., Riccardo Agatea
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 all
13
+ 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 THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,69 @@
1
+ # GraphQL Models Connect
2
+
3
+ A way to directly link GraphQL types with their underlying models.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'graphql-models_connect', '~> 1.0'
11
+ ```
12
+
13
+ And then execute:
14
+ ```bash
15
+ $ bundle
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ GraphQL Models Connect associates every GraphQL type with a model. By default, the model is assumed to have the same name as the type minus the `Type` suffix, and to be nested under the same module. For a single exception you can explicitly declare the model inside your object type:
21
+
22
+ ```ruby
23
+ module Types
24
+ class PokemonType < BaseObject
25
+ model_class Pokemon
26
+ ...
27
+ end
28
+ end
29
+ ```
30
+
31
+ To change the default behavior of the gem, override the `default_model_class` class method in your base object class:
32
+
33
+ ```ruby
34
+ module Types
35
+ class BaseObject < GraphQL::Schema::Object
36
+ def self.default_model_class
37
+ model_name = name
38
+ .delete_prefix('Types::')
39
+ .delete_suffix('Type')
40
+
41
+ const_get model_name
42
+ end
43
+ end
44
+ end
45
+ ```
46
+
47
+ ## Version numbers
48
+
49
+ GraphQL Models Connect loosely follows [Semantic Versioning](https://semver.org/), with a hard guarantee that breaking changes to the public API will always coincide with an increase to the `MAJOR` number.
50
+
51
+ Version numbers are in three parts: `MAJOR.MINOR.PATCH`.
52
+
53
+ - Breaking changes to the public API increment the `MAJOR`. There may also be changes that would otherwise increase the `MINOR` or the `PATCH`.
54
+ - Additions, deprecations, and "big" non breaking changes to the public API increment the `MINOR`. There may also be changes that would otherwise increase the `PATCH`.
55
+ - Bug fixes and "small" non breaking changes to the public API increment the `PATCH`.
56
+
57
+ Notice that any feature deprecated by a minor release can be expected to be removed by the next major release.
58
+
59
+ ## Changelog
60
+
61
+ Full list of changes in [CHANGELOG.md](CHANGELOG.md)
62
+
63
+ ## Contributing
64
+
65
+ Bug reports and pull requests are welcome on GitHub at https://github.com/moku-io/graphql-filters.
66
+
67
+ ## License
68
+
69
+ 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,7 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ require 'rubocop/rake_task'
4
+
5
+ RuboCop::RakeTask.new
6
+
7
+ task default: [:rubocop]
@@ -0,0 +1,27 @@
1
+ require 'active_support/concern'
2
+
3
+ monkey_patch = Module.new do
4
+ extend ActiveSupport::Concern
5
+
6
+ class_methods do
7
+ def model_class new_model_class=nil
8
+ if new_model_class.nil?
9
+ @model_class ||= default_model_class
10
+ else
11
+ @model_class = new_model_class
12
+ end
13
+ end
14
+
15
+ def default_model_class
16
+ raise 'You must set an explicit model for anonymous graphql classes' if name.nil?
17
+
18
+ default_model_name = name.delete_suffix 'Type'
19
+
20
+ raise "No default model found for #{name}" unless const_defined? default_model_name
21
+
22
+ const_get default_model_name
23
+ end
24
+ end
25
+ end
26
+
27
+ GraphQL::Schema::Object.prepend monkey_patch
@@ -0,0 +1,3 @@
1
+ Dir[File.join('dsl','**','*.rb'), base: __dir__].each do |filename|
2
+ require_relative filename
3
+ end
@@ -0,0 +1,5 @@
1
+ module GraphQL
2
+ module ModelsConnect
3
+ VERSION = '1.0.0'
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ require 'graphql'
2
+
3
+ module GraphQL
4
+ module ModelsConnect
5
+ end
6
+ end
7
+
8
+ require_relative 'models_connect/dsl'
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: graphql-models_connect
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Moku S.r.l.
8
+ - Riccardo Agatea
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2024-10-09 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activesupport
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: graphql
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '2.0'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '2.0'
42
+ description: Directly link GraphQL types to underlying models.
43
+ email:
44
+ - info@moku.io
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".rubocop.yml"
50
+ - CHANGELOG.md
51
+ - Gemfile
52
+ - LICENSE
53
+ - README.md
54
+ - Rakefile
55
+ - lib/graphql/models_connect.rb
56
+ - lib/graphql/models_connect/dsl.rb
57
+ - lib/graphql/models_connect/dsl/graphql/schema/object.rb
58
+ - lib/graphql/models_connect/version.rb
59
+ homepage: https://github.com/moku-io/graphql-models_connect
60
+ licenses:
61
+ - MIT
62
+ metadata:
63
+ homepage_uri: https://github.com/moku-io/graphql-models_connect
64
+ source_code_uri: https://github.com/moku-io/graphql-models_connect
65
+ changelog_uri: https://github.com/moku-io/graphql-models_connect/blob/master/CHANGELOG.md
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 3.0.0
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubygems_version: 3.5.20
82
+ signing_key:
83
+ specification_version: 4
84
+ summary: Directly link GraphQL types to underlying models.
85
+ test_files: []