graphql 1.7.14 → 1.8.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/generators/graphql/function_generator.rb +1 -1
- data/lib/generators/graphql/loader_generator.rb +1 -1
- data/lib/generators/graphql/mutation_generator.rb +1 -6
- data/lib/generators/graphql/templates/function.erb +2 -2
- data/lib/generators/graphql/templates/loader.erb +2 -2
- data/lib/graphql.rb +2 -0
- data/lib/graphql/argument.rb +0 -1
- data/lib/graphql/backwards_compatibility.rb +2 -3
- data/lib/graphql/base_type.rb +18 -16
- data/lib/graphql/compatibility/query_parser_specification.rb +0 -117
- data/lib/graphql/compatibility/query_parser_specification/parse_error_specification.rb +0 -14
- data/lib/graphql/define/assign_object_field.rb +5 -12
- data/lib/graphql/deprecated_dsl.rb +28 -0
- data/lib/graphql/directive.rb +0 -1
- data/lib/graphql/enum_type.rb +1 -3
- data/lib/graphql/execution.rb +0 -1
- data/lib/graphql/execution/multiplex.rb +29 -12
- data/lib/graphql/field.rb +5 -20
- data/lib/graphql/function.rb +12 -0
- data/lib/graphql/input_object_type.rb +1 -3
- data/lib/graphql/internal_representation/node.rb +14 -26
- data/lib/graphql/internal_representation/visit.rb +6 -3
- data/lib/graphql/introspection/arguments_field.rb +0 -1
- data/lib/graphql/introspection/enum_values_field.rb +0 -1
- data/lib/graphql/introspection/fields_field.rb +0 -1
- data/lib/graphql/introspection/input_fields_field.rb +0 -1
- data/lib/graphql/introspection/interfaces_field.rb +0 -1
- data/lib/graphql/introspection/of_type_field.rb +0 -1
- data/lib/graphql/introspection/possible_types_field.rb +0 -1
- data/lib/graphql/introspection/schema_field.rb +0 -1
- data/lib/graphql/introspection/type_by_name_field.rb +0 -1
- data/lib/graphql/introspection/typename_field.rb +0 -1
- data/lib/graphql/language.rb +0 -3
- data/lib/graphql/language/generation.rb +182 -3
- data/lib/graphql/language/lexer.rb +69 -144
- data/lib/graphql/language/lexer.rl +4 -15
- data/lib/graphql/language/nodes.rb +76 -136
- data/lib/graphql/language/parser.rb +621 -668
- data/lib/graphql/language/parser.y +11 -17
- data/lib/graphql/language/token.rb +3 -10
- data/lib/graphql/object_type.rb +6 -1
- data/lib/graphql/query.rb +13 -8
- data/lib/graphql/query/arguments.rb +33 -48
- data/lib/graphql/query/context.rb +1 -0
- data/lib/graphql/query/literal_input.rb +1 -4
- data/lib/graphql/relay/connection_resolve.rb +3 -0
- data/lib/graphql/relay/global_id_resolve.rb +5 -1
- data/lib/graphql/relay/relation_connection.rb +19 -14
- data/lib/graphql/schema.rb +219 -12
- data/lib/graphql/schema/argument.rb +33 -0
- data/lib/graphql/schema/build_from_definition.rb +18 -64
- data/lib/graphql/schema/enum.rb +76 -0
- data/lib/graphql/schema/field.rb +127 -0
- data/lib/graphql/schema/field/dynamic_resolve.rb +63 -0
- data/lib/graphql/schema/field/unwrapped_resolve.rb +20 -0
- data/lib/graphql/schema/input_object.rb +61 -0
- data/lib/graphql/schema/interface.rb +32 -0
- data/lib/graphql/schema/loader.rb +2 -2
- data/lib/graphql/schema/member.rb +97 -0
- data/lib/graphql/schema/member/build_type.rb +106 -0
- data/lib/graphql/schema/member/has_fields.rb +56 -0
- data/lib/graphql/schema/member/instrumentation.rb +113 -0
- data/lib/graphql/schema/member/list_type_proxy.rb +21 -0
- data/lib/graphql/schema/member/non_null_type_proxy.rb +21 -0
- data/lib/graphql/schema/object.rb +65 -0
- data/lib/graphql/schema/printer.rb +266 -33
- data/lib/graphql/schema/scalar.rb +25 -0
- data/lib/graphql/schema/traversal.rb +26 -17
- data/lib/graphql/schema/union.rb +48 -0
- data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +1 -5
- data/lib/graphql/static_validation/rules/fields_will_merge.rb +8 -15
- data/lib/graphql/static_validation/rules/variables_are_used_and_defined.rb +1 -11
- data/lib/graphql/subscriptions/action_cable_subscriptions.rb +5 -7
- data/lib/graphql/tracing.rb +0 -1
- data/lib/graphql/tracing/platform_tracing.rb +7 -20
- data/lib/graphql/tracing/scout_tracing.rb +2 -2
- data/lib/graphql/unresolved_type_error.rb +2 -3
- data/lib/graphql/version.rb +1 -1
- data/readme.md +1 -1
- data/spec/dummy/app/channels/graphql_channel.rb +1 -22
- data/spec/dummy/log/development.log +0 -239
- data/spec/dummy/log/test.log +0 -204
- data/spec/dummy/test/system/action_cable_subscription_test.rb +0 -4
- data/spec/dummy/tmp/screenshots/failures_test_it_handles_subscriptions.png +0 -0
- data/spec/generators/graphql/function_generator_spec.rb +0 -26
- data/spec/generators/graphql/loader_generator_spec.rb +0 -24
- data/spec/graphql/analysis/max_query_complexity_spec.rb +3 -3
- data/spec/graphql/analysis/max_query_depth_spec.rb +3 -3
- data/spec/graphql/backtrace_spec.rb +0 -10
- data/spec/graphql/base_type_spec.rb +5 -19
- data/spec/graphql/boolean_type_spec.rb +3 -3
- data/spec/graphql/directive_spec.rb +1 -3
- data/spec/graphql/enum_type_spec.rb +5 -18
- data/spec/graphql/execution/execute_spec.rb +1 -1
- data/spec/graphql/execution/multiplex_spec.rb +2 -2
- data/spec/graphql/float_type_spec.rb +2 -2
- data/spec/graphql/id_type_spec.rb +1 -1
- data/spec/graphql/input_object_type_spec.rb +2 -15
- data/spec/graphql/int_type_spec.rb +2 -2
- data/spec/graphql/internal_representation/rewrite_spec.rb +2 -2
- data/spec/graphql/introspection/schema_type_spec.rb +0 -1
- data/spec/graphql/language/generation_spec.rb +186 -21
- data/spec/graphql/language/lexer_spec.rb +1 -21
- data/spec/graphql/language/nodes_spec.rb +12 -21
- data/spec/graphql/language/parser_spec.rb +1 -1
- data/spec/graphql/query/arguments_spec.rb +15 -37
- data/spec/graphql/query/serial_execution/value_resolution_spec.rb +2 -2
- data/spec/graphql/query/variables_spec.rb +1 -1
- data/spec/graphql/query_spec.rb +5 -31
- data/spec/graphql/rake_task_spec.rb +1 -3
- data/spec/graphql/relay/base_connection_spec.rb +1 -1
- data/spec/graphql/relay/connection_instrumentation_spec.rb +2 -2
- data/spec/graphql/relay/connection_resolve_spec.rb +1 -1
- data/spec/graphql/relay/connection_type_spec.rb +1 -1
- data/spec/graphql/relay/mutation_spec.rb +3 -3
- data/spec/graphql/relay/relation_connection_spec.rb +1 -65
- data/spec/graphql/schema/build_from_definition_spec.rb +4 -86
- data/spec/graphql/schema/enum_spec.rb +60 -0
- data/spec/graphql/schema/field_spec.rb +14 -0
- data/spec/graphql/schema/input_object_spec.rb +43 -0
- data/spec/graphql/schema/interface_spec.rb +98 -0
- data/spec/graphql/schema/object_spec.rb +119 -0
- data/spec/graphql/schema/printer_spec.rb +15 -92
- data/spec/graphql/schema/scalar_spec.rb +40 -0
- data/spec/graphql/schema/union_spec.rb +35 -0
- data/spec/graphql/schema/validation_spec.rb +1 -1
- data/spec/graphql/schema/warden_spec.rb +11 -11
- data/spec/graphql/schema_spec.rb +25 -23
- data/spec/graphql/static_validation/rules/fields_have_appropriate_selections_spec.rb +2 -10
- data/spec/graphql/static_validation/rules/fields_will_merge_spec.rb +2 -2
- data/spec/graphql/string_type_spec.rb +3 -3
- data/spec/graphql/subscriptions_spec.rb +1 -1
- data/spec/graphql/tracing/platform_tracing_spec.rb +1 -60
- data/spec/support/dummy/schema.rb +25 -39
- data/spec/support/jazz.rb +334 -0
- data/spec/support/lazy_helpers.rb +21 -23
- data/spec/support/star_wars/data.rb +7 -6
- data/spec/support/star_wars/schema.rb +109 -142
- metadata +39 -33
- data/lib/graphql/execution/instrumentation.rb +0 -82
- data/lib/graphql/language/block_string.rb +0 -47
- data/lib/graphql/language/document_from_schema_definition.rb +0 -277
- data/lib/graphql/language/printer.rb +0 -351
- data/lib/graphql/tracing/data_dog_tracing.rb +0 -49
- data/spec/graphql/execution/instrumentation_spec.rb +0 -165
- data/spec/graphql/language/block_string_spec.rb +0 -70
- data/spec/graphql/language/document_from_schema_definition_spec.rb +0 -770
- data/spec/graphql/language/printer_spec.rb +0 -203
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.0.pre1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Mosolgo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: benchmark-ips
|
@@ -136,20 +136,6 @@ dependencies:
|
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: 3.0.0
|
139
|
-
- !ruby/object:Gem::Dependency
|
140
|
-
name: memory_profiler
|
141
|
-
requirement: !ruby/object:Gem::Requirement
|
142
|
-
requirements:
|
143
|
-
- - ">="
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
version: '0'
|
146
|
-
type: :development
|
147
|
-
prerelease: false
|
148
|
-
version_requirements: !ruby/object:Gem::Requirement
|
149
|
-
requirements:
|
150
|
-
- - ">="
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
version: '0'
|
153
139
|
- !ruby/object:Gem::Dependency
|
154
140
|
name: minitest
|
155
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -376,6 +362,7 @@ files:
|
|
376
362
|
- lib/graphql/define/no_definition_error.rb
|
377
363
|
- lib/graphql/define/non_null_with_bang.rb
|
378
364
|
- lib/graphql/define/type_definer.rb
|
365
|
+
- lib/graphql/deprecated_dsl.rb
|
379
366
|
- lib/graphql/directive.rb
|
380
367
|
- lib/graphql/directive/deprecated_directive.rb
|
381
368
|
- lib/graphql/directive/include_directive.rb
|
@@ -385,7 +372,6 @@ files:
|
|
385
372
|
- lib/graphql/execution/directive_checks.rb
|
386
373
|
- lib/graphql/execution/execute.rb
|
387
374
|
- lib/graphql/execution/flatten.rb
|
388
|
-
- lib/graphql/execution/instrumentation.rb
|
389
375
|
- lib/graphql/execution/lazy.rb
|
390
376
|
- lib/graphql/execution/lazy/lazy_method_map.rb
|
391
377
|
- lib/graphql/execution/lazy/resolve.rb
|
@@ -431,17 +417,14 @@ files:
|
|
431
417
|
- lib/graphql/invalid_name_error.rb
|
432
418
|
- lib/graphql/invalid_null_error.rb
|
433
419
|
- lib/graphql/language.rb
|
434
|
-
- lib/graphql/language/block_string.rb
|
435
420
|
- lib/graphql/language/comments.rb
|
436
421
|
- lib/graphql/language/definition_slice.rb
|
437
|
-
- lib/graphql/language/document_from_schema_definition.rb
|
438
422
|
- lib/graphql/language/generation.rb
|
439
423
|
- lib/graphql/language/lexer.rb
|
440
424
|
- lib/graphql/language/lexer.rl
|
441
425
|
- lib/graphql/language/nodes.rb
|
442
426
|
- lib/graphql/language/parser.rb
|
443
427
|
- lib/graphql/language/parser.y
|
444
|
-
- lib/graphql/language/printer.rb
|
445
428
|
- lib/graphql/language/token.rb
|
446
429
|
- lib/graphql/language/visitor.rb
|
447
430
|
- lib/graphql/list_type.rb
|
@@ -489,6 +472,7 @@ files:
|
|
489
472
|
- lib/graphql/runtime_type_error.rb
|
490
473
|
- lib/graphql/scalar_type.rb
|
491
474
|
- lib/graphql/schema.rb
|
475
|
+
- lib/graphql/schema/argument.rb
|
492
476
|
- lib/graphql/schema/base_64_encoder.rb
|
493
477
|
- lib/graphql/schema/build_from_definition.rb
|
494
478
|
- lib/graphql/schema/build_from_definition/resolve_map.rb
|
@@ -496,16 +480,31 @@ files:
|
|
496
480
|
- lib/graphql/schema/catchall_middleware.rb
|
497
481
|
- lib/graphql/schema/default_parse_error.rb
|
498
482
|
- lib/graphql/schema/default_type_error.rb
|
483
|
+
- lib/graphql/schema/enum.rb
|
484
|
+
- lib/graphql/schema/field.rb
|
485
|
+
- lib/graphql/schema/field/dynamic_resolve.rb
|
486
|
+
- lib/graphql/schema/field/unwrapped_resolve.rb
|
487
|
+
- lib/graphql/schema/input_object.rb
|
488
|
+
- lib/graphql/schema/interface.rb
|
499
489
|
- lib/graphql/schema/invalid_type_error.rb
|
500
490
|
- lib/graphql/schema/loader.rb
|
491
|
+
- lib/graphql/schema/member.rb
|
492
|
+
- lib/graphql/schema/member/build_type.rb
|
493
|
+
- lib/graphql/schema/member/has_fields.rb
|
494
|
+
- lib/graphql/schema/member/instrumentation.rb
|
495
|
+
- lib/graphql/schema/member/list_type_proxy.rb
|
496
|
+
- lib/graphql/schema/member/non_null_type_proxy.rb
|
501
497
|
- lib/graphql/schema/middleware_chain.rb
|
502
498
|
- lib/graphql/schema/null_mask.rb
|
499
|
+
- lib/graphql/schema/object.rb
|
503
500
|
- lib/graphql/schema/possible_types.rb
|
504
501
|
- lib/graphql/schema/printer.rb
|
505
502
|
- lib/graphql/schema/rescue_middleware.rb
|
503
|
+
- lib/graphql/schema/scalar.rb
|
506
504
|
- lib/graphql/schema/timeout_middleware.rb
|
507
505
|
- lib/graphql/schema/traversal.rb
|
508
506
|
- lib/graphql/schema/type_expression.rb
|
507
|
+
- lib/graphql/schema/union.rb
|
509
508
|
- lib/graphql/schema/unique_within_type.rb
|
510
509
|
- lib/graphql/schema/validation.rb
|
511
510
|
- lib/graphql/schema/warden.rb
|
@@ -553,7 +552,6 @@ files:
|
|
553
552
|
- lib/graphql/tracing.rb
|
554
553
|
- lib/graphql/tracing/active_support_notifications_tracing.rb
|
555
554
|
- lib/graphql/tracing/appsignal_tracing.rb
|
556
|
-
- lib/graphql/tracing/data_dog_tracing.rb
|
557
555
|
- lib/graphql/tracing/new_relic_tracing.rb
|
558
556
|
- lib/graphql/tracing/platform_tracing.rb
|
559
557
|
- lib/graphql/tracing/scout_tracing.rb
|
@@ -893,7 +891,6 @@ files:
|
|
893
891
|
- spec/graphql/directive_spec.rb
|
894
892
|
- spec/graphql/enum_type_spec.rb
|
895
893
|
- spec/graphql/execution/execute_spec.rb
|
896
|
-
- spec/graphql/execution/instrumentation_spec.rb
|
897
894
|
- spec/graphql/execution/lazy/lazy_method_map_spec.rb
|
898
895
|
- spec/graphql/execution/lazy_spec.rb
|
899
896
|
- spec/graphql/execution/multiplex_spec.rb
|
@@ -914,15 +911,12 @@ files:
|
|
914
911
|
- spec/graphql/introspection/schema_type_spec.rb
|
915
912
|
- spec/graphql/introspection/type_by_name_field_spec.rb
|
916
913
|
- spec/graphql/introspection/type_type_spec.rb
|
917
|
-
- spec/graphql/language/block_string_spec.rb
|
918
914
|
- spec/graphql/language/definition_slice_spec.rb
|
919
|
-
- spec/graphql/language/document_from_schema_definition_spec.rb
|
920
915
|
- spec/graphql/language/equality_spec.rb
|
921
916
|
- spec/graphql/language/generation_spec.rb
|
922
917
|
- spec/graphql/language/lexer_spec.rb
|
923
918
|
- spec/graphql/language/nodes_spec.rb
|
924
919
|
- spec/graphql/language/parser_spec.rb
|
925
|
-
- spec/graphql/language/printer_spec.rb
|
926
920
|
- spec/graphql/language/visitor_spec.rb
|
927
921
|
- spec/graphql/list_type_spec.rb
|
928
922
|
- spec/graphql/non_null_type_spec.rb
|
@@ -950,13 +944,20 @@ files:
|
|
950
944
|
- spec/graphql/scalar_type_spec.rb
|
951
945
|
- spec/graphql/schema/build_from_definition_spec.rb
|
952
946
|
- spec/graphql/schema/catchall_middleware_spec.rb
|
947
|
+
- spec/graphql/schema/enum_spec.rb
|
948
|
+
- spec/graphql/schema/field_spec.rb
|
949
|
+
- spec/graphql/schema/input_object_spec.rb
|
950
|
+
- spec/graphql/schema/interface_spec.rb
|
953
951
|
- spec/graphql/schema/loader_spec.rb
|
954
952
|
- spec/graphql/schema/middleware_chain_spec.rb
|
953
|
+
- spec/graphql/schema/object_spec.rb
|
955
954
|
- spec/graphql/schema/printer_spec.rb
|
956
955
|
- spec/graphql/schema/rescue_middleware_spec.rb
|
956
|
+
- spec/graphql/schema/scalar_spec.rb
|
957
957
|
- spec/graphql/schema/timeout_middleware_spec.rb
|
958
958
|
- spec/graphql/schema/traversal_spec.rb
|
959
959
|
- spec/graphql/schema/type_expression_spec.rb
|
960
|
+
- spec/graphql/schema/union_spec.rb
|
960
961
|
- spec/graphql/schema/unique_within_type_spec.rb
|
961
962
|
- spec/graphql/schema/validation_spec.rb
|
962
963
|
- spec/graphql/schema/warden_spec.rb
|
@@ -1001,6 +1002,7 @@ files:
|
|
1001
1002
|
- spec/support/base_generator_test.rb
|
1002
1003
|
- spec/support/dummy/data.rb
|
1003
1004
|
- spec/support/dummy/schema.rb
|
1005
|
+
- spec/support/jazz.rb
|
1004
1006
|
- spec/support/lazy_helpers.rb
|
1005
1007
|
- spec/support/magic_cards/schema.graphql
|
1006
1008
|
- spec/support/minimum_input_object.rb
|
@@ -1022,15 +1024,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
1022
1024
|
requirements:
|
1023
1025
|
- - ">="
|
1024
1026
|
- !ruby/object:Gem::Version
|
1025
|
-
version: 2.
|
1027
|
+
version: 2.2.0
|
1026
1028
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
1027
1029
|
requirements:
|
1028
|
-
- - "
|
1030
|
+
- - ">"
|
1029
1031
|
- !ruby/object:Gem::Version
|
1030
|
-
version:
|
1032
|
+
version: 1.3.1
|
1031
1033
|
requirements: []
|
1032
1034
|
rubyforge_project:
|
1033
|
-
rubygems_version: 2.
|
1035
|
+
rubygems_version: 2.6.11
|
1034
1036
|
signing_key:
|
1035
1037
|
specification_version: 4
|
1036
1038
|
summary: A GraphQL language and runtime for Ruby
|
@@ -1365,7 +1367,6 @@ test_files:
|
|
1365
1367
|
- spec/graphql/directive_spec.rb
|
1366
1368
|
- spec/graphql/enum_type_spec.rb
|
1367
1369
|
- spec/graphql/execution/execute_spec.rb
|
1368
|
-
- spec/graphql/execution/instrumentation_spec.rb
|
1369
1370
|
- spec/graphql/execution/lazy/lazy_method_map_spec.rb
|
1370
1371
|
- spec/graphql/execution/lazy_spec.rb
|
1371
1372
|
- spec/graphql/execution/multiplex_spec.rb
|
@@ -1386,15 +1387,12 @@ test_files:
|
|
1386
1387
|
- spec/graphql/introspection/schema_type_spec.rb
|
1387
1388
|
- spec/graphql/introspection/type_by_name_field_spec.rb
|
1388
1389
|
- spec/graphql/introspection/type_type_spec.rb
|
1389
|
-
- spec/graphql/language/block_string_spec.rb
|
1390
1390
|
- spec/graphql/language/definition_slice_spec.rb
|
1391
|
-
- spec/graphql/language/document_from_schema_definition_spec.rb
|
1392
1391
|
- spec/graphql/language/equality_spec.rb
|
1393
1392
|
- spec/graphql/language/generation_spec.rb
|
1394
1393
|
- spec/graphql/language/lexer_spec.rb
|
1395
1394
|
- spec/graphql/language/nodes_spec.rb
|
1396
1395
|
- spec/graphql/language/parser_spec.rb
|
1397
|
-
- spec/graphql/language/printer_spec.rb
|
1398
1396
|
- spec/graphql/language/visitor_spec.rb
|
1399
1397
|
- spec/graphql/list_type_spec.rb
|
1400
1398
|
- spec/graphql/non_null_type_spec.rb
|
@@ -1422,13 +1420,20 @@ test_files:
|
|
1422
1420
|
- spec/graphql/scalar_type_spec.rb
|
1423
1421
|
- spec/graphql/schema/build_from_definition_spec.rb
|
1424
1422
|
- spec/graphql/schema/catchall_middleware_spec.rb
|
1423
|
+
- spec/graphql/schema/enum_spec.rb
|
1424
|
+
- spec/graphql/schema/field_spec.rb
|
1425
|
+
- spec/graphql/schema/input_object_spec.rb
|
1426
|
+
- spec/graphql/schema/interface_spec.rb
|
1425
1427
|
- spec/graphql/schema/loader_spec.rb
|
1426
1428
|
- spec/graphql/schema/middleware_chain_spec.rb
|
1429
|
+
- spec/graphql/schema/object_spec.rb
|
1427
1430
|
- spec/graphql/schema/printer_spec.rb
|
1428
1431
|
- spec/graphql/schema/rescue_middleware_spec.rb
|
1432
|
+
- spec/graphql/schema/scalar_spec.rb
|
1429
1433
|
- spec/graphql/schema/timeout_middleware_spec.rb
|
1430
1434
|
- spec/graphql/schema/traversal_spec.rb
|
1431
1435
|
- spec/graphql/schema/type_expression_spec.rb
|
1436
|
+
- spec/graphql/schema/union_spec.rb
|
1432
1437
|
- spec/graphql/schema/unique_within_type_spec.rb
|
1433
1438
|
- spec/graphql/schema/validation_spec.rb
|
1434
1439
|
- spec/graphql/schema/warden_spec.rb
|
@@ -1473,6 +1478,7 @@ test_files:
|
|
1473
1478
|
- spec/support/base_generator_test.rb
|
1474
1479
|
- spec/support/dummy/data.rb
|
1475
1480
|
- spec/support/dummy/schema.rb
|
1481
|
+
- spec/support/jazz.rb
|
1476
1482
|
- spec/support/lazy_helpers.rb
|
1477
1483
|
- spec/support/magic_cards/schema.graphql
|
1478
1484
|
- spec/support/minimum_input_object.rb
|
@@ -1,82 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module GraphQL
|
3
|
-
module Execution
|
4
|
-
module Instrumentation
|
5
|
-
# This function implements the instrumentation policy:
|
6
|
-
#
|
7
|
-
# - Instrumenters are a stack; the first `before_query` will have the last `after_query`
|
8
|
-
# - If a `before_` hook returned without an error, its corresponding `after_` hook will run.
|
9
|
-
# - If the `before_` hook did _not_ run, the `after_` hook will not be called.
|
10
|
-
#
|
11
|
-
# When errors are raised from `after_` hooks:
|
12
|
-
# - Subsequent `after_` hooks _are_ called
|
13
|
-
# - The first raised error is captured; later errors are ignored
|
14
|
-
# - If an error was capture, it's re-raised after all hooks are finished
|
15
|
-
#
|
16
|
-
# Partial runs of instrumentation are possible:
|
17
|
-
# - If a `before_multiplex` hook raises an error, no `before_query` hooks will run
|
18
|
-
# - If a `before_query` hook raises an error, subsequent `before_query` hooks will not run (on any query)
|
19
|
-
def self.apply_instrumenters(multiplex)
|
20
|
-
schema = multiplex.schema
|
21
|
-
queries = multiplex.queries
|
22
|
-
query_instrumenters = schema.instrumenters[:query]
|
23
|
-
multiplex_instrumenters = schema.instrumenters[:multiplex]
|
24
|
-
|
25
|
-
# First, run multiplex instrumentation, then query instrumentation for each query
|
26
|
-
call_hooks(multiplex_instrumenters, multiplex, :before_multiplex, :after_multiplex) do
|
27
|
-
each_query_call_hooks(query_instrumenters, queries) do
|
28
|
-
# Let them be executed
|
29
|
-
yield
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
class << self
|
35
|
-
private
|
36
|
-
# Call the before_ hooks of each query,
|
37
|
-
# Then yield if no errors.
|
38
|
-
# `call_hooks` takes care of appropriate cleanup.
|
39
|
-
def each_query_call_hooks(instrumenters, queries, i = 0)
|
40
|
-
if i >= queries.length
|
41
|
-
yield
|
42
|
-
else
|
43
|
-
query = queries[i]
|
44
|
-
call_hooks(instrumenters, query, :before_query, :after_query) {
|
45
|
-
each_query_call_hooks(instrumenters, queries, i + 1) {
|
46
|
-
yield
|
47
|
-
}
|
48
|
-
}
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
# Call each before hook, and if they all succeed, yield.
|
53
|
-
# If they don't all succeed, call after_ for each one that succeeded.
|
54
|
-
def call_hooks(instrumenters, object, before_hook_name, after_hook_name, i = 0)
|
55
|
-
if i >= instrumenters.length
|
56
|
-
# We've reached the end of the instrumenters, so start exiting the call stack.
|
57
|
-
# (This will eventually call the originally-passed block.)
|
58
|
-
yield
|
59
|
-
else
|
60
|
-
# Get the next instrumenter and call the before_hook.
|
61
|
-
instrumenter = instrumenters[i]
|
62
|
-
instrumenter.public_send(before_hook_name, object)
|
63
|
-
# At this point, the before_hook did _not_ raise an error.
|
64
|
-
# (If it did raise an error, we wouldn't reach this point.)
|
65
|
-
# So we should guarantee that we run the after_hook.
|
66
|
-
begin
|
67
|
-
# Call the next instrumenter on the list,
|
68
|
-
# basically passing along the original block
|
69
|
-
call_hooks(instrumenters, object, before_hook_name, after_hook_name, i + 1) {
|
70
|
-
yield
|
71
|
-
}
|
72
|
-
ensure
|
73
|
-
# Regardless of how the next instrumenter in the list behaves,
|
74
|
-
# call the after_hook of this instrumenter
|
75
|
-
instrumenter.public_send(after_hook_name, object)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module GraphQL
|
3
|
-
module Language
|
4
|
-
module BlockString
|
5
|
-
# Remove leading and trailing whitespace from a block string.
|
6
|
-
# See "Block Strings" in https://github.com/facebook/graphql/blob/master/spec/Section%202%20--%20Language.md
|
7
|
-
def self.trim_whitespace(str)
|
8
|
-
lines = str.split("\n")
|
9
|
-
common_indent = nil
|
10
|
-
|
11
|
-
# find the common whitespace
|
12
|
-
lines.each_with_index do |line, idx|
|
13
|
-
if idx == 0
|
14
|
-
next
|
15
|
-
end
|
16
|
-
line_length = line.size
|
17
|
-
line_indent = line[/\A */].size
|
18
|
-
if line_indent < line_length && (common_indent.nil? || line_indent < common_indent)
|
19
|
-
common_indent = line_indent
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
# Remove the common whitespace
|
24
|
-
if common_indent
|
25
|
-
lines.each_with_index do |line, idx|
|
26
|
-
if idx == 0
|
27
|
-
next
|
28
|
-
else
|
29
|
-
line[0, common_indent] = ""
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
# Remove leading & trailing blank lines
|
35
|
-
while lines.first.empty?
|
36
|
-
lines.shift
|
37
|
-
end
|
38
|
-
while lines.last.empty?
|
39
|
-
lines.pop
|
40
|
-
end
|
41
|
-
|
42
|
-
# Rebuild the string
|
43
|
-
lines.join("\n")
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,277 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module GraphQL
|
3
|
-
module Language
|
4
|
-
# @api private
|
5
|
-
#
|
6
|
-
# {GraphQL::Language::DocumentFromSchemaDefinition} is used to convert a {GraphQL::Schema} object
|
7
|
-
# To a {GraphQL::Language::Document} AST node.
|
8
|
-
#
|
9
|
-
# @param context [Hash]
|
10
|
-
# @param only [<#call(member, ctx)>]
|
11
|
-
# @param except [<#call(member, ctx)>]
|
12
|
-
# @param include_introspection_types [Boolean] Whether or not to include introspection types in the AST
|
13
|
-
# @param include_built_in_scalars [Boolean] Whether or not to include built in scalars in the AST
|
14
|
-
# @param include_built_in_directives [Boolean] Whether or not to include built in diirectives in the AST
|
15
|
-
class DocumentFromSchemaDefinition
|
16
|
-
def initialize(
|
17
|
-
schema, context: nil, only: nil, except: nil, include_introspection_types: false,
|
18
|
-
include_built_in_directives: false, include_built_in_scalars: false, always_include_schema: false
|
19
|
-
)
|
20
|
-
@schema = schema
|
21
|
-
@always_include_schema = always_include_schema
|
22
|
-
@include_introspection_types = include_introspection_types
|
23
|
-
@include_built_in_scalars = include_built_in_scalars
|
24
|
-
@include_built_in_directives = include_built_in_directives
|
25
|
-
|
26
|
-
@warden = GraphQL::Schema::Warden.new(
|
27
|
-
GraphQL::Filter.new(only: only, except: except),
|
28
|
-
schema: @schema,
|
29
|
-
context: context,
|
30
|
-
)
|
31
|
-
end
|
32
|
-
|
33
|
-
def document
|
34
|
-
GraphQL::Language::Nodes::Document.new(
|
35
|
-
definitions: build_definition_nodes
|
36
|
-
)
|
37
|
-
end
|
38
|
-
|
39
|
-
def build_schema_node
|
40
|
-
GraphQL::Language::Nodes::SchemaDefinition.new(
|
41
|
-
query: warden.root_type_for_operation("query"),
|
42
|
-
mutation: warden.root_type_for_operation("mutation"),
|
43
|
-
subscription: warden.root_type_for_operation("subscription")
|
44
|
-
)
|
45
|
-
end
|
46
|
-
|
47
|
-
def build_object_type_node(object_type)
|
48
|
-
GraphQL::Language::Nodes::ObjectTypeDefinition.new(
|
49
|
-
name: object_type.name,
|
50
|
-
interfaces: warden.interfaces(object_type).sort_by(&:name).map { |iface| build_type_name_node(iface) },
|
51
|
-
fields: build_field_nodes(warden.fields(object_type)),
|
52
|
-
description: object_type.description,
|
53
|
-
)
|
54
|
-
end
|
55
|
-
|
56
|
-
def build_field_node(field)
|
57
|
-
field_node = GraphQL::Language::Nodes::FieldDefinition.new(
|
58
|
-
name: field.name,
|
59
|
-
arguments: build_argument_nodes(warden.arguments(field)),
|
60
|
-
type: build_type_name_node(field.type),
|
61
|
-
description: field.description,
|
62
|
-
)
|
63
|
-
|
64
|
-
if field.deprecation_reason
|
65
|
-
field_node.directives << GraphQL::Language::Nodes::Directive.new(
|
66
|
-
name: GraphQL::Directive::DeprecatedDirective.name,
|
67
|
-
arguments: [GraphQL::Language::Nodes::Argument.new(name: "reason", value: field.deprecation_reason)]
|
68
|
-
)
|
69
|
-
end
|
70
|
-
|
71
|
-
field_node
|
72
|
-
end
|
73
|
-
|
74
|
-
def build_union_type_node(union_type)
|
75
|
-
GraphQL::Language::Nodes::UnionTypeDefinition.new(
|
76
|
-
name: union_type.name,
|
77
|
-
description: union_type.description,
|
78
|
-
types: warden.possible_types(union_type).sort_by(&:name).map { |type| build_type_name_node(type) }
|
79
|
-
)
|
80
|
-
end
|
81
|
-
|
82
|
-
def build_interface_type_node(interface_type)
|
83
|
-
GraphQL::Language::Nodes::InterfaceTypeDefinition.new(
|
84
|
-
name: interface_type.name,
|
85
|
-
description: interface_type.description,
|
86
|
-
fields: build_field_nodes(warden.fields(interface_type))
|
87
|
-
)
|
88
|
-
end
|
89
|
-
|
90
|
-
def build_enum_type_node(enum_type)
|
91
|
-
GraphQL::Language::Nodes::EnumTypeDefinition.new(
|
92
|
-
name: enum_type.name,
|
93
|
-
values: warden.enum_values(enum_type).sort_by(&:name).map do |enum_value|
|
94
|
-
build_enum_value_node(enum_value)
|
95
|
-
end,
|
96
|
-
description: enum_type.description,
|
97
|
-
)
|
98
|
-
end
|
99
|
-
|
100
|
-
def build_enum_value_node(enum_value)
|
101
|
-
enum_value_node = GraphQL::Language::Nodes::EnumValueDefinition.new(
|
102
|
-
name: enum_value.name,
|
103
|
-
description: enum_value.description,
|
104
|
-
)
|
105
|
-
|
106
|
-
if enum_value.deprecation_reason
|
107
|
-
enum_value_node.directives << GraphQL::Language::Nodes::Directive.new(
|
108
|
-
name: GraphQL::Directive::DeprecatedDirective.name,
|
109
|
-
arguments: [GraphQL::Language::Nodes::Argument.new(name: "reason", value: enum_value.deprecation_reason)]
|
110
|
-
)
|
111
|
-
end
|
112
|
-
|
113
|
-
enum_value_node
|
114
|
-
end
|
115
|
-
|
116
|
-
def build_scalar_type_node(scalar_type)
|
117
|
-
GraphQL::Language::Nodes::ScalarTypeDefinition.new(
|
118
|
-
name: scalar_type.name,
|
119
|
-
description: scalar_type.description,
|
120
|
-
)
|
121
|
-
end
|
122
|
-
|
123
|
-
def build_argument_node(argument)
|
124
|
-
argument_node = GraphQL::Language::Nodes::InputValueDefinition.new(
|
125
|
-
name: argument.name,
|
126
|
-
description: argument.description,
|
127
|
-
type: build_type_name_node(argument.type),
|
128
|
-
)
|
129
|
-
|
130
|
-
if argument.default_value?
|
131
|
-
argument_node.default_value = build_default_value(argument.default_value, argument.type)
|
132
|
-
end
|
133
|
-
|
134
|
-
argument_node
|
135
|
-
end
|
136
|
-
|
137
|
-
def build_input_object_node(input_object)
|
138
|
-
GraphQL::Language::Nodes::InputObjectTypeDefinition.new(
|
139
|
-
name: input_object.name,
|
140
|
-
fields: build_argument_nodes(warden.arguments(input_object)),
|
141
|
-
description: input_object.description,
|
142
|
-
)
|
143
|
-
end
|
144
|
-
|
145
|
-
def build_directive_node(directive)
|
146
|
-
GraphQL::Language::Nodes::DirectiveDefinition.new(
|
147
|
-
name: directive.name,
|
148
|
-
arguments: build_argument_nodes(warden.arguments(directive)),
|
149
|
-
locations: directive.locations.map(&:to_s),
|
150
|
-
description: directive.description,
|
151
|
-
)
|
152
|
-
end
|
153
|
-
|
154
|
-
def build_type_name_node(type)
|
155
|
-
case type
|
156
|
-
when GraphQL::ListType
|
157
|
-
GraphQL::Language::Nodes::ListType.new(
|
158
|
-
of_type: build_type_name_node(type.of_type)
|
159
|
-
)
|
160
|
-
when GraphQL::NonNullType
|
161
|
-
GraphQL::Language::Nodes::NonNullType.new(
|
162
|
-
of_type: build_type_name_node(type.of_type)
|
163
|
-
)
|
164
|
-
else
|
165
|
-
GraphQL::Language::Nodes::TypeName.new(name: type.name)
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
def build_default_value(default_value, type)
|
170
|
-
if default_value.nil?
|
171
|
-
return GraphQL::Language::Nodes::NullValue.new(name: "null")
|
172
|
-
end
|
173
|
-
|
174
|
-
case type
|
175
|
-
when GraphQL::ScalarType
|
176
|
-
type.coerce_isolated_result(default_value)
|
177
|
-
when EnumType
|
178
|
-
GraphQL::Language::Nodes::Enum.new(name: type.coerce_isolated_result(default_value))
|
179
|
-
when InputObjectType
|
180
|
-
GraphQL::Language::Nodes::InputObject.new(
|
181
|
-
arguments: default_value.to_h.map do |arg_name, arg_value|
|
182
|
-
arg_type = type.input_fields.fetch(arg_name.to_s).type
|
183
|
-
GraphQL::Language::Nodes::Argument.new(
|
184
|
-
name: arg_name,
|
185
|
-
value: build_default_value(arg_value, arg_type)
|
186
|
-
)
|
187
|
-
end
|
188
|
-
)
|
189
|
-
when NonNullType
|
190
|
-
build_default_value(default_value, type.of_type)
|
191
|
-
when ListType
|
192
|
-
default_value.to_a.map { |v| build_default_value(v, type.of_type) }
|
193
|
-
else
|
194
|
-
raise NotImplementedError, "Unexpected default value type #{type.inspect}"
|
195
|
-
end
|
196
|
-
end
|
197
|
-
|
198
|
-
def build_type_definition_node(type)
|
199
|
-
case type
|
200
|
-
when GraphQL::ObjectType
|
201
|
-
build_object_type_node(type)
|
202
|
-
when GraphQL::UnionType
|
203
|
-
build_union_type_node(type)
|
204
|
-
when GraphQL::InterfaceType
|
205
|
-
build_interface_type_node(type)
|
206
|
-
when GraphQL::ScalarType
|
207
|
-
build_scalar_type_node(type)
|
208
|
-
when GraphQL::EnumType
|
209
|
-
build_enum_type_node(type)
|
210
|
-
when GraphQL::InputObjectType
|
211
|
-
build_input_object_node(type)
|
212
|
-
else
|
213
|
-
raise TypeError
|
214
|
-
end
|
215
|
-
end
|
216
|
-
|
217
|
-
def build_argument_nodes(arguments)
|
218
|
-
arguments
|
219
|
-
.map { |arg| build_argument_node(arg) }
|
220
|
-
.sort_by(&:name)
|
221
|
-
end
|
222
|
-
|
223
|
-
def build_directive_nodes(directives)
|
224
|
-
if !include_built_in_directives
|
225
|
-
directives = directives.reject { |directive| directive.default_directive? }
|
226
|
-
end
|
227
|
-
|
228
|
-
directives
|
229
|
-
.map { |directive| build_directive_node(directive) }
|
230
|
-
.sort_by(&:name)
|
231
|
-
end
|
232
|
-
|
233
|
-
def build_definition_nodes
|
234
|
-
definitions = []
|
235
|
-
definitions << build_schema_node if include_schema_node?
|
236
|
-
definitions += build_directive_nodes(warden.directives)
|
237
|
-
definitions += build_type_definition_nodes(warden.types)
|
238
|
-
definitions
|
239
|
-
end
|
240
|
-
|
241
|
-
def build_type_definition_nodes(types)
|
242
|
-
if !include_introspection_types
|
243
|
-
types = types.reject { |type| type.introspection? }
|
244
|
-
end
|
245
|
-
|
246
|
-
if !include_built_in_scalars
|
247
|
-
types = types.reject { |type| type.default_scalar? }
|
248
|
-
end
|
249
|
-
|
250
|
-
types
|
251
|
-
.map { |type| build_type_definition_node(type) }
|
252
|
-
.sort_by(&:name)
|
253
|
-
end
|
254
|
-
|
255
|
-
def build_field_nodes(fields)
|
256
|
-
fields
|
257
|
-
.map { |field| build_field_node(field) }
|
258
|
-
.sort_by(&:name)
|
259
|
-
end
|
260
|
-
|
261
|
-
private
|
262
|
-
|
263
|
-
def include_schema_node?
|
264
|
-
always_include_schema || !schema_respects_root_name_conventions?(schema)
|
265
|
-
end
|
266
|
-
|
267
|
-
def schema_respects_root_name_conventions?(schema)
|
268
|
-
(schema.query.nil? || schema.query.name == 'Query') &&
|
269
|
-
(schema.mutation.nil? || schema.mutation.name == 'Mutation') &&
|
270
|
-
(schema.subscription.nil? || schema.subscription.name == 'Subscription')
|
271
|
-
end
|
272
|
-
|
273
|
-
attr_reader :schema, :warden, :always_include_schema,
|
274
|
-
:include_introspection_types, :include_built_in_directives, :include_built_in_scalars
|
275
|
-
end
|
276
|
-
end
|
277
|
-
end
|