graphql 0.0.4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/graph_ql/directive.rb +36 -0
- data/lib/graph_ql/directives/directive_chain.rb +33 -0
- data/lib/graph_ql/directives/include_directive.rb +15 -0
- data/lib/graph_ql/directives/skip_directive.rb +15 -0
- data/lib/graph_ql/enum.rb +34 -0
- data/lib/graph_ql/fields/abstract_field.rb +37 -0
- data/lib/graph_ql/fields/access_field.rb +24 -0
- data/lib/graph_ql/fields/field.rb +34 -0
- data/lib/graph_ql/interface.rb +14 -0
- data/lib/graph_ql/introspection/arguments_field.rb +5 -0
- data/lib/graph_ql/introspection/directive_type.rb +12 -0
- data/lib/graph_ql/introspection/enum_value_type.rb +10 -0
- data/lib/graph_ql/introspection/enum_values_field.rb +15 -0
- data/lib/graph_ql/introspection/field_type.rb +11 -0
- data/lib/graph_ql/introspection/fields_field.rb +14 -0
- data/lib/graph_ql/introspection/input_fields_field.rb +12 -0
- data/lib/graph_ql/introspection/input_value_type.rb +10 -0
- data/lib/graph_ql/introspection/of_type_field.rb +12 -0
- data/lib/graph_ql/introspection/possible_types_field.rb +12 -0
- data/lib/graph_ql/introspection/schema_type.rb +32 -0
- data/lib/graph_ql/introspection/type_kind_enum.rb +7 -0
- data/lib/graph_ql/introspection/type_type.rb +22 -0
- data/lib/graph_ql/parser/nodes.rb +72 -0
- data/lib/graph_ql/parser/parser.rb +108 -0
- data/lib/graph_ql/parser/transform.rb +86 -0
- data/lib/graph_ql/parser/visitor.rb +47 -0
- data/lib/graph_ql/query.rb +50 -0
- data/lib/graph_ql/query/arguments.rb +25 -0
- data/lib/graph_ql/query/field_resolution_strategy.rb +83 -0
- data/lib/graph_ql/query/fragment_spread_resolution_strategy.rb +16 -0
- data/lib/graph_ql/query/inline_fragment_resolution_strategy.rb +14 -0
- data/lib/graph_ql/query/operation_resolver.rb +28 -0
- data/lib/graph_ql/query/selection_resolver.rb +20 -0
- data/lib/graph_ql/query/type_resolver.rb +19 -0
- data/lib/graph_ql/repl.rb +27 -0
- data/lib/graph_ql/schema.rb +30 -0
- data/lib/graph_ql/schema/type_reducer.rb +44 -0
- data/lib/graph_ql/type_kinds.rb +15 -0
- data/lib/graph_ql/types/abstract_type.rb +14 -0
- data/lib/graph_ql/types/boolean_type.rb +6 -0
- data/lib/graph_ql/types/float_type.rb +6 -0
- data/lib/graph_ql/types/input_object_type.rb +17 -0
- data/lib/graph_ql/types/input_value.rb +10 -0
- data/lib/graph_ql/types/int_type.rb +6 -0
- data/lib/graph_ql/types/list_type.rb +10 -0
- data/lib/graph_ql/types/non_null_type.rb +18 -0
- data/lib/graph_ql/types/non_null_with_bang.rb +5 -0
- data/lib/graph_ql/types/object_type.rb +62 -0
- data/lib/graph_ql/types/scalar_type.rb +5 -0
- data/lib/graph_ql/types/string_type.rb +6 -0
- data/lib/graph_ql/types/type_definer.rb +16 -0
- data/lib/graph_ql/union.rb +35 -0
- data/lib/graph_ql/validations/fields_are_defined_on_type.rb +44 -0
- data/lib/graph_ql/validations/fields_will_merge.rb +80 -0
- data/lib/graph_ql/validations/fragments_are_used.rb +24 -0
- data/lib/graph_ql/validator.rb +29 -0
- data/lib/graph_ql/version.rb +3 -0
- data/lib/graphql.rb +92 -99
- data/readme.md +17 -177
- data/spec/graph_ql/directive_spec.rb +81 -0
- data/spec/graph_ql/enum_spec.rb +5 -0
- data/spec/graph_ql/fields/field_spec.rb +10 -0
- data/spec/graph_ql/interface_spec.rb +13 -0
- data/spec/graph_ql/introspection/directive_type_spec.rb +40 -0
- data/spec/graph_ql/introspection/schema_type_spec.rb +39 -0
- data/spec/graph_ql/introspection/type_type_spec.rb +104 -0
- data/spec/graph_ql/parser/parser_spec.rb +120 -0
- data/spec/graph_ql/parser/transform_spec.rb +109 -0
- data/spec/graph_ql/parser/visitor_spec.rb +31 -0
- data/spec/graph_ql/query/operation_resolver_spec.rb +14 -0
- data/spec/graph_ql/query_spec.rb +82 -0
- data/spec/graph_ql/schema/type_reducer_spec.rb +24 -0
- data/spec/graph_ql/types/input_object_type_spec.rb +12 -0
- data/spec/graph_ql/types/object_type_spec.rb +35 -0
- data/spec/graph_ql/union_spec.rb +27 -0
- data/spec/graph_ql/validations/fields_are_defined_on_type_spec.rb +28 -0
- data/spec/graph_ql/validations/fields_will_merge_spec.rb +40 -0
- data/spec/graph_ql/validations/fragments_are_used_spec.rb +28 -0
- data/spec/graph_ql/validator_spec.rb +24 -0
- data/spec/spec_helper.rb +2 -2
- data/spec/support/dummy_app.rb +123 -63
- data/spec/support/dummy_data.rb +11 -0
- metadata +107 -59
- data/lib/graphql/call.rb +0 -8
- data/lib/graphql/connection.rb +0 -65
- data/lib/graphql/field.rb +0 -12
- data/lib/graphql/field_definer.rb +0 -25
- data/lib/graphql/introspection/call_type.rb +0 -13
- data/lib/graphql/introspection/connection.rb +0 -9
- data/lib/graphql/introspection/field_type.rb +0 -10
- data/lib/graphql/introspection/root_call_argument_node.rb +0 -5
- data/lib/graphql/introspection/root_call_type.rb +0 -20
- data/lib/graphql/introspection/schema_call.rb +0 -8
- data/lib/graphql/introspection/schema_type.rb +0 -17
- data/lib/graphql/introspection/type_call.rb +0 -8
- data/lib/graphql/introspection/type_type.rb +0 -18
- data/lib/graphql/node.rb +0 -244
- data/lib/graphql/parser/parser.rb +0 -39
- data/lib/graphql/parser/transform.rb +0 -22
- data/lib/graphql/query.rb +0 -109
- data/lib/graphql/root_call.rb +0 -202
- data/lib/graphql/root_call_argument.rb +0 -11
- data/lib/graphql/root_call_argument_definer.rb +0 -17
- data/lib/graphql/schema/all.rb +0 -46
- data/lib/graphql/schema/schema.rb +0 -87
- data/lib/graphql/schema/schema_validation.rb +0 -32
- data/lib/graphql/syntax/call.rb +0 -8
- data/lib/graphql/syntax/field.rb +0 -9
- data/lib/graphql/syntax/fragment.rb +0 -7
- data/lib/graphql/syntax/node.rb +0 -8
- data/lib/graphql/syntax/query.rb +0 -8
- data/lib/graphql/syntax/variable.rb +0 -7
- data/lib/graphql/types/boolean_type.rb +0 -3
- data/lib/graphql/types/number_type.rb +0 -3
- data/lib/graphql/types/object_type.rb +0 -6
- data/lib/graphql/types/string_type.rb +0 -3
- data/lib/graphql/version.rb +0 -3
- data/spec/graphql/node_spec.rb +0 -69
- data/spec/graphql/parser/parser_spec.rb +0 -168
- data/spec/graphql/parser/transform_spec.rb +0 -157
- data/spec/graphql/query_spec.rb +0 -274
- data/spec/graphql/root_call_spec.rb +0 -69
- data/spec/graphql/schema/schema_spec.rb +0 -93
- data/spec/graphql/schema/schema_validation_spec.rb +0 -48
- data/spec/support/nodes.rb +0 -175
@@ -0,0 +1,11 @@
|
|
1
|
+
Cheese = Struct.new(:id, :flavor, :fatContent, :source)
|
2
|
+
CHEESES = {
|
3
|
+
1 => Cheese.new(1, "Brie", 0.19, "COW"),
|
4
|
+
2 => Cheese.new(2, "Gouda", 0.3, "COW"),
|
5
|
+
3 => Cheese.new(3, "Manchego", 0.065, "SHEEP")
|
6
|
+
}
|
7
|
+
|
8
|
+
Milk = Struct.new(:id, :fatContent, :source)
|
9
|
+
MILKS = {
|
10
|
+
1 => Milk.new(1, 0.04, "COW"),
|
11
|
+
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Mosolgo
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: parslet
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.6
|
33
|
+
version: '1.6'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.6
|
40
|
+
version: '1.6'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: codeclimate-test-reporter
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,14 +114,14 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '5
|
117
|
+
version: '5'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '5
|
124
|
+
version: '5'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: minitest-focus
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -172,52 +172,88 @@ extensions: []
|
|
172
172
|
extra_rdoc_files: []
|
173
173
|
files:
|
174
174
|
- MIT-LICENSE
|
175
|
+
- lib/graph_ql/directive.rb
|
176
|
+
- lib/graph_ql/directives/directive_chain.rb
|
177
|
+
- lib/graph_ql/directives/include_directive.rb
|
178
|
+
- lib/graph_ql/directives/skip_directive.rb
|
179
|
+
- lib/graph_ql/enum.rb
|
180
|
+
- lib/graph_ql/fields/abstract_field.rb
|
181
|
+
- lib/graph_ql/fields/access_field.rb
|
182
|
+
- lib/graph_ql/fields/field.rb
|
183
|
+
- lib/graph_ql/interface.rb
|
184
|
+
- lib/graph_ql/introspection/arguments_field.rb
|
185
|
+
- lib/graph_ql/introspection/directive_type.rb
|
186
|
+
- lib/graph_ql/introspection/enum_value_type.rb
|
187
|
+
- lib/graph_ql/introspection/enum_values_field.rb
|
188
|
+
- lib/graph_ql/introspection/field_type.rb
|
189
|
+
- lib/graph_ql/introspection/fields_field.rb
|
190
|
+
- lib/graph_ql/introspection/input_fields_field.rb
|
191
|
+
- lib/graph_ql/introspection/input_value_type.rb
|
192
|
+
- lib/graph_ql/introspection/of_type_field.rb
|
193
|
+
- lib/graph_ql/introspection/possible_types_field.rb
|
194
|
+
- lib/graph_ql/introspection/schema_type.rb
|
195
|
+
- lib/graph_ql/introspection/type_kind_enum.rb
|
196
|
+
- lib/graph_ql/introspection/type_type.rb
|
197
|
+
- lib/graph_ql/parser/nodes.rb
|
198
|
+
- lib/graph_ql/parser/parser.rb
|
199
|
+
- lib/graph_ql/parser/transform.rb
|
200
|
+
- lib/graph_ql/parser/visitor.rb
|
201
|
+
- lib/graph_ql/query.rb
|
202
|
+
- lib/graph_ql/query/arguments.rb
|
203
|
+
- lib/graph_ql/query/field_resolution_strategy.rb
|
204
|
+
- lib/graph_ql/query/fragment_spread_resolution_strategy.rb
|
205
|
+
- lib/graph_ql/query/inline_fragment_resolution_strategy.rb
|
206
|
+
- lib/graph_ql/query/operation_resolver.rb
|
207
|
+
- lib/graph_ql/query/selection_resolver.rb
|
208
|
+
- lib/graph_ql/query/type_resolver.rb
|
209
|
+
- lib/graph_ql/repl.rb
|
210
|
+
- lib/graph_ql/schema.rb
|
211
|
+
- lib/graph_ql/schema/type_reducer.rb
|
212
|
+
- lib/graph_ql/type_kinds.rb
|
213
|
+
- lib/graph_ql/types/abstract_type.rb
|
214
|
+
- lib/graph_ql/types/boolean_type.rb
|
215
|
+
- lib/graph_ql/types/float_type.rb
|
216
|
+
- lib/graph_ql/types/input_object_type.rb
|
217
|
+
- lib/graph_ql/types/input_value.rb
|
218
|
+
- lib/graph_ql/types/int_type.rb
|
219
|
+
- lib/graph_ql/types/list_type.rb
|
220
|
+
- lib/graph_ql/types/non_null_type.rb
|
221
|
+
- lib/graph_ql/types/non_null_with_bang.rb
|
222
|
+
- lib/graph_ql/types/object_type.rb
|
223
|
+
- lib/graph_ql/types/scalar_type.rb
|
224
|
+
- lib/graph_ql/types/string_type.rb
|
225
|
+
- lib/graph_ql/types/type_definer.rb
|
226
|
+
- lib/graph_ql/union.rb
|
227
|
+
- lib/graph_ql/validations/fields_are_defined_on_type.rb
|
228
|
+
- lib/graph_ql/validations/fields_will_merge.rb
|
229
|
+
- lib/graph_ql/validations/fragments_are_used.rb
|
230
|
+
- lib/graph_ql/validator.rb
|
231
|
+
- lib/graph_ql/version.rb
|
175
232
|
- lib/graphql.rb
|
176
|
-
- lib/graphql/call.rb
|
177
|
-
- lib/graphql/connection.rb
|
178
|
-
- lib/graphql/field.rb
|
179
|
-
- lib/graphql/field_definer.rb
|
180
|
-
- lib/graphql/introspection/call_type.rb
|
181
|
-
- lib/graphql/introspection/connection.rb
|
182
|
-
- lib/graphql/introspection/field_type.rb
|
183
|
-
- lib/graphql/introspection/root_call_argument_node.rb
|
184
|
-
- lib/graphql/introspection/root_call_type.rb
|
185
|
-
- lib/graphql/introspection/schema_call.rb
|
186
|
-
- lib/graphql/introspection/schema_type.rb
|
187
|
-
- lib/graphql/introspection/type_call.rb
|
188
|
-
- lib/graphql/introspection/type_type.rb
|
189
|
-
- lib/graphql/node.rb
|
190
|
-
- lib/graphql/parser/parser.rb
|
191
|
-
- lib/graphql/parser/transform.rb
|
192
|
-
- lib/graphql/query.rb
|
193
|
-
- lib/graphql/root_call.rb
|
194
|
-
- lib/graphql/root_call_argument.rb
|
195
|
-
- lib/graphql/root_call_argument_definer.rb
|
196
|
-
- lib/graphql/schema/all.rb
|
197
|
-
- lib/graphql/schema/schema.rb
|
198
|
-
- lib/graphql/schema/schema_validation.rb
|
199
|
-
- lib/graphql/syntax/call.rb
|
200
|
-
- lib/graphql/syntax/field.rb
|
201
|
-
- lib/graphql/syntax/fragment.rb
|
202
|
-
- lib/graphql/syntax/node.rb
|
203
|
-
- lib/graphql/syntax/query.rb
|
204
|
-
- lib/graphql/syntax/variable.rb
|
205
|
-
- lib/graphql/types/boolean_type.rb
|
206
|
-
- lib/graphql/types/number_type.rb
|
207
|
-
- lib/graphql/types/object_type.rb
|
208
|
-
- lib/graphql/types/string_type.rb
|
209
|
-
- lib/graphql/version.rb
|
210
233
|
- readme.md
|
211
|
-
- spec/
|
212
|
-
- spec/
|
213
|
-
- spec/
|
214
|
-
- spec/
|
215
|
-
- spec/
|
216
|
-
- spec/
|
217
|
-
- spec/
|
234
|
+
- spec/graph_ql/directive_spec.rb
|
235
|
+
- spec/graph_ql/enum_spec.rb
|
236
|
+
- spec/graph_ql/fields/field_spec.rb
|
237
|
+
- spec/graph_ql/interface_spec.rb
|
238
|
+
- spec/graph_ql/introspection/directive_type_spec.rb
|
239
|
+
- spec/graph_ql/introspection/schema_type_spec.rb
|
240
|
+
- spec/graph_ql/introspection/type_type_spec.rb
|
241
|
+
- spec/graph_ql/parser/parser_spec.rb
|
242
|
+
- spec/graph_ql/parser/transform_spec.rb
|
243
|
+
- spec/graph_ql/parser/visitor_spec.rb
|
244
|
+
- spec/graph_ql/query/operation_resolver_spec.rb
|
245
|
+
- spec/graph_ql/query_spec.rb
|
246
|
+
- spec/graph_ql/schema/type_reducer_spec.rb
|
247
|
+
- spec/graph_ql/types/input_object_type_spec.rb
|
248
|
+
- spec/graph_ql/types/object_type_spec.rb
|
249
|
+
- spec/graph_ql/union_spec.rb
|
250
|
+
- spec/graph_ql/validations/fields_are_defined_on_type_spec.rb
|
251
|
+
- spec/graph_ql/validations/fields_will_merge_spec.rb
|
252
|
+
- spec/graph_ql/validations/fragments_are_used_spec.rb
|
253
|
+
- spec/graph_ql/validator_spec.rb
|
218
254
|
- spec/spec_helper.rb
|
219
255
|
- spec/support/dummy_app.rb
|
220
|
-
- spec/support/
|
256
|
+
- spec/support/dummy_data.rb
|
221
257
|
homepage: http://github.com/rmosolgo/graphql-ruby
|
222
258
|
licenses:
|
223
259
|
- MIT
|
@@ -238,19 +274,31 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
238
274
|
version: '0'
|
239
275
|
requirements: []
|
240
276
|
rubyforge_project:
|
241
|
-
rubygems_version: 2.
|
277
|
+
rubygems_version: 2.4.5
|
242
278
|
signing_key:
|
243
279
|
specification_version: 4
|
244
280
|
summary: GraphQL
|
245
281
|
test_files:
|
246
|
-
- spec/
|
247
|
-
- spec/
|
248
|
-
- spec/
|
249
|
-
- spec/
|
250
|
-
- spec/
|
251
|
-
- spec/
|
252
|
-
- spec/
|
282
|
+
- spec/graph_ql/directive_spec.rb
|
283
|
+
- spec/graph_ql/enum_spec.rb
|
284
|
+
- spec/graph_ql/fields/field_spec.rb
|
285
|
+
- spec/graph_ql/interface_spec.rb
|
286
|
+
- spec/graph_ql/introspection/directive_type_spec.rb
|
287
|
+
- spec/graph_ql/introspection/schema_type_spec.rb
|
288
|
+
- spec/graph_ql/introspection/type_type_spec.rb
|
289
|
+
- spec/graph_ql/parser/parser_spec.rb
|
290
|
+
- spec/graph_ql/parser/transform_spec.rb
|
291
|
+
- spec/graph_ql/parser/visitor_spec.rb
|
292
|
+
- spec/graph_ql/query/operation_resolver_spec.rb
|
293
|
+
- spec/graph_ql/query_spec.rb
|
294
|
+
- spec/graph_ql/schema/type_reducer_spec.rb
|
295
|
+
- spec/graph_ql/types/input_object_type_spec.rb
|
296
|
+
- spec/graph_ql/types/object_type_spec.rb
|
297
|
+
- spec/graph_ql/union_spec.rb
|
298
|
+
- spec/graph_ql/validations/fields_are_defined_on_type_spec.rb
|
299
|
+
- spec/graph_ql/validations/fields_will_merge_spec.rb
|
300
|
+
- spec/graph_ql/validations/fragments_are_used_spec.rb
|
301
|
+
- spec/graph_ql/validator_spec.rb
|
253
302
|
- spec/spec_helper.rb
|
254
303
|
- spec/support/dummy_app.rb
|
255
|
-
- spec/support/
|
256
|
-
has_rdoc:
|
304
|
+
- spec/support/dummy_data.rb
|
data/lib/graphql/call.rb
DELETED
data/lib/graphql/connection.rb
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
# {Connection}s wrap collections of objects.
|
2
|
-
#
|
3
|
-
# Out of the box, the only field it has is `edges`, which provides access to the members of the collection.
|
4
|
-
#
|
5
|
-
# You can define a custom {Connection} to use. This allows you to define fields and calls at the collection level (rather than the item level)
|
6
|
-
#
|
7
|
-
# You can access the collection as `target` ({Node#target}).
|
8
|
-
#
|
9
|
-
# @example
|
10
|
-
# class UpvotesConnection < GraphQL::Collection
|
11
|
-
# type :upvotes # adds it to the schema
|
12
|
-
# call :first, -> (prev_items, first) { prev_items.first(first.to_i) }
|
13
|
-
# call :after, -> (prev_items, after) { prev_items.select {|i| i.id > after.to_i } }
|
14
|
-
#
|
15
|
-
# field.number(:count) # delegates to the underlying collection
|
16
|
-
# field.boolean(:any)
|
17
|
-
#
|
18
|
-
# def any
|
19
|
-
# target.any?
|
20
|
-
# end
|
21
|
-
# end
|
22
|
-
#
|
23
|
-
# # Then, this connection will be used for connections whose names match:
|
24
|
-
# class PostNode < GraphQL::Node
|
25
|
-
# field.upvotes(:upvotes)
|
26
|
-
# # ^^ uses `UpvotesConnection` based on naming convention
|
27
|
-
# end
|
28
|
-
#
|
29
|
-
# # And you can use the fields in a query:
|
30
|
-
# <<QUERY
|
31
|
-
# find_post(10) {
|
32
|
-
# title,
|
33
|
-
# upvotes {
|
34
|
-
# count,
|
35
|
-
# any,
|
36
|
-
# edges {
|
37
|
-
# node { created_at }
|
38
|
-
# }
|
39
|
-
# }
|
40
|
-
# }
|
41
|
-
# QUERY
|
42
|
-
class GraphQL::Connection < GraphQL::Node
|
43
|
-
exposes "Array"
|
44
|
-
field.object(:edges)
|
45
|
-
|
46
|
-
def edge_fields
|
47
|
-
@edge_fields ||= syntax_fields.find { |f| f.identifier == "edges" }.fields
|
48
|
-
end
|
49
|
-
|
50
|
-
def edges
|
51
|
-
raise "#{self.class} expected a connection, but got `nil`" if target.nil?
|
52
|
-
target.map do |item|
|
53
|
-
node_class = GraphQL::SCHEMA.type_for_object(item)
|
54
|
-
node = node_class.new(item, fields: edge_fields, query: query)
|
55
|
-
res = node.as_result
|
56
|
-
res
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
class << self
|
61
|
-
def default_schema_name
|
62
|
-
name.split("::").last.sub(/Connection$/, '').underscore
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
data/lib/graphql/field.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
# Each {Node} has {Field}s that are used to look up connected nodes at query-time
|
2
|
-
class GraphQL::Field
|
3
|
-
attr_reader :type, :name
|
4
|
-
def initialize(name:, type:)
|
5
|
-
@name = name
|
6
|
-
@type = type.to_s
|
7
|
-
end
|
8
|
-
|
9
|
-
def type_class
|
10
|
-
GraphQL::SCHEMA.get_type(type)
|
11
|
-
end
|
12
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# Every {Node} class has a {FieldDefiner} instance that
|
2
|
-
# enables the `field.{something}` API.
|
3
|
-
class GraphQL::FieldDefiner
|
4
|
-
attr_reader :owner_class
|
5
|
-
def initialize(owner_class)
|
6
|
-
@owner_class = owner_class
|
7
|
-
end
|
8
|
-
|
9
|
-
# `method_name` is used as a field type and looked up against {GraphQL::SCHEMA}.
|
10
|
-
# `args[0]` is the name for the field of that type.
|
11
|
-
def method_missing(method_name, *args, &block)
|
12
|
-
map_field(args[0], type: method_name, description: args[1])
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
|
17
|
-
def map_field(field_name, type: nil, description: nil)
|
18
|
-
field_name = field_name.to_s
|
19
|
-
mapping = GraphQL::Field.new(
|
20
|
-
name: field_name,
|
21
|
-
type: type,
|
22
|
-
)
|
23
|
-
owner_class.own_fields[field_name] = mapping
|
24
|
-
end
|
25
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
class GraphQL::Introspection::CallType < GraphQL::Node
|
2
|
-
exposes "GraphQL::Call"
|
3
|
-
field.string(:name)
|
4
|
-
field.string(:arguments)
|
5
|
-
|
6
|
-
def arguments
|
7
|
-
args = target.lambda.parameters
|
8
|
-
args.shift
|
9
|
-
args.map { |p| "#{p[1]} (#{p[0]})" }.join(", ")
|
10
|
-
rescue StandardError => e
|
11
|
-
raise "Errored on #{name} (#{self}): #{e}"
|
12
|
-
end
|
13
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
class GraphQL::Introspection::RootCallType < GraphQL::Node
|
2
|
-
exposes "GraphQL::RootCall"
|
3
|
-
field.string(:name)
|
4
|
-
field.string(:returns)
|
5
|
-
field.introspection_connection(:arguments)
|
6
|
-
|
7
|
-
|
8
|
-
def returns
|
9
|
-
return_declarations = @target.return_declarations
|
10
|
-
return_declarations.keys.map(&:to_s)
|
11
|
-
end
|
12
|
-
|
13
|
-
def name
|
14
|
-
schema_name
|
15
|
-
end
|
16
|
-
|
17
|
-
def arguments
|
18
|
-
target.arguments.values
|
19
|
-
end
|
20
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
class GraphQL::Introspection::SchemaType < GraphQL::Node
|
2
|
-
exposes "GraphQL::Schema::Schema"
|
3
|
-
field.introspection_connection(:calls)
|
4
|
-
field.introspection_connection(:types)
|
5
|
-
|
6
|
-
def cursor
|
7
|
-
"schema"
|
8
|
-
end
|
9
|
-
|
10
|
-
def types
|
11
|
-
@target.types.values
|
12
|
-
end
|
13
|
-
|
14
|
-
def calls
|
15
|
-
target.calls.values
|
16
|
-
end
|
17
|
-
end
|