graphql_grpc 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +568 -0
- data/Gemfile.lock +6 -22
- data/bin/example.rb +6 -6
- data/graphql_grpc.gemspec +1 -1
- data/lib/graphql_grpc.rb +0 -1
- data/lib/graphql_grpc/arrayify.rb +15 -14
- data/lib/graphql_grpc/proxy.rb +2 -2
- data/lib/graphql_grpc/schema.rb +9 -6
- data/lib/graphql_grpc/type_library.rb +7 -9
- data/lib/graphql_grpc/version.rb +1 -1
- metadata +5 -4
- data/lib/graphql_grpc/graphql.rb +0 -114
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 73ffb6b8a88a45dfc882b15a467c1c5912740e69a0d85502935853c32f415ac6
|
|
4
|
+
data.tar.gz: ddcca9cf940118b08e7be88c105a92025f55cfaca273b2f8b434ab8a5be747d0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e79abd3330bae88e762862dc67260d11214479c1d0d21d64d06b8ecdbd3b4a64e3e49b81b42965b7c590d89409ff63c311329efa86d0f120f39781d6aab4d21e
|
|
7
|
+
data.tar.gz: f4053cc79dd3c07add87c51dfd5a81773c7716a178afaba58d47c725e9dfe0b12e2b8ed7e8839bde164f321a60e6e7c54ae09dd30d165fa1906ba189382c84a5
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
data/.rubocop_todo.yml
ADDED
|
@@ -0,0 +1,568 @@
|
|
|
1
|
+
# This configuration was generated by
|
|
2
|
+
# `rubocop --auto-gen-config`
|
|
3
|
+
# on 2018-11-05 21:08:34 -0800 using RuboCop version 0.60.0.
|
|
4
|
+
# The point is for the user to remove these configuration records
|
|
5
|
+
# one by one as the offenses are removed from the code base.
|
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
|
8
|
+
|
|
9
|
+
# Offense count: 8
|
|
10
|
+
# Cop supports --auto-correct.
|
|
11
|
+
# Configuration parameters: TreatCommentsAsGroupSeparators, Include.
|
|
12
|
+
# Include: **/*.gemspec
|
|
13
|
+
Gemspec/OrderedDependencies:
|
|
14
|
+
Exclude:
|
|
15
|
+
- 'graphql_grpc.gemspec'
|
|
16
|
+
|
|
17
|
+
# Offense count: 3
|
|
18
|
+
# Cop supports --auto-correct.
|
|
19
|
+
# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
|
|
20
|
+
# SupportedHashRocketStyles: key, separator, table
|
|
21
|
+
# SupportedColonStyles: key, separator, table
|
|
22
|
+
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
|
|
23
|
+
Layout/AlignHash:
|
|
24
|
+
Exclude:
|
|
25
|
+
- 'bin/example.rb'
|
|
26
|
+
- 'spec/graphql_grpc_spec.rb'
|
|
27
|
+
|
|
28
|
+
# Offense count: 6
|
|
29
|
+
# Cop supports --auto-correct.
|
|
30
|
+
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
|
31
|
+
# SupportedStyles: with_first_parameter, with_fixed_indentation
|
|
32
|
+
Layout/AlignParameters:
|
|
33
|
+
Exclude:
|
|
34
|
+
- 'spec/graphql_grpc_spec.rb'
|
|
35
|
+
|
|
36
|
+
# Offense count: 6
|
|
37
|
+
# Cop supports --auto-correct.
|
|
38
|
+
# Configuration parameters: EnforcedStyle, IndentOneStep, IndentationWidth.
|
|
39
|
+
# SupportedStyles: case, end
|
|
40
|
+
Layout/CaseIndentation:
|
|
41
|
+
Exclude:
|
|
42
|
+
- 'lib/graphql_grpc/type_library.rb'
|
|
43
|
+
|
|
44
|
+
# Offense count: 2
|
|
45
|
+
# Cop supports --auto-correct.
|
|
46
|
+
Layout/ClosingParenthesisIndentation:
|
|
47
|
+
Exclude:
|
|
48
|
+
- 'spec/graphql_grpc_spec.rb'
|
|
49
|
+
|
|
50
|
+
# Offense count: 10
|
|
51
|
+
# Cop supports --auto-correct.
|
|
52
|
+
Layout/CommentIndentation:
|
|
53
|
+
Exclude:
|
|
54
|
+
- 'lib/graphql_grpc/type_library.rb'
|
|
55
|
+
- 'spec/graphql_grpc_spec.rb'
|
|
56
|
+
|
|
57
|
+
# Offense count: 3
|
|
58
|
+
# Cop supports --auto-correct.
|
|
59
|
+
Layout/ElseAlignment:
|
|
60
|
+
Exclude:
|
|
61
|
+
- 'graphql_grpc.gemspec'
|
|
62
|
+
- 'lib/graphql_grpc/type_library.rb'
|
|
63
|
+
|
|
64
|
+
# Offense count: 12
|
|
65
|
+
# Cop supports --auto-correct.
|
|
66
|
+
Layout/EmptyLineAfterGuardClause:
|
|
67
|
+
Exclude:
|
|
68
|
+
- 'lib/graphql_grpc/graphql.rb'
|
|
69
|
+
- 'lib/graphql_grpc/proxy.rb'
|
|
70
|
+
- 'lib/graphql_grpc/type_library.rb'
|
|
71
|
+
|
|
72
|
+
# Offense count: 2
|
|
73
|
+
# Cop supports --auto-correct.
|
|
74
|
+
# Configuration parameters: EnforcedStyle.
|
|
75
|
+
# SupportedStyles: empty_lines, no_empty_lines
|
|
76
|
+
Layout/EmptyLinesAroundBlockBody:
|
|
77
|
+
Exclude:
|
|
78
|
+
- 'spec/graphql_grpc_spec.rb'
|
|
79
|
+
|
|
80
|
+
# Offense count: 2
|
|
81
|
+
# Cop supports --auto-correct.
|
|
82
|
+
# Configuration parameters: EnforcedStyle.
|
|
83
|
+
# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only
|
|
84
|
+
Layout/EmptyLinesAroundClassBody:
|
|
85
|
+
Exclude:
|
|
86
|
+
- 'Guardfile'
|
|
87
|
+
- 'lib/graphql_grpc/schema.rb'
|
|
88
|
+
|
|
89
|
+
# Offense count: 1
|
|
90
|
+
# Cop supports --auto-correct.
|
|
91
|
+
# Configuration parameters: EnforcedStyle.
|
|
92
|
+
# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines
|
|
93
|
+
Layout/EmptyLinesAroundModuleBody:
|
|
94
|
+
Exclude:
|
|
95
|
+
- 'lib/graphql_grpc/type_library.rb'
|
|
96
|
+
|
|
97
|
+
# Offense count: 2
|
|
98
|
+
# Cop supports --auto-correct.
|
|
99
|
+
# Configuration parameters: EnforcedStyleAlignWith, AutoCorrect, Severity.
|
|
100
|
+
# SupportedStylesAlignWith: keyword, variable, start_of_line
|
|
101
|
+
Layout/EndAlignment:
|
|
102
|
+
Exclude:
|
|
103
|
+
- 'lib/graphql_grpc/type_library.rb'
|
|
104
|
+
|
|
105
|
+
# Offense count: 1
|
|
106
|
+
# Cop supports --auto-correct.
|
|
107
|
+
# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment.
|
|
108
|
+
Layout/ExtraSpacing:
|
|
109
|
+
Exclude:
|
|
110
|
+
- 'graphql_grpc.gemspec'
|
|
111
|
+
|
|
112
|
+
# Offense count: 2
|
|
113
|
+
# Cop supports --auto-correct.
|
|
114
|
+
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
|
115
|
+
# SupportedStyles: consistent, consistent_relative_to_receiver, special_for_inner_method_call, special_for_inner_method_call_in_parentheses
|
|
116
|
+
Layout/FirstParameterIndentation:
|
|
117
|
+
Exclude:
|
|
118
|
+
- 'spec/graphql_grpc_spec.rb'
|
|
119
|
+
|
|
120
|
+
# Offense count: 6
|
|
121
|
+
# Cop supports --auto-correct.
|
|
122
|
+
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
|
123
|
+
# SupportedStyles: special_inside_parentheses, consistent, align_braces
|
|
124
|
+
Layout/IndentHash:
|
|
125
|
+
Exclude:
|
|
126
|
+
- 'bin/example.rb'
|
|
127
|
+
- 'spec/graphql_grpc_spec.rb'
|
|
128
|
+
|
|
129
|
+
# Offense count: 9
|
|
130
|
+
# Cop supports --auto-correct.
|
|
131
|
+
# Configuration parameters: EnforcedStyle.
|
|
132
|
+
# SupportedStyles: normal, rails
|
|
133
|
+
Layout/IndentationConsistency:
|
|
134
|
+
Exclude:
|
|
135
|
+
- 'lib/graphql_grpc/type_library.rb'
|
|
136
|
+
- 'spec/graphql_grpc_spec.rb'
|
|
137
|
+
|
|
138
|
+
# Offense count: 14
|
|
139
|
+
# Cop supports --auto-correct.
|
|
140
|
+
# Configuration parameters: Width, IgnoredPatterns.
|
|
141
|
+
Layout/IndentationWidth:
|
|
142
|
+
Exclude:
|
|
143
|
+
- 'graphql_grpc.gemspec'
|
|
144
|
+
- 'lib/graphql_grpc/type_library.rb'
|
|
145
|
+
- 'spec/graphql_grpc_spec.rb'
|
|
146
|
+
|
|
147
|
+
# Offense count: 1
|
|
148
|
+
# Cop supports --auto-correct.
|
|
149
|
+
Layout/LeadingBlankLines:
|
|
150
|
+
Exclude:
|
|
151
|
+
- 'graphql_grpc.gemspec'
|
|
152
|
+
|
|
153
|
+
# Offense count: 6
|
|
154
|
+
# Cop supports --auto-correct.
|
|
155
|
+
Layout/SpaceAfterComma:
|
|
156
|
+
Exclude:
|
|
157
|
+
- 'lib/graphql_grpc/function.rb'
|
|
158
|
+
- 'lib/graphql_grpc/proxy.rb'
|
|
159
|
+
|
|
160
|
+
# Offense count: 2
|
|
161
|
+
# Cop supports --auto-correct.
|
|
162
|
+
# Configuration parameters: EnforcedStyle.
|
|
163
|
+
# SupportedStyles: space, no_space
|
|
164
|
+
Layout/SpaceAroundEqualsInParameterDefault:
|
|
165
|
+
Exclude:
|
|
166
|
+
- 'lib/graphql_grpc/proxy.rb'
|
|
167
|
+
- 'lib/graphql_grpc/type_library.rb'
|
|
168
|
+
|
|
169
|
+
# Offense count: 2
|
|
170
|
+
# Cop supports --auto-correct.
|
|
171
|
+
# Configuration parameters: AllowForAlignment.
|
|
172
|
+
Layout/SpaceAroundOperators:
|
|
173
|
+
Exclude:
|
|
174
|
+
- 'graphql_grpc.gemspec'
|
|
175
|
+
- 'lib/graphql_grpc/type_library.rb'
|
|
176
|
+
|
|
177
|
+
# Offense count: 6
|
|
178
|
+
# Cop supports --auto-correct.
|
|
179
|
+
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
|
|
180
|
+
# SupportedStyles: space, no_space
|
|
181
|
+
# SupportedStylesForEmptyBraces: space, no_space
|
|
182
|
+
Layout/SpaceBeforeBlockBraces:
|
|
183
|
+
Exclude:
|
|
184
|
+
- 'bin/example.rb'
|
|
185
|
+
- 'lib/graphql_grpc/function.rb'
|
|
186
|
+
- 'lib/graphql_grpc/proxy.rb'
|
|
187
|
+
- 'spec/graphql_grpc_spec.rb'
|
|
188
|
+
|
|
189
|
+
# Offense count: 1
|
|
190
|
+
# Cop supports --auto-correct.
|
|
191
|
+
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets.
|
|
192
|
+
# SupportedStyles: space, no_space, compact
|
|
193
|
+
# SupportedStylesForEmptyBrackets: space, no_space
|
|
194
|
+
Layout/SpaceInsideArrayLiteralBrackets:
|
|
195
|
+
Exclude:
|
|
196
|
+
- 'spec/graphql_grpc_spec.rb'
|
|
197
|
+
|
|
198
|
+
# Offense count: 18
|
|
199
|
+
# Cop supports --auto-correct.
|
|
200
|
+
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
|
|
201
|
+
# SupportedStyles: space, no_space
|
|
202
|
+
# SupportedStylesForEmptyBraces: space, no_space
|
|
203
|
+
Layout/SpaceInsideBlockBraces:
|
|
204
|
+
Exclude:
|
|
205
|
+
- 'bin/example.rb'
|
|
206
|
+
- 'lib/graphql_grpc/function.rb'
|
|
207
|
+
- 'lib/graphql_grpc/proxy.rb'
|
|
208
|
+
- 'spec/graphql_grpc_spec.rb'
|
|
209
|
+
|
|
210
|
+
# Offense count: 4
|
|
211
|
+
# Cop supports --auto-correct.
|
|
212
|
+
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
|
|
213
|
+
# SupportedStyles: space, no_space, compact
|
|
214
|
+
# SupportedStylesForEmptyBraces: space, no_space
|
|
215
|
+
Layout/SpaceInsideHashLiteralBraces:
|
|
216
|
+
Exclude:
|
|
217
|
+
- 'lib/graphql_grpc/graphql.rb'
|
|
218
|
+
- 'spec/graphql_grpc_spec.rb'
|
|
219
|
+
|
|
220
|
+
# Offense count: 1
|
|
221
|
+
# Cop supports --auto-correct.
|
|
222
|
+
# Configuration parameters: EnforcedStyle.
|
|
223
|
+
# SupportedStyles: space, no_space
|
|
224
|
+
Layout/SpaceInsideParens:
|
|
225
|
+
Exclude:
|
|
226
|
+
- 'bin/console'
|
|
227
|
+
|
|
228
|
+
# Offense count: 3
|
|
229
|
+
# Cop supports --auto-correct.
|
|
230
|
+
# Configuration parameters: EnforcedStyle.
|
|
231
|
+
# SupportedStyles: final_newline, final_blank_line
|
|
232
|
+
Layout/TrailingBlankLines:
|
|
233
|
+
Exclude:
|
|
234
|
+
- 'Guardfile'
|
|
235
|
+
- 'lib/graphql_grpc/graphql.rb'
|
|
236
|
+
- 'lib/graphql_grpc/proxy.rb'
|
|
237
|
+
|
|
238
|
+
# Offense count: 31
|
|
239
|
+
# Cop supports --auto-correct.
|
|
240
|
+
# Configuration parameters: AllowInHeredoc.
|
|
241
|
+
Layout/TrailingWhitespace:
|
|
242
|
+
Exclude:
|
|
243
|
+
- 'bin/example.rb'
|
|
244
|
+
- 'graphql_grpc.gemspec'
|
|
245
|
+
- 'lib/graphql_grpc/function.rb'
|
|
246
|
+
- 'lib/graphql_grpc/graphql.rb'
|
|
247
|
+
- 'lib/graphql_grpc/proxy.rb'
|
|
248
|
+
- 'lib/graphql_grpc/schema.rb'
|
|
249
|
+
- 'lib/graphql_grpc/type_library.rb'
|
|
250
|
+
- 'spec/graphql_grpc_spec.rb'
|
|
251
|
+
|
|
252
|
+
# Offense count: 1
|
|
253
|
+
Lint/DuplicateMethods:
|
|
254
|
+
Exclude:
|
|
255
|
+
- 'Guardfile'
|
|
256
|
+
|
|
257
|
+
# Offense count: 1
|
|
258
|
+
Lint/HandleExceptions:
|
|
259
|
+
Exclude:
|
|
260
|
+
- 'lib/graphql_grpc/type_library.rb'
|
|
261
|
+
|
|
262
|
+
# Offense count: 1
|
|
263
|
+
# Cop supports --auto-correct.
|
|
264
|
+
Lint/UnifiedInteger:
|
|
265
|
+
Exclude:
|
|
266
|
+
- 'lib/graphql_grpc/function.rb'
|
|
267
|
+
|
|
268
|
+
# Offense count: 6
|
|
269
|
+
# Cop supports --auto-correct.
|
|
270
|
+
# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
|
|
271
|
+
Lint/UnusedBlockArgument:
|
|
272
|
+
Exclude:
|
|
273
|
+
- 'Guardfile'
|
|
274
|
+
- 'lib/graphql_grpc/function.rb'
|
|
275
|
+
- 'lib/graphql_grpc/proxy.rb'
|
|
276
|
+
|
|
277
|
+
# Offense count: 3
|
|
278
|
+
# Cop supports --auto-correct.
|
|
279
|
+
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods.
|
|
280
|
+
Lint/UnusedMethodArgument:
|
|
281
|
+
Exclude:
|
|
282
|
+
- 'Guardfile'
|
|
283
|
+
- 'lib/graphql_grpc/proxy.rb'
|
|
284
|
+
|
|
285
|
+
# Offense count: 7
|
|
286
|
+
Lint/UselessAssignment:
|
|
287
|
+
Exclude:
|
|
288
|
+
- 'bin/example.rb'
|
|
289
|
+
- 'spec/graphql_grpc_spec.rb'
|
|
290
|
+
|
|
291
|
+
# Offense count: 7
|
|
292
|
+
Metrics/AbcSize:
|
|
293
|
+
Max: 24
|
|
294
|
+
|
|
295
|
+
# Offense count: 4
|
|
296
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
|
297
|
+
# ExcludedMethods: refine
|
|
298
|
+
Metrics/BlockLength:
|
|
299
|
+
Max: 108
|
|
300
|
+
|
|
301
|
+
# Offense count: 1
|
|
302
|
+
Metrics/CyclomaticComplexity:
|
|
303
|
+
Max: 9
|
|
304
|
+
|
|
305
|
+
# Offense count: 5
|
|
306
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
|
307
|
+
Metrics/MethodLength:
|
|
308
|
+
Max: 19
|
|
309
|
+
|
|
310
|
+
# Offense count: 2
|
|
311
|
+
Naming/BinaryOperatorParameterName:
|
|
312
|
+
Exclude:
|
|
313
|
+
- 'lib/graphql_grpc/type_library.rb'
|
|
314
|
+
|
|
315
|
+
# Offense count: 4
|
|
316
|
+
# Configuration parameters: Blacklist.
|
|
317
|
+
# Blacklist: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$))
|
|
318
|
+
Naming/HeredocDelimiterNaming:
|
|
319
|
+
Exclude:
|
|
320
|
+
- 'bin/example.rb'
|
|
321
|
+
- 'lib/graphql_grpc/proxy.rb'
|
|
322
|
+
- 'lib/graphql_grpc/type_library.rb'
|
|
323
|
+
- 'spec/graphql_grpc_spec.rb'
|
|
324
|
+
|
|
325
|
+
# Offense count: 2
|
|
326
|
+
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
|
|
327
|
+
# AllowedNames: io, id, to, by, on, in, at, ip, db
|
|
328
|
+
Naming/UncommunicativeMethodParamName:
|
|
329
|
+
Exclude:
|
|
330
|
+
- 'lib/graphql_grpc/type_library.rb'
|
|
331
|
+
|
|
332
|
+
# Offense count: 1
|
|
333
|
+
# Cop supports --auto-correct.
|
|
334
|
+
Performance/CompareWithBlock:
|
|
335
|
+
Exclude:
|
|
336
|
+
- 'lib/graphql_grpc/proxy.rb'
|
|
337
|
+
|
|
338
|
+
# Offense count: 9
|
|
339
|
+
# Cop supports --auto-correct.
|
|
340
|
+
# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods.
|
|
341
|
+
# SupportedStyles: line_count_based, semantic, braces_for_chaining
|
|
342
|
+
# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
|
|
343
|
+
# FunctionalMethods: let, let!, subject, watch
|
|
344
|
+
# IgnoredMethods: lambda, proc, it
|
|
345
|
+
Style/BlockDelimiters:
|
|
346
|
+
Exclude:
|
|
347
|
+
- 'Guardfile'
|
|
348
|
+
- 'lib/graphql_grpc/function.rb'
|
|
349
|
+
- 'lib/graphql_grpc/proxy.rb'
|
|
350
|
+
- 'lib/graphql_grpc/type_library.rb'
|
|
351
|
+
|
|
352
|
+
# Offense count: 1
|
|
353
|
+
# Cop supports --auto-correct.
|
|
354
|
+
# Configuration parameters: AutoCorrect, EnforcedStyle.
|
|
355
|
+
# SupportedStyles: nested, compact
|
|
356
|
+
Style/ClassAndModuleChildren:
|
|
357
|
+
Exclude:
|
|
358
|
+
- 'Guardfile'
|
|
359
|
+
|
|
360
|
+
# Offense count: 1
|
|
361
|
+
# Configuration parameters: AllowCoercion.
|
|
362
|
+
Style/DateTime:
|
|
363
|
+
Exclude:
|
|
364
|
+
- 'lib/graphql_grpc/graphql.rb'
|
|
365
|
+
|
|
366
|
+
# Offense count: 10
|
|
367
|
+
Style/Documentation:
|
|
368
|
+
Exclude:
|
|
369
|
+
- 'spec/**/*'
|
|
370
|
+
- 'test/**/*'
|
|
371
|
+
- 'Guardfile'
|
|
372
|
+
- 'lib/graphql_grpc.rb'
|
|
373
|
+
- 'lib/graphql_grpc/graphql.rb'
|
|
374
|
+
- 'lib/graphql_grpc/proxy.rb'
|
|
375
|
+
- 'lib/graphql_grpc/type_library.rb'
|
|
376
|
+
|
|
377
|
+
# Offense count: 1
|
|
378
|
+
Style/DoubleNegation:
|
|
379
|
+
Exclude:
|
|
380
|
+
- 'lib/graphql_grpc/proxy.rb'
|
|
381
|
+
|
|
382
|
+
# Offense count: 1
|
|
383
|
+
# Cop supports --auto-correct.
|
|
384
|
+
Style/EmptyBlockParameter:
|
|
385
|
+
Exclude:
|
|
386
|
+
- 'lib/graphql_grpc/proxy.rb'
|
|
387
|
+
|
|
388
|
+
# Offense count: 2
|
|
389
|
+
# Cop supports --auto-correct.
|
|
390
|
+
Style/ExpandPathArguments:
|
|
391
|
+
Exclude:
|
|
392
|
+
- 'graphql_grpc.gemspec'
|
|
393
|
+
|
|
394
|
+
# Offense count: 1
|
|
395
|
+
# Configuration parameters: MinBodyLength.
|
|
396
|
+
Style/GuardClause:
|
|
397
|
+
Exclude:
|
|
398
|
+
- 'graphql_grpc.gemspec'
|
|
399
|
+
|
|
400
|
+
# Offense count: 7
|
|
401
|
+
# Cop supports --auto-correct.
|
|
402
|
+
# Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
|
|
403
|
+
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
|
|
404
|
+
Style/HashSyntax:
|
|
405
|
+
Exclude:
|
|
406
|
+
- 'Rakefile'
|
|
407
|
+
- 'bin/example.rb'
|
|
408
|
+
- 'lib/graphql_grpc/graphql.rb'
|
|
409
|
+
- 'spec/graphql_grpc_spec.rb'
|
|
410
|
+
|
|
411
|
+
# Offense count: 2
|
|
412
|
+
# Cop supports --auto-correct.
|
|
413
|
+
Style/IfUnlessModifier:
|
|
414
|
+
Exclude:
|
|
415
|
+
- 'lib/graphql_grpc/graphql.rb'
|
|
416
|
+
- 'lib/graphql_grpc/proxy.rb'
|
|
417
|
+
|
|
418
|
+
# Offense count: 1
|
|
419
|
+
# Cop supports --auto-correct.
|
|
420
|
+
# Configuration parameters: InverseMethods, InverseBlocks.
|
|
421
|
+
Style/InverseMethods:
|
|
422
|
+
Exclude:
|
|
423
|
+
- 'lib/graphql_grpc/proxy.rb'
|
|
424
|
+
|
|
425
|
+
# Offense count: 2
|
|
426
|
+
# Cop supports --auto-correct.
|
|
427
|
+
Style/MutableConstant:
|
|
428
|
+
Exclude:
|
|
429
|
+
- 'lib/graphql_grpc/type_library.rb'
|
|
430
|
+
- 'lib/graphql_grpc/version.rb'
|
|
431
|
+
|
|
432
|
+
# Offense count: 2
|
|
433
|
+
# Cop supports --auto-correct.
|
|
434
|
+
# Configuration parameters: EnforcedStyle.
|
|
435
|
+
# SupportedStyles: both, prefix, postfix
|
|
436
|
+
Style/NegatedIf:
|
|
437
|
+
Exclude:
|
|
438
|
+
- 'lib/graphql_grpc/type_library.rb'
|
|
439
|
+
|
|
440
|
+
# Offense count: 3
|
|
441
|
+
# Cop supports --auto-correct.
|
|
442
|
+
# Configuration parameters: Strict.
|
|
443
|
+
Style/NumericLiterals:
|
|
444
|
+
MinDigits: 6
|
|
445
|
+
|
|
446
|
+
# Offense count: 2
|
|
447
|
+
# Cop supports --auto-correct.
|
|
448
|
+
# Configuration parameters: PreferredDelimiters.
|
|
449
|
+
Style/PercentLiteralDelimiters:
|
|
450
|
+
Exclude:
|
|
451
|
+
- 'Guardfile'
|
|
452
|
+
- 'graphql_grpc.gemspec'
|
|
453
|
+
|
|
454
|
+
# Offense count: 2
|
|
455
|
+
# Cop supports --auto-correct.
|
|
456
|
+
# Configuration parameters: AllowMultipleReturnValues.
|
|
457
|
+
Style/RedundantReturn:
|
|
458
|
+
Exclude:
|
|
459
|
+
- 'lib/graphql_grpc/graphql.rb'
|
|
460
|
+
|
|
461
|
+
# Offense count: 15
|
|
462
|
+
# Cop supports --auto-correct.
|
|
463
|
+
Style/RedundantSelf:
|
|
464
|
+
Exclude:
|
|
465
|
+
- 'lib/graphql_grpc/type_library.rb'
|
|
466
|
+
|
|
467
|
+
# Offense count: 1
|
|
468
|
+
# Cop supports --auto-correct.
|
|
469
|
+
# Configuration parameters: EnforcedStyle, AllowInnerSlashes.
|
|
470
|
+
# SupportedStyles: slashes, percent_r, mixed
|
|
471
|
+
Style/RegexpLiteral:
|
|
472
|
+
Exclude:
|
|
473
|
+
- 'Guardfile'
|
|
474
|
+
|
|
475
|
+
# Offense count: 2
|
|
476
|
+
# Cop supports --auto-correct.
|
|
477
|
+
# Configuration parameters: EnforcedStyle.
|
|
478
|
+
# SupportedStyles: implicit, explicit
|
|
479
|
+
Style/RescueStandardError:
|
|
480
|
+
Exclude:
|
|
481
|
+
- 'lib/graphql_grpc/graphql.rb'
|
|
482
|
+
- 'lib/graphql_grpc/type_library.rb'
|
|
483
|
+
|
|
484
|
+
# Offense count: 1
|
|
485
|
+
# Cop supports --auto-correct.
|
|
486
|
+
# Configuration parameters: EnforcedStyle.
|
|
487
|
+
# SupportedStyles: use_perl_names, use_english_names
|
|
488
|
+
Style/SpecialGlobalVars:
|
|
489
|
+
Exclude:
|
|
490
|
+
- 'bin/console'
|
|
491
|
+
|
|
492
|
+
# Offense count: 31
|
|
493
|
+
# Cop supports --auto-correct.
|
|
494
|
+
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
|
|
495
|
+
# SupportedStyles: single_quotes, double_quotes
|
|
496
|
+
Style/StringLiterals:
|
|
497
|
+
Exclude:
|
|
498
|
+
- 'Guardfile'
|
|
499
|
+
- 'Rakefile'
|
|
500
|
+
- 'bin/console'
|
|
501
|
+
- 'bin/example.rb'
|
|
502
|
+
- 'lib/graphql_grpc.rb'
|
|
503
|
+
- 'lib/graphql_grpc/function.rb'
|
|
504
|
+
- 'lib/graphql_grpc/graphql.rb'
|
|
505
|
+
- 'lib/graphql_grpc/proxy.rb'
|
|
506
|
+
- 'lib/graphql_grpc/type_library.rb'
|
|
507
|
+
- 'lib/graphql_grpc/version.rb'
|
|
508
|
+
- 'spec/graphql_grpc_spec.rb'
|
|
509
|
+
|
|
510
|
+
# Offense count: 1
|
|
511
|
+
# Cop supports --auto-correct.
|
|
512
|
+
# Configuration parameters: EnforcedStyle.
|
|
513
|
+
# SupportedStyles: single_quotes, double_quotes
|
|
514
|
+
Style/StringLiteralsInInterpolation:
|
|
515
|
+
Exclude:
|
|
516
|
+
- 'lib/graphql_grpc/proxy.rb'
|
|
517
|
+
|
|
518
|
+
# Offense count: 2
|
|
519
|
+
# Cop supports --auto-correct.
|
|
520
|
+
# Configuration parameters: EnforcedStyle, MinSize.
|
|
521
|
+
# SupportedStyles: percent, brackets
|
|
522
|
+
Style/SymbolArray:
|
|
523
|
+
Exclude:
|
|
524
|
+
- 'lib/graphql_grpc/graphql.rb'
|
|
525
|
+
|
|
526
|
+
# Offense count: 5
|
|
527
|
+
# Cop supports --auto-correct.
|
|
528
|
+
# Configuration parameters: IgnoredMethods.
|
|
529
|
+
# IgnoredMethods: respond_to, define_method
|
|
530
|
+
Style/SymbolProc:
|
|
531
|
+
Exclude:
|
|
532
|
+
- 'lib/graphql_grpc/function.rb'
|
|
533
|
+
- 'lib/graphql_grpc/proxy.rb'
|
|
534
|
+
- 'lib/graphql_grpc/type_library.rb'
|
|
535
|
+
|
|
536
|
+
# Offense count: 1
|
|
537
|
+
# Cop supports --auto-correct.
|
|
538
|
+
# Configuration parameters: EnforcedStyleForMultiline.
|
|
539
|
+
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
|
|
540
|
+
Style/TrailingCommaInArguments:
|
|
541
|
+
Exclude:
|
|
542
|
+
- 'bin/console'
|
|
543
|
+
|
|
544
|
+
# Offense count: 1
|
|
545
|
+
# Cop supports --auto-correct.
|
|
546
|
+
# Configuration parameters: EnforcedStyleForMultiline.
|
|
547
|
+
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
|
|
548
|
+
Style/TrailingCommaInHashLiteral:
|
|
549
|
+
Exclude:
|
|
550
|
+
- 'spec/graphql_grpc_spec.rb'
|
|
551
|
+
|
|
552
|
+
# Offense count: 2
|
|
553
|
+
# Cop supports --auto-correct.
|
|
554
|
+
Style/UnneededPercentQ:
|
|
555
|
+
Exclude:
|
|
556
|
+
- 'graphql_grpc.gemspec'
|
|
557
|
+
|
|
558
|
+
# Offense count: 1
|
|
559
|
+
# Cop supports --auto-correct.
|
|
560
|
+
Style/ZeroLengthPredicate:
|
|
561
|
+
Exclude:
|
|
562
|
+
- 'lib/graphql_grpc/type_library.rb'
|
|
563
|
+
|
|
564
|
+
# Offense count: 52
|
|
565
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
|
566
|
+
# URISchemes: http, https
|
|
567
|
+
Metrics/LineLength:
|
|
568
|
+
Max: 1288
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
graphql_grpc (0.1.
|
|
4
|
+
graphql_grpc (0.1.4)
|
|
5
5
|
activesupport
|
|
6
6
|
graphql
|
|
7
7
|
grpc
|
|
@@ -17,9 +17,8 @@ GEM
|
|
|
17
17
|
addressable (2.5.2)
|
|
18
18
|
public_suffix (>= 2.0.2, < 4.0)
|
|
19
19
|
ast (2.4.0)
|
|
20
|
-
atlas-rb (1.0.11)
|
|
21
|
-
faraday
|
|
22
20
|
bombshell (0.1.6)
|
|
21
|
+
byebug (10.0.2)
|
|
23
22
|
coderay (1.1.2)
|
|
24
23
|
concurrent-ruby (1.1.3)
|
|
25
24
|
diff-lcs (1.3)
|
|
@@ -72,19 +71,12 @@ GEM
|
|
|
72
71
|
ruby_dep (~> 1.2)
|
|
73
72
|
lumberjack (1.0.13)
|
|
74
73
|
memoist (0.16.0)
|
|
75
|
-
metatron (0.1.1)
|
|
76
74
|
method_source (0.9.1)
|
|
77
75
|
minitest (5.11.3)
|
|
78
76
|
multi_json (1.13.1)
|
|
79
77
|
multipart-post (2.0.0)
|
|
80
78
|
mustermann (1.0.3)
|
|
81
79
|
nenv (0.3.0)
|
|
82
|
-
nf-configuration (1.4.2)
|
|
83
|
-
grpc (~> 1.12.0)
|
|
84
|
-
rspec (~> 3.2)
|
|
85
|
-
nf-discovery (0.2.0)
|
|
86
|
-
grpc (= 1.12)
|
|
87
|
-
rspec (~> 3.2)
|
|
88
80
|
notiffany (0.1.1)
|
|
89
81
|
nenv (~> 0.1)
|
|
90
82
|
shellany (~> 0.0)
|
|
@@ -96,6 +88,9 @@ GEM
|
|
|
96
88
|
pry (0.12.0)
|
|
97
89
|
coderay (~> 1.1.0)
|
|
98
90
|
method_source (~> 0.9.0)
|
|
91
|
+
pry-byebug (3.6.0)
|
|
92
|
+
byebug (~> 10.0)
|
|
93
|
+
pry (~> 0.10)
|
|
99
94
|
public_suffix (3.0.3)
|
|
100
95
|
rack (2.0.6)
|
|
101
96
|
rack-protection (2.0.4)
|
|
@@ -105,8 +100,6 @@ GEM
|
|
|
105
100
|
rb-fsevent (0.10.3)
|
|
106
101
|
rb-inotify (0.9.10)
|
|
107
102
|
ffi (>= 0.5.0, < 2)
|
|
108
|
-
redis (4.0.3)
|
|
109
|
-
retries (0.0.5)
|
|
110
103
|
rspec (3.8.0)
|
|
111
104
|
rspec-core (~> 3.8.0)
|
|
112
105
|
rspec-expectations (~> 3.8.0)
|
|
@@ -137,14 +130,6 @@ GEM
|
|
|
137
130
|
json-schema
|
|
138
131
|
sinatra (~> 2.0)
|
|
139
132
|
wirble
|
|
140
|
-
sdp-search (0.5.6.pre.rc.27)
|
|
141
|
-
atlas-rb (~> 1.0, >= 1.0.8)
|
|
142
|
-
grpc (~> 1.12, >= 1.12.0)
|
|
143
|
-
metatron (~> 0.1, >= 0.1.1)
|
|
144
|
-
nf-configuration (~> 1)
|
|
145
|
-
nf-discovery (~> 0)
|
|
146
|
-
redis
|
|
147
|
-
retries (~> 0.0.5)
|
|
148
133
|
shellany (0.0.1)
|
|
149
134
|
signet (0.11.0)
|
|
150
135
|
addressable (~> 2.3)
|
|
@@ -172,11 +157,10 @@ DEPENDENCIES
|
|
|
172
157
|
graphql_grpc!
|
|
173
158
|
guard-bundler
|
|
174
159
|
guard-rspec
|
|
175
|
-
pry
|
|
160
|
+
pry-byebug
|
|
176
161
|
rake (~> 10.0)
|
|
177
162
|
rubocop
|
|
178
163
|
ruby_robot
|
|
179
|
-
sdp-search
|
|
180
164
|
wirble
|
|
181
165
|
|
|
182
166
|
BUNDLED WITH
|
data/bin/example.rb
CHANGED
|
@@ -52,14 +52,14 @@ puts 'gRPC #report result: ' + proxy.report.to_s
|
|
|
52
52
|
|
|
53
53
|
# GraphQL
|
|
54
54
|
gql_query_doc = <<GRAPHQL_QUERY
|
|
55
|
-
query {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
query {
|
|
56
|
+
report {
|
|
57
|
+
error {
|
|
58
|
+
error
|
|
59
|
+
message
|
|
60
|
+
}
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
|
-
}
|
|
63
63
|
GRAPHQL_QUERY
|
|
64
64
|
|
|
65
65
|
puts "GraphQL query result: " +
|
data/graphql_grpc.gemspec
CHANGED
|
@@ -41,7 +41,7 @@ Gem::Specification.new do |spec|
|
|
|
41
41
|
# within bin/console env.
|
|
42
42
|
spec.add_development_dependency 'guard-bundler'
|
|
43
43
|
spec.add_development_dependency 'guard-rspec'
|
|
44
|
-
spec.add_development_dependency 'pry'
|
|
44
|
+
spec.add_development_dependency 'pry-byebug'
|
|
45
45
|
spec.add_development_dependency 'rubocop'
|
|
46
46
|
spec.add_development_dependency 'ruby_robot'
|
|
47
47
|
end
|
data/lib/graphql_grpc.rb
CHANGED
|
@@ -21,28 +21,29 @@
|
|
|
21
21
|
# SOFTWARE.
|
|
22
22
|
|
|
23
23
|
module GraphqlGrpc
|
|
24
|
+
#
|
|
25
|
+
# Translate from gRPC hashmaps w/ integer keys to arrays of objects with
|
|
26
|
+
# 'key' and 'value' fields.
|
|
27
|
+
#
|
|
28
|
+
# Recursively descend through the hash; if any hashes are encountered where
|
|
29
|
+
# all the keys are integers, convert that hash into an array of hashes with
|
|
30
|
+
# [{ key: <integer_value>, value: <the_value> },
|
|
31
|
+
# { key: <integer_value>, value: <the_value> },...]
|
|
32
|
+
#
|
|
33
|
+
# Example: {1: :hello, 2: :world} => [{key:1, value: :hello}, {key:2, value: :world}]
|
|
34
|
+
#
|
|
24
35
|
module Arrayify
|
|
25
|
-
#
|
|
26
|
-
# Translate from gRPC hashmaps w/ integer keys to arrays of objects with
|
|
27
|
-
# 'key' and 'value' fields.
|
|
28
|
-
#
|
|
29
|
-
# Recursively descend through the hash; if any hashes are encountered where
|
|
30
|
-
# all the keys are integers, convert that hash into an array of hashes with
|
|
31
|
-
# [{ key: <integer_value>, value: <the_value> },
|
|
32
|
-
# { key: <integer_value>, value: <the_value> },...]
|
|
33
|
-
#
|
|
34
|
-
# Example: {1: :hello, 2: :world} => [{key:1, value: :hello}, {key:2, value: :world}]
|
|
35
|
-
#
|
|
36
36
|
def arrayify_hashes(input)
|
|
37
37
|
case input.class.name.to_sym
|
|
38
38
|
when :Array
|
|
39
39
|
input.map { |i| arrayify_hashes(i) }
|
|
40
40
|
when :Hash
|
|
41
|
-
|
|
41
|
+
input_types = input.keys.map(&:class).compact.sort.uniq
|
|
42
|
+
if input_types.inject(true) { |tf, val| val.ancestors.include?(Integer) && tf }
|
|
42
43
|
arr = input.to_a.map { |e| { key: e.first, value: e.last } }
|
|
43
|
-
|
|
44
|
+
arrayify_hashes(arr)
|
|
44
45
|
else
|
|
45
|
-
input.each { |k,v| input[k] = arrayify_hashes(v) }
|
|
46
|
+
input.each { |k, v| input[k] = arrayify_hashes(v) }
|
|
46
47
|
end
|
|
47
48
|
else
|
|
48
49
|
input
|
data/lib/graphql_grpc/proxy.rb
CHANGED
data/lib/graphql_grpc/schema.rb
CHANGED
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
require 'google/protobuf/empty_pb'
|
|
24
24
|
|
|
25
25
|
module GraphqlGrpc
|
|
26
|
+
# :nodoc:
|
|
26
27
|
module Schema
|
|
27
28
|
# TODO: Find better way to detect queries
|
|
28
29
|
# Currently look for methods named 'get' or with no args
|
|
@@ -56,7 +57,8 @@ module GraphqlGrpc
|
|
|
56
57
|
end
|
|
57
58
|
|
|
58
59
|
def to_schema_query
|
|
59
|
-
|
|
60
|
+
if gql_queries.empty?
|
|
61
|
+
'type Query {'\
|
|
60
62
|
' # """This gRPC stub does not contain any methods that are mapped to '\
|
|
61
63
|
'GraphQL queries; this placeholder query field keeps the Query type from '\
|
|
62
64
|
'being empty which can break tools (GraphiQL) which expect Query to contain '\
|
|
@@ -64,9 +66,10 @@ module GraphqlGrpc
|
|
|
64
66
|
'
|
|
65
67
|
'\
|
|
66
68
|
' grpcPlacholder: Url'\
|
|
67
|
-
'}'
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
'}'
|
|
70
|
+
else
|
|
71
|
+
"type Query { #{to_function_types(gql_queries)} }"
|
|
72
|
+
end
|
|
70
73
|
end
|
|
71
74
|
|
|
72
75
|
def to_schema_mutations
|
|
@@ -76,7 +79,7 @@ module GraphqlGrpc
|
|
|
76
79
|
end
|
|
77
80
|
|
|
78
81
|
def to_gql_schema
|
|
79
|
-
<<
|
|
82
|
+
<<GRAPHQL_SCHEMA
|
|
80
83
|
#{to_schema_types}
|
|
81
84
|
#{to_schema_query}
|
|
82
85
|
#{to_schema_mutations}
|
|
@@ -84,7 +87,7 @@ module GraphqlGrpc
|
|
|
84
87
|
query: Query
|
|
85
88
|
#{gql_mutations.empty? ? '' : 'mutation: Mutation'}
|
|
86
89
|
}
|
|
87
|
-
|
|
90
|
+
GRAPHQL_SCHEMA
|
|
88
91
|
end
|
|
89
92
|
end
|
|
90
93
|
end
|
|
@@ -67,9 +67,9 @@ module GraphqlGrpc
|
|
|
67
67
|
def to_gql_type(prefix = '')
|
|
68
68
|
if entries.any?
|
|
69
69
|
<<EOF
|
|
70
|
-
#{input_or_type(prefix)} #{prefix}#{type_name} {
|
|
71
|
-
|
|
72
|
-
}
|
|
70
|
+
#{input_or_type(prefix)} #{prefix}#{type_name} {
|
|
71
|
+
#{types(prefix).join("\n ")}
|
|
72
|
+
}
|
|
73
73
|
EOF
|
|
74
74
|
else
|
|
75
75
|
# For now, treat empty types as scalars
|
|
@@ -229,12 +229,10 @@ module GraphqlGrpc
|
|
|
229
229
|
# as is the case when a google.protobuf.Empty object is declared
|
|
230
230
|
# as the argument for a gRPC call that is being mapped to a
|
|
231
231
|
# GraphQL query.
|
|
232
|
-
@descriptors.delete_if do |
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
descriptor.sub_types.empty?
|
|
237
|
-
)
|
|
232
|
+
@descriptors.delete_if do |_key, descriptor|
|
|
233
|
+
if descriptor.name.start_with?('google.protobuf') &&
|
|
234
|
+
descriptor.respond_to?(:sub_types) &&
|
|
235
|
+
descriptor.sub_types.empty?
|
|
238
236
|
true
|
|
239
237
|
else
|
|
240
238
|
false
|
data/lib/graphql_grpc/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: graphql_grpc
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Zane Claes
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: exe
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2018-
|
|
12
|
+
date: 2018-12-20 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: activesupport
|
|
@@ -124,7 +124,7 @@ dependencies:
|
|
|
124
124
|
- !ruby/object:Gem::Version
|
|
125
125
|
version: '0'
|
|
126
126
|
- !ruby/object:Gem::Dependency
|
|
127
|
-
name: pry
|
|
127
|
+
name: pry-byebug
|
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
|
129
129
|
requirements:
|
|
130
130
|
- - ">="
|
|
@@ -174,6 +174,8 @@ extensions: []
|
|
|
174
174
|
extra_rdoc_files: []
|
|
175
175
|
files:
|
|
176
176
|
- ".gitignore"
|
|
177
|
+
- ".rubocop.yml"
|
|
178
|
+
- ".rubocop_todo.yml"
|
|
177
179
|
- Gemfile
|
|
178
180
|
- Gemfile.lock
|
|
179
181
|
- Guardfile
|
|
@@ -187,7 +189,6 @@ files:
|
|
|
187
189
|
- lib/graphql_grpc.rb
|
|
188
190
|
- lib/graphql_grpc/arrayify.rb
|
|
189
191
|
- lib/graphql_grpc/function.rb
|
|
190
|
-
- lib/graphql_grpc/graphql.rb
|
|
191
192
|
- lib/graphql_grpc/proxy.rb
|
|
192
193
|
- lib/graphql_grpc/schema.rb
|
|
193
194
|
- lib/graphql_grpc/type_library.rb
|
data/lib/graphql_grpc/graphql.rb
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
# MIT License
|
|
2
|
-
#
|
|
3
|
-
# Copyright (c) 2018, Zane Claes
|
|
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.
|
|
22
|
-
|
|
23
|
-
require 'graphql'
|
|
24
|
-
module GraphqlGrpc
|
|
25
|
-
class Graphql
|
|
26
|
-
OP_FIELD = ::GraphQL::Language::Nodes::OperationDefinition
|
|
27
|
-
|
|
28
|
-
def initialize(proxy, error_presenter)
|
|
29
|
-
@error_presenter = error_presenter
|
|
30
|
-
@proxy = proxy
|
|
31
|
-
@output = { 'data' => {} }
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
# Given a graphQL document, execute those OperationDefinitions which map to a RPC
|
|
35
|
-
# The document will be modified to not include those fields / selections which were executed.
|
|
36
|
-
def execute(document, variables = {}, metadata = {})
|
|
37
|
-
@variables = variables || {}
|
|
38
|
-
@metadata = metadata || {}
|
|
39
|
-
document.definitions.reject! do |d|
|
|
40
|
-
# Filter out fields handled by GRPC...
|
|
41
|
-
d.selections.reject! { |s| graphql(s) } if d.is_a?(OP_FIELD)
|
|
42
|
-
d.selections.empty? # Filter the empty operations.
|
|
43
|
-
end
|
|
44
|
-
@output
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
private
|
|
48
|
-
|
|
49
|
-
# Execute a GraphQL field as an RPC on the proxy.
|
|
50
|
-
# @param field [GraphQL::Language::Nodes::GraphqlSelection] the RPC field.
|
|
51
|
-
# @param block [Proc] the presenter for the error handler.
|
|
52
|
-
def graphql(field)
|
|
53
|
-
return false unless @proxy.respond_to?(field.name)
|
|
54
|
-
|
|
55
|
-
key = (field.alias || field.name).to_s
|
|
56
|
-
resp = @proxy.rpc(field.name, vars_from(field), @metadata)
|
|
57
|
-
@output['data'][key] = present(field, resp)
|
|
58
|
-
true
|
|
59
|
-
rescue StandardError => e
|
|
60
|
-
@output['errors'] ||= []
|
|
61
|
-
@output['errors'] << @error_presenter.call(e)
|
|
62
|
-
true
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
# Filter the response down to the selected fields.
|
|
66
|
-
# n.b., the GRPC server should not include unselected fields, but those fields will appear
|
|
67
|
-
# as blank/empty in the response unless we actually filter the keys.
|
|
68
|
-
def present(field, resp)
|
|
69
|
-
return resp unless field.selections
|
|
70
|
-
|
|
71
|
-
if resp.is_a?(Hash)
|
|
72
|
-
return Time.at(resp[:seconds]).to_datetime if resp.keys == %i[seconds nanos] # TODO: find better way to detect timestamps...
|
|
73
|
-
|
|
74
|
-
result = field.selections.each_with_object({}) do |s, out|
|
|
75
|
-
out[(s.alias || s.name).to_s] = present(s, resp[s.name.to_sym])
|
|
76
|
-
end
|
|
77
|
-
result
|
|
78
|
-
elsif resp.is_a?(Array)
|
|
79
|
-
resp.map { |r| present(field, r) }
|
|
80
|
-
else
|
|
81
|
-
resp
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
# Extract the variables from a field.
|
|
86
|
-
def vars_from(field)
|
|
87
|
-
vars = {}
|
|
88
|
-
vars[:selections] = graphql_selections_array(field)
|
|
89
|
-
field.arguments.each do |arg|
|
|
90
|
-
val = if arg.value.is_a?(::GraphQL::Language::Nodes::VariableIdentifier)
|
|
91
|
-
@variables[arg.value.name.to_s]
|
|
92
|
-
elsif arg.value.is_a?(::GraphQL::Language::Nodes::Enum)
|
|
93
|
-
arg.value.name
|
|
94
|
-
else
|
|
95
|
-
arg.value
|
|
96
|
-
end
|
|
97
|
-
vars[arg.name] = val
|
|
98
|
-
end
|
|
99
|
-
vars
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
# Turn a field into a selections object for the RPC.
|
|
103
|
-
def graphql_selections_array(field)
|
|
104
|
-
return nil unless field && field.selections.any?
|
|
105
|
-
|
|
106
|
-
field.selections.map do |sel|
|
|
107
|
-
{
|
|
108
|
-
name: sel.name,
|
|
109
|
-
selections: graphql_selections_array(sel)
|
|
110
|
-
}
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
end
|