graphql 1.7.6 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/generators/graphql/function_generator.rb +1 -1
- data/lib/generators/graphql/install_generator.rb +14 -8
- data/lib/generators/graphql/loader_generator.rb +1 -1
- data/lib/generators/graphql/mutation_generator.rb +6 -1
- data/lib/generators/graphql/templates/function.erb +2 -2
- data/lib/generators/graphql/templates/loader.erb +2 -2
- data/lib/generators/graphql/templates/schema.erb +1 -1
- data/lib/graphql/argument.rb +25 -19
- data/lib/graphql/backtrace/tracer.rb +16 -22
- data/lib/graphql/backtrace.rb +1 -1
- data/lib/graphql/backwards_compatibility.rb +2 -3
- data/lib/graphql/base_type.rb +31 -31
- data/lib/graphql/compatibility/query_parser_specification/parse_error_specification.rb +14 -0
- data/lib/graphql/compatibility/query_parser_specification.rb +117 -0
- data/lib/graphql/define/assign_object_field.rb +5 -12
- data/lib/graphql/deprecated_dsl.rb +42 -0
- data/lib/graphql/directive.rb +1 -0
- data/lib/graphql/enum_type.rb +3 -1
- data/lib/graphql/execution/execute.rb +21 -13
- data/lib/graphql/execution/instrumentation.rb +82 -0
- data/lib/graphql/execution/lazy/lazy_method_map.rb +1 -1
- data/lib/graphql/execution/lazy/resolve.rb +1 -3
- data/lib/graphql/execution/multiplex.rb +12 -29
- data/lib/graphql/execution.rb +1 -0
- data/lib/graphql/field.rb +21 -4
- data/lib/graphql/function.rb +14 -0
- data/lib/graphql/input_object_type.rb +3 -1
- data/lib/graphql/interface_type.rb +5 -3
- data/lib/graphql/internal_representation/node.rb +26 -14
- data/lib/graphql/internal_representation/visit.rb +3 -6
- data/lib/graphql/introspection/base_object.rb +16 -0
- data/lib/graphql/introspection/directive_location_enum.rb +11 -7
- data/lib/graphql/introspection/directive_type.rb +23 -16
- data/lib/graphql/introspection/dynamic_fields.rb +11 -0
- data/lib/graphql/introspection/entry_points.rb +29 -0
- data/lib/graphql/introspection/enum_value_type.rb +16 -11
- data/lib/graphql/introspection/field_type.rb +21 -12
- data/lib/graphql/introspection/input_value_type.rb +26 -23
- data/lib/graphql/introspection/schema_field.rb +7 -2
- data/lib/graphql/introspection/schema_type.rb +36 -22
- data/lib/graphql/introspection/type_by_name_field.rb +10 -2
- data/lib/graphql/introspection/type_kind_enum.rb +10 -6
- data/lib/graphql/introspection/type_type.rb +85 -23
- data/lib/graphql/introspection/typename_field.rb +1 -0
- data/lib/graphql/introspection.rb +3 -10
- data/lib/graphql/language/block_string.rb +47 -0
- data/lib/graphql/language/document_from_schema_definition.rb +280 -0
- data/lib/graphql/language/generation.rb +3 -182
- data/lib/graphql/language/lexer.rb +144 -69
- data/lib/graphql/language/lexer.rl +15 -4
- data/lib/graphql/language/nodes.rb +141 -78
- data/lib/graphql/language/parser.rb +677 -630
- data/lib/graphql/language/parser.y +18 -12
- data/lib/graphql/language/printer.rb +361 -0
- data/lib/graphql/language/token.rb +10 -3
- data/lib/graphql/language.rb +3 -0
- data/lib/graphql/non_null_type.rb +1 -1
- data/lib/graphql/object_type.rb +1 -6
- data/lib/graphql/query/arguments.rb +63 -32
- data/lib/graphql/query/context.rb +32 -2
- data/lib/graphql/query/literal_input.rb +4 -1
- data/lib/graphql/query/null_context.rb +1 -1
- data/lib/graphql/query/result.rb +1 -1
- data/lib/graphql/query/variables.rb +21 -3
- data/lib/graphql/query.rb +19 -6
- data/lib/graphql/railtie.rb +109 -0
- data/lib/graphql/relay/connection_resolve.rb +3 -0
- data/lib/graphql/relay/connection_type.rb +5 -3
- data/lib/graphql/relay/edge_type.rb +2 -1
- data/lib/graphql/relay/global_id_resolve.rb +5 -1
- data/lib/graphql/relay/mongo_relation_connection.rb +40 -0
- data/lib/graphql/relay/mutation/instrumentation.rb +1 -1
- data/lib/graphql/relay/mutation/resolve.rb +5 -1
- data/lib/graphql/relay/relation_connection.rb +14 -19
- data/lib/graphql/relay/type_extensions.rb +30 -0
- data/lib/graphql/relay.rb +2 -0
- data/lib/graphql/scalar_type.rb +14 -2
- data/lib/graphql/schema/argument.rb +92 -0
- data/lib/graphql/schema/build_from_definition.rb +64 -18
- data/lib/graphql/schema/enum.rb +85 -0
- data/lib/graphql/schema/enum_value.rb +74 -0
- data/lib/graphql/schema/field.rb +372 -0
- data/lib/graphql/schema/finder.rb +153 -0
- data/lib/graphql/schema/input_object.rb +87 -0
- data/lib/graphql/schema/interface.rb +105 -0
- data/lib/graphql/schema/introspection_system.rb +93 -0
- data/lib/graphql/schema/late_bound_type.rb +32 -0
- data/lib/graphql/schema/list.rb +32 -0
- data/lib/graphql/schema/loader.rb +2 -2
- data/lib/graphql/schema/member/accepts_definition.rb +152 -0
- data/lib/graphql/schema/member/base_dsl_methods.rb +100 -0
- data/lib/graphql/schema/member/build_type.rb +137 -0
- data/lib/graphql/schema/member/cached_graphql_definition.rb +26 -0
- data/lib/graphql/schema/member/graphql_type_names.rb +21 -0
- data/lib/graphql/schema/member/has_arguments.rb +50 -0
- data/lib/graphql/schema/member/has_fields.rb +130 -0
- data/lib/graphql/schema/member/instrumentation.rb +115 -0
- data/lib/graphql/schema/member/type_system_helpers.rb +34 -0
- data/lib/graphql/schema/member.rb +28 -0
- data/lib/graphql/schema/middleware_chain.rb +5 -1
- data/lib/graphql/schema/mutation.rb +138 -0
- data/lib/graphql/schema/non_null.rb +38 -0
- data/lib/graphql/schema/object.rb +81 -0
- data/lib/graphql/schema/printer.rb +33 -266
- data/lib/graphql/schema/relay_classic_mutation.rb +87 -0
- data/lib/graphql/schema/rescue_middleware.rb +8 -7
- data/lib/graphql/schema/resolver.rb +122 -0
- data/lib/graphql/schema/scalar.rb +35 -0
- data/lib/graphql/schema/traversal.rb +102 -22
- data/lib/graphql/schema/union.rb +36 -0
- data/lib/graphql/schema/validation.rb +3 -2
- data/lib/graphql/schema.rb +381 -12
- data/lib/graphql/static_validation/definition_dependencies.rb +1 -1
- data/lib/graphql/static_validation/literal_validator.rb +16 -4
- data/lib/graphql/static_validation/rules/fields_are_defined_on_type.rb +6 -6
- data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +5 -1
- data/lib/graphql/static_validation/rules/fields_will_merge.rb +15 -8
- data/lib/graphql/static_validation/rules/variables_are_used_and_defined.rb +11 -1
- data/lib/graphql/static_validation/validation_context.rb +1 -1
- data/lib/graphql/subscriptions/action_cable_subscriptions.rb +7 -5
- data/lib/graphql/subscriptions/instrumentation.rb +5 -1
- data/lib/graphql/subscriptions/serialize.rb +2 -0
- data/lib/graphql/subscriptions.rb +90 -16
- data/lib/graphql/tracing/data_dog_tracing.rb +49 -0
- data/lib/graphql/tracing/new_relic_tracing.rb +26 -0
- data/lib/graphql/tracing/platform_tracing.rb +20 -7
- data/lib/graphql/tracing/scout_tracing.rb +2 -2
- data/lib/graphql/tracing.rb +1 -0
- data/lib/graphql/unresolved_type_error.rb +3 -2
- data/lib/graphql/upgrader/member.rb +894 -0
- data/lib/graphql/upgrader/schema.rb +37 -0
- data/lib/graphql/version.rb +1 -1
- data/lib/graphql.rb +5 -25
- data/readme.md +2 -2
- data/spec/dummy/app/channels/graphql_channel.rb +23 -2
- data/spec/dummy/log/development.log +239 -0
- data/spec/dummy/log/test.log +410 -0
- data/spec/dummy/test/system/action_cable_subscription_test.rb +4 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/-x/-xYZjAnuuzgR79fcznLTQtSdh6AARxu8FcQ_J6p7L3U.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/13/13HiV12xyoQvT-1L39ZzLwMZxjyaGMiENmfw7f-QTIc.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/3W/3Wtf5pCWdqq0AB-iB0Y9uUNrTkruRxIEf1XFn_BETU0.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/5i/5iguGafb4hOn8262Kn8Q37ogNN9MxxQKGKNzHAzUcvI.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/8m/8mj2T6yy847Mc2Z7k3Xzh8O91hhVJt3NrPe8ASNDlIA.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/DT/DTQyMpr4ABZYQetsdRJ5A7S4jf1r3ie4FGOR7GZBNSs.cache +3 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Dq/DqJ5_yJPrP5iLlOQyTQsjAVI5FE5LCVDkED0f7GgsSo.cache +3 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/F8/F8MUNRzORGFgr329fNM0xLaoWCXdv3BIalT7dsvLfjs.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/KB/KB07ZaKNC5uXJ7TjLi-WqnY6g7dq8wWp_8N3HNjBNxg.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Rw/RwDuCV-XpnCtjNkvhpJfBuxXMk0b5AD3L9eR6M-wcy0.cache +3 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/UL/ULdjhhb0bRuqmaG7XSZlFYzGYCXTDnqZuJBTWRlzqgw.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Up/UpPNgh0yYoUsyMDh5zWqe_U6qJIyTC6-dxMMAs1vvlM.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Wg/Wguh-szFGTI1gaL6npYwPekMXflugRei7F_mOyRucXg.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/X-/X-khLYMA9mqFRPg3zAi86mREDxpKl4bdKYp3uF6WHos.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/bi/BIkdhfxsezxM4q-HZ4oCNTq97WEJTigcq0tpX2cDvbY.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/ff/FfxmA4CMHQZT7exx0G7NS1Wpcnny0vzp-Jhc2H36bp8.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/gE/gEiiG4GZNy_djEjK2pHm_NgA-gyhLZhdQvo0Yt96GqE.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/gn/gnA9ZSqpjccNL2m8pe_jBvY6SinXlCzXDWyop83Od8s.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/lO/lOAan3cMwCE_Hli6gsDML88xFNfn0nxPmvrSkW7eEOw.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/m1/M1pv8MJEPLXGLvS8QxVh3DSO9cI4mRt5FHFWdrvUj6o.cache +2 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/m7/m77qH7ZqH0_0SmwJbiKGDd-aLau1Dav847DC6ge46zY.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/sj/sjRjnjRB37lH2vrgtkdJ8Cz84__IJ978IuKTM7HcztI.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/um/um1JrirR4hJhK-1rE-HywlyCi5ibgxHVrReiujZBWJM.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/v4/v4fwVytD7ITcE0_GDbslZEYud8a5Okm85fV1o7SDl6g.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/v_/v_0PAQt0iipQjFP5zjgkkk9Stnpf4VzvnMv67d1Keuw.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/wd/wdT9U4MKxe1PyqNjVuCKMpCl3dxGCIRJIlwUTfh2DQU.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/xI/xIaxut_fEIhKBDqljTNwYaADK9kj3gG0ESrfHs-5_og.cache +3 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/y0/y0SJOqIx2fn1SKqOkAihsQow0trRJrSIyAswufVuoA8.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/zg/zgpzeaX-KZErHyGJ1aBH3ZusweNXMneVZule88XsIJI.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/zy/zYFltDy-8VC-uKq2BVEiJJyYXNFvVzAKuMlR3ZIYZsk.cache +0 -0
- data/spec/dummy/tmp/screenshots/failures_test_it_handles_subscriptions.png +0 -0
- data/spec/fixtures/upgrader/account.original.rb +19 -0
- data/spec/fixtures/upgrader/account.transformed.rb +20 -0
- data/spec/fixtures/upgrader/blame_range.original.rb +43 -0
- data/spec/fixtures/upgrader/blame_range.transformed.rb +30 -0
- data/spec/fixtures/upgrader/date_time.original.rb +24 -0
- data/spec/fixtures/upgrader/date_time.transformed.rb +23 -0
- data/spec/fixtures/upgrader/delete_project.original.rb +28 -0
- data/spec/fixtures/upgrader/delete_project.transformed.rb +27 -0
- data/spec/fixtures/upgrader/gist_order_field.original.rb +14 -0
- data/spec/fixtures/upgrader/gist_order_field.transformed.rb +13 -0
- data/spec/fixtures/upgrader/increment_count.original.rb +59 -0
- data/spec/fixtures/upgrader/increment_count.transformed.rb +50 -0
- data/spec/fixtures/upgrader/photo.original.rb +10 -0
- data/spec/fixtures/upgrader/photo.transformed.rb +12 -0
- data/spec/fixtures/upgrader/release_order.original.rb +15 -0
- data/spec/fixtures/upgrader/release_order.transformed.rb +14 -0
- data/spec/fixtures/upgrader/starrable.original.rb +49 -0
- data/spec/fixtures/upgrader/starrable.transformed.rb +46 -0
- data/spec/fixtures/upgrader/subscribable.original.rb +55 -0
- data/spec/fixtures/upgrader/subscribable.transformed.rb +51 -0
- data/spec/fixtures/upgrader/type_x.original.rb +65 -0
- data/spec/fixtures/upgrader/type_x.transformed.rb +56 -0
- data/spec/generators/graphql/function_generator_spec.rb +26 -0
- data/spec/generators/graphql/install_generator_spec.rb +1 -1
- data/spec/generators/graphql/loader_generator_spec.rb +24 -0
- 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/argument_spec.rb +21 -0
- data/spec/graphql/backtrace_spec.rb +10 -0
- data/spec/graphql/base_type_spec.rb +42 -0
- data/spec/graphql/boolean_type_spec.rb +3 -3
- data/spec/graphql/directive_spec.rb +3 -1
- data/spec/graphql/enum_type_spec.rb +18 -5
- data/spec/graphql/execution/execute_spec.rb +4 -4
- data/spec/graphql/execution/instrumentation_spec.rb +165 -0
- data/spec/graphql/execution/multiplex_spec.rb +2 -2
- data/spec/graphql/execution_error_spec.rb +18 -0
- 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 +15 -2
- data/spec/graphql/int_type_spec.rb +2 -2
- data/spec/graphql/interface_type_spec.rb +12 -0
- data/spec/graphql/internal_representation/rewrite_spec.rb +2 -2
- data/spec/graphql/introspection/schema_type_spec.rb +2 -0
- data/spec/graphql/language/block_string_spec.rb +70 -0
- data/spec/graphql/language/document_from_schema_definition_spec.rb +770 -0
- data/spec/graphql/language/generation_spec.rb +21 -186
- data/spec/graphql/language/lexer_spec.rb +21 -1
- data/spec/graphql/language/nodes_spec.rb +21 -12
- data/spec/graphql/language/parser_spec.rb +1 -1
- data/spec/graphql/language/printer_spec.rb +203 -0
- data/spec/graphql/object_type_spec.rb +22 -0
- data/spec/graphql/query/arguments_spec.rb +25 -15
- data/spec/graphql/query/context_spec.rb +18 -0
- data/spec/graphql/query/executor_spec.rb +2 -1
- data/spec/graphql/query/serial_execution/value_resolution_spec.rb +2 -8
- data/spec/graphql/query/variables_spec.rb +42 -1
- data/spec/graphql/query_spec.rb +31 -5
- data/spec/graphql/rake_task_spec.rb +3 -1
- 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/mongo_relation_connection_spec.rb +474 -0
- data/spec/graphql/relay/mutation_spec.rb +9 -7
- data/spec/graphql/relay/range_add_spec.rb +5 -1
- data/spec/graphql/relay/relation_connection_spec.rb +65 -1
- data/spec/graphql/schema/argument_spec.rb +87 -0
- data/spec/graphql/schema/build_from_definition_spec.rb +89 -5
- data/spec/graphql/schema/enum_spec.rb +74 -0
- data/spec/graphql/schema/field_spec.rb +225 -0
- data/spec/graphql/schema/finder_spec.rb +135 -0
- data/spec/graphql/schema/input_object_spec.rb +111 -0
- data/spec/graphql/schema/instrumentation_spec.rb +40 -0
- data/spec/graphql/schema/interface_spec.rb +185 -0
- data/spec/graphql/schema/introspection_system_spec.rb +39 -0
- data/spec/graphql/schema/member/accepts_definition_spec.rb +111 -0
- data/spec/graphql/schema/member/build_type_spec.rb +17 -0
- data/spec/graphql/schema/member/has_fields_spec.rb +129 -0
- data/spec/graphql/schema/member/type_system_helpers_spec.rb +63 -0
- data/spec/graphql/schema/mutation_spec.rb +148 -0
- data/spec/graphql/schema/object_spec.rb +175 -0
- data/spec/graphql/schema/printer_spec.rb +111 -15
- data/spec/graphql/schema/relay_classic_mutation_spec.rb +38 -0
- data/spec/graphql/schema/rescue_middleware_spec.rb +11 -0
- data/spec/graphql/schema/resolver_spec.rb +131 -0
- data/spec/graphql/schema/scalar_spec.rb +95 -0
- data/spec/graphql/schema/traversal_spec.rb +31 -0
- data/spec/graphql/schema/union_spec.rb +65 -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 +55 -12
- data/spec/graphql/static_validation/rules/fields_have_appropriate_selections_spec.rb +10 -2
- 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 +273 -184
- data/spec/graphql/tracing/active_support_notifications_tracing_spec.rb +1 -1
- data/spec/graphql/tracing/new_relic_tracing_spec.rb +47 -0
- data/spec/graphql/tracing/platform_tracing_spec.rb +60 -1
- data/spec/graphql/union_type_spec.rb +1 -1
- data/spec/graphql/upgrader/member_spec.rb +516 -0
- data/spec/graphql/upgrader/schema_spec.rb +82 -0
- data/spec/spec_helper.rb +8 -0
- data/spec/support/dummy/schema.rb +53 -24
- data/spec/support/jazz.rb +544 -0
- data/spec/support/lazy_helpers.rb +21 -23
- data/spec/support/new_relic.rb +24 -0
- data/spec/support/star_trek/data.rb +109 -0
- data/spec/support/star_trek/schema.rb +388 -0
- data/spec/support/star_wars/data.rb +6 -7
- data/spec/support/star_wars/schema.rb +127 -171
- metadata +233 -11
- data/lib/graphql/introspection/arguments_field.rb +0 -7
- data/lib/graphql/introspection/enum_values_field.rb +0 -18
- data/lib/graphql/introspection/fields_field.rb +0 -13
- data/lib/graphql/introspection/input_fields_field.rb +0 -12
- data/lib/graphql/introspection/interfaces_field.rb +0 -11
- data/lib/graphql/introspection/of_type_field.rb +0 -6
- data/lib/graphql/introspection/possible_types_field.rb +0 -11
@@ -68,12 +68,10 @@ module GraphQL
|
|
68
68
|
irep_node: child_irep_node,
|
69
69
|
)
|
70
70
|
|
71
|
-
field_result =
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
)
|
76
|
-
end
|
71
|
+
field_result = resolve_field(
|
72
|
+
object,
|
73
|
+
field_ctx
|
74
|
+
)
|
77
75
|
|
78
76
|
if field_result.is_a?(Skip)
|
79
77
|
next
|
@@ -105,7 +103,9 @@ module GraphQL
|
|
105
103
|
|
106
104
|
raw_value = begin
|
107
105
|
arguments = query.arguments_for(irep_node, field)
|
108
|
-
field_ctx.
|
106
|
+
field_ctx.trace("execute_field", { context: field_ctx }) do
|
107
|
+
field_ctx.schema.middleware.invoke([parent_type, object, field, arguments, field_ctx])
|
108
|
+
end
|
109
109
|
rescue GraphQL::ExecutionError => err
|
110
110
|
err
|
111
111
|
end
|
@@ -118,12 +118,14 @@ module GraphQL
|
|
118
118
|
# If the returned object is finished, continue to coerce
|
119
119
|
# and resolve child fields
|
120
120
|
if query.schema.lazy?(raw_value)
|
121
|
-
field_ctx.value =
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
121
|
+
field_ctx.value = Execution::Lazy.new {
|
122
|
+
inner_value = field_ctx.trace("execute_field_lazy", {context: field_ctx}) {
|
123
|
+
begin
|
124
|
+
field.lazy_resolve(raw_value, arguments, field_ctx)
|
125
|
+
rescue GraphQL::ExecutionError => err
|
126
|
+
err
|
127
|
+
end
|
128
|
+
}
|
127
129
|
field_ctx.value = continue_resolve_field(inner_value, field_ctx)
|
128
130
|
}
|
129
131
|
else
|
@@ -178,6 +180,12 @@ module GraphQL
|
|
178
180
|
else
|
179
181
|
nil
|
180
182
|
end
|
183
|
+
elsif value.is_a?(Array) && value.any? && value.all? {|v| v.is_a?(GraphQL::ExecutionError)}
|
184
|
+
if field_type.kind.non_null?
|
185
|
+
PROPAGATE_NULL
|
186
|
+
else
|
187
|
+
nil
|
188
|
+
end
|
181
189
|
elsif value.is_a?(Skip)
|
182
190
|
field_ctx.value = value
|
183
191
|
else
|
@@ -0,0 +1,82 @@
|
|
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
|
@@ -51,7 +51,7 @@ module GraphQL
|
|
51
51
|
|
52
52
|
# Mock the Concurrent::Map API
|
53
53
|
class ConcurrentishMap
|
54
|
-
extend
|
54
|
+
extend Forwardable
|
55
55
|
# Technically this should be under the mutex too,
|
56
56
|
# but I know it's only used when the lock is already acquired.
|
57
57
|
def_delegators :@storage, :each_pair, :size
|
@@ -60,12 +60,12 @@ module GraphQL
|
|
60
60
|
if queries.length != 1
|
61
61
|
raise ArgumentError, "Multiplexing doesn't support custom execution strategies, run one query at a time instead"
|
62
62
|
else
|
63
|
-
|
63
|
+
instrument_and_analyze(multiplex, max_complexity: max_complexity) do
|
64
64
|
[run_one_legacy(schema, queries.first)]
|
65
65
|
end
|
66
66
|
end
|
67
67
|
else
|
68
|
-
|
68
|
+
instrument_and_analyze(multiplex, max_complexity: max_complexity) do
|
69
69
|
run_as_multiplex(multiplex)
|
70
70
|
end
|
71
71
|
end
|
@@ -93,7 +93,7 @@ module GraphQL
|
|
93
93
|
end
|
94
94
|
rescue StandardError
|
95
95
|
# Assign values here so that the query's `@executed` becomes true
|
96
|
-
queries.map { |q| q.result_values ||=
|
96
|
+
queries.map { |q| q.result_values ||= {} }
|
97
97
|
raise
|
98
98
|
end
|
99
99
|
|
@@ -162,34 +162,17 @@ module GraphQL
|
|
162
162
|
# Apply multiplex & query instrumentation to `queries`.
|
163
163
|
#
|
164
164
|
# It yields when the queries should be executed, then runs teardown.
|
165
|
-
def
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
multiplex_instrumenters.each { |i| i.before_multiplex(multiplex) }
|
173
|
-
queries.each do |query|
|
174
|
-
query_instrumenters.each { |i| i.before_query(query) }
|
175
|
-
end
|
176
|
-
|
177
|
-
multiplex_analyzers = schema.multiplex_analyzers
|
178
|
-
if max_complexity
|
179
|
-
multiplex_analyzers += [GraphQL::Analysis::MaxQueryComplexity.new(max_complexity)]
|
180
|
-
end
|
181
|
-
|
182
|
-
GraphQL::Analysis.analyze_multiplex(multiplex, multiplex_analyzers)
|
165
|
+
def instrument_and_analyze(multiplex, max_complexity:)
|
166
|
+
GraphQL::Execution::Instrumentation.apply_instrumenters(multiplex) do
|
167
|
+
schema = multiplex.schema
|
168
|
+
multiplex_analyzers = schema.multiplex_analyzers
|
169
|
+
if max_complexity
|
170
|
+
multiplex_analyzers += [GraphQL::Analysis::MaxQueryComplexity.new(max_complexity)]
|
171
|
+
end
|
183
172
|
|
184
|
-
|
185
|
-
|
186
|
-
ensure
|
187
|
-
# Finally, run teardown instrumentation for each query + the multiplex
|
188
|
-
# Use `reverse_each` so instrumenters are treated like a stack
|
189
|
-
queries.each do |query|
|
190
|
-
query_instrumenters.reverse_each { |i| i.after_query(query) }
|
173
|
+
GraphQL::Analysis.analyze_multiplex(multiplex, multiplex_analyzers)
|
174
|
+
yield
|
191
175
|
end
|
192
|
-
multiplex_instrumenters.reverse_each { |i| i.after_multiplex(multiplex) }
|
193
176
|
end
|
194
177
|
end
|
195
178
|
end
|
data/lib/graphql/execution.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
require "graphql/execution/directive_checks"
|
3
3
|
require "graphql/execution/execute"
|
4
4
|
require "graphql/execution/flatten"
|
5
|
+
require "graphql/execution/instrumentation"
|
5
6
|
require "graphql/execution/lazy"
|
6
7
|
require "graphql/execution/multiplex"
|
7
8
|
require "graphql/execution/typecast"
|
data/lib/graphql/field.rb
CHANGED
@@ -102,7 +102,7 @@ module GraphQL
|
|
102
102
|
# @example Calculating the complexity of a list field
|
103
103
|
# field :items, types[ItemType] do
|
104
104
|
# argument :limit, !types.Int
|
105
|
-
# #
|
105
|
+
# # Multiply the child complexity by the possible items on the list
|
106
106
|
# complexity ->(ctx, args, child_complexity) { child_complexity * args[:limit] }
|
107
107
|
# end
|
108
108
|
#
|
@@ -130,6 +130,8 @@ module GraphQL
|
|
130
130
|
:relay_node_field,
|
131
131
|
:relay_nodes_field,
|
132
132
|
:subscription_scope,
|
133
|
+
:trace,
|
134
|
+
:introspection,
|
133
135
|
argument: GraphQL::Define::AssignArgument
|
134
136
|
|
135
137
|
ensure_defined(
|
@@ -137,7 +139,8 @@ module GraphQL
|
|
137
139
|
:mutation, :arguments, :complexity, :function,
|
138
140
|
:resolve, :resolve=, :lazy_resolve, :lazy_resolve=, :lazy_resolve_proc, :resolve_proc,
|
139
141
|
:type, :type=, :name=, :property=, :hash_key=,
|
140
|
-
:relay_node_field, :relay_nodes_field, :edges?, :edge_class, :subscription_scope
|
142
|
+
:relay_node_field, :relay_nodes_field, :edges?, :edge_class, :subscription_scope,
|
143
|
+
:introspection?
|
141
144
|
)
|
142
145
|
|
143
146
|
# @return [Boolean] True if this is the Relay find-by-id field
|
@@ -182,10 +185,16 @@ module GraphQL
|
|
182
185
|
attr_accessor :arguments_class
|
183
186
|
|
184
187
|
attr_writer :connection
|
188
|
+
attr_writer :introspection
|
185
189
|
|
186
190
|
# @return [nil, String] Prefix for subscription names from this field
|
187
191
|
attr_accessor :subscription_scope
|
188
192
|
|
193
|
+
# @return [Boolean] True if this field should be traced. By default, fields are only traced if they are not a ScalarType or EnumType.
|
194
|
+
attr_accessor :trace
|
195
|
+
|
196
|
+
attr_accessor :ast_node
|
197
|
+
|
189
198
|
# @return [Boolean]
|
190
199
|
def connection?
|
191
200
|
@connection
|
@@ -212,13 +221,21 @@ module GraphQL
|
|
212
221
|
@connection = false
|
213
222
|
@connection_max_page_size = nil
|
214
223
|
@edge_class = nil
|
224
|
+
@trace = nil
|
225
|
+
@introspection = false
|
215
226
|
end
|
216
227
|
|
217
228
|
def initialize_copy(other)
|
229
|
+
ensure_defined
|
218
230
|
super
|
219
231
|
@arguments = other.arguments.dup
|
220
232
|
end
|
221
233
|
|
234
|
+
# @return [Boolean] Is this field a predefined introspection field?
|
235
|
+
def introspection?
|
236
|
+
@introspection
|
237
|
+
end
|
238
|
+
|
222
239
|
# Get a value for this field
|
223
240
|
# @example resolving a field value
|
224
241
|
# field.resolve(obj, args, ctx)
|
@@ -274,8 +291,8 @@ module GraphQL
|
|
274
291
|
"<Field name:#{name || "not-named"} desc:#{description} resolve:#{resolve_proc}>"
|
275
292
|
end
|
276
293
|
|
277
|
-
# If {#resolve} returned
|
278
|
-
# this method will be called later force the object to return its value.
|
294
|
+
# If {#resolve} returned an object which should be handled lazily,
|
295
|
+
# this method will be called later to force the object to return its value.
|
279
296
|
# @param obj [Object] The {#resolve}-provided object, registered with {Schema#lazy_resolve}
|
280
297
|
# @param args [GraphQL::Query::Arguments] Arguments to this field
|
281
298
|
# @param ctx [GraphQL::Query::Context] Context for this field
|
data/lib/graphql/function.rb
CHANGED
@@ -28,6 +28,8 @@ module GraphQL
|
|
28
28
|
# field :post, function: FindRecord.new(model: Post, type: PostType)
|
29
29
|
# field :comment, function: FindRecord.new(model: Comment, type: CommentType)
|
30
30
|
# end
|
31
|
+
#
|
32
|
+
# @see {GraphQL::Schema::Resolver} for a replacement for `GraphQL::Function`
|
31
33
|
class Function
|
32
34
|
# @return [Hash<String => GraphQL::Argument>] Arguments, keyed by name
|
33
35
|
def arguments
|
@@ -97,6 +99,18 @@ module GraphQL
|
|
97
99
|
end
|
98
100
|
end
|
99
101
|
|
102
|
+
def build_field(function)
|
103
|
+
GraphQL::Field.define(
|
104
|
+
arguments: function.arguments,
|
105
|
+
complexity: function.complexity,
|
106
|
+
type: function.type,
|
107
|
+
resolve: function,
|
108
|
+
description: function.description,
|
109
|
+
function: function,
|
110
|
+
deprecation_reason: function.deprecation_reason,
|
111
|
+
)
|
112
|
+
end
|
113
|
+
|
100
114
|
# Class-level reader/writer which is inherited
|
101
115
|
# @api private
|
102
116
|
def self.inherited_value(name)
|
@@ -84,6 +84,7 @@ module GraphQL
|
|
84
84
|
|
85
85
|
def coerce_non_null_input(value, ctx)
|
86
86
|
input_values = {}
|
87
|
+
defaults_used = Set.new
|
87
88
|
|
88
89
|
arguments.each do |input_key, input_field_defn|
|
89
90
|
field_value = value[input_key]
|
@@ -93,10 +94,11 @@ module GraphQL
|
|
93
94
|
input_values[input_key] = input_field_defn.prepare(coerced_value, ctx)
|
94
95
|
elsif input_field_defn.default_value?
|
95
96
|
input_values[input_key] = input_field_defn.default_value
|
97
|
+
defaults_used << input_key
|
96
98
|
end
|
97
99
|
end
|
98
100
|
|
99
|
-
arguments_class.new(input_values)
|
101
|
+
arguments_class.new(input_values, context: ctx, defaults_used: defaults_used)
|
100
102
|
end
|
101
103
|
|
102
104
|
# @api private
|
@@ -23,20 +23,22 @@ module GraphQL
|
|
23
23
|
# end
|
24
24
|
#
|
25
25
|
class InterfaceType < GraphQL::BaseType
|
26
|
-
accepts_definitions :fields, :resolve_type, field: GraphQL::Define::AssignObjectField
|
26
|
+
accepts_definitions :fields, :orphan_types, :resolve_type, field: GraphQL::Define::AssignObjectField
|
27
27
|
|
28
|
-
attr_accessor :fields, :resolve_type_proc
|
29
|
-
ensure_defined :fields, :resolve_type_proc, :resolve_type
|
28
|
+
attr_accessor :fields, :orphan_types, :resolve_type_proc
|
29
|
+
ensure_defined :fields, :orphan_types, :resolve_type_proc, :resolve_type
|
30
30
|
|
31
31
|
def initialize
|
32
32
|
super
|
33
33
|
@fields = {}
|
34
|
+
@orphan_types = []
|
34
35
|
@resolve_type_proc = nil
|
35
36
|
end
|
36
37
|
|
37
38
|
def initialize_copy(other)
|
38
39
|
super
|
39
40
|
@fields = other.fields.dup
|
41
|
+
@orphan_types = other.orphan_types.dup
|
40
42
|
end
|
41
43
|
|
42
44
|
def kind
|
@@ -4,6 +4,12 @@ module GraphQL
|
|
4
4
|
class Node
|
5
5
|
# @api private
|
6
6
|
DEFAULT_TYPED_CHILDREN = Proc.new { |h, k| h[k] = {} }
|
7
|
+
|
8
|
+
# A specialized, reusable object for leaf nodes.
|
9
|
+
NO_TYPED_CHILDREN = Hash.new({}.freeze)
|
10
|
+
def NO_TYPED_CHILDREN.dup; self; end;
|
11
|
+
NO_TYPED_CHILDREN.freeze
|
12
|
+
|
7
13
|
# @return [String] the name this node has in the response
|
8
14
|
attr_reader :name
|
9
15
|
|
@@ -16,9 +22,9 @@ module GraphQL
|
|
16
22
|
# This value is derived from {#scoped_children} after the rewrite is finished.
|
17
23
|
# @return [Hash<GraphQL::ObjectType, Hash<String => Node>>]
|
18
24
|
def typed_children
|
19
|
-
@
|
20
|
-
new_tc = Hash.new(&DEFAULT_TYPED_CHILDREN)
|
25
|
+
@typed_children ||= begin
|
21
26
|
if @scoped_children.any?
|
27
|
+
new_tc = Hash.new(&DEFAULT_TYPED_CHILDREN)
|
22
28
|
all_object_types = Set.new
|
23
29
|
scoped_children.each_key { |t| all_object_types.merge(@query.possible_types(t)) }
|
24
30
|
# Remove any scoped children which don't follow this return type
|
@@ -27,8 +33,11 @@ module GraphQL
|
|
27
33
|
all_object_types.each do |t|
|
28
34
|
new_tc[t] = get_typed_children(t)
|
29
35
|
end
|
36
|
+
new_tc
|
37
|
+
else
|
38
|
+
NO_TYPED_CHILDREN
|
30
39
|
end
|
31
|
-
|
40
|
+
|
32
41
|
end
|
33
42
|
end
|
34
43
|
|
@@ -125,17 +134,20 @@ module GraphQL
|
|
125
134
|
@ast_nodes |= new_parent.ast_nodes
|
126
135
|
@definitions |= new_parent.definitions
|
127
136
|
end
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
prev_node
|
137
|
-
|
138
|
-
|
137
|
+
new_sc = new_parent.scoped_children
|
138
|
+
if new_sc.any?
|
139
|
+
scope ||= Scope.new(@query, @return_type.unwrap)
|
140
|
+
new_sc.each do |obj_type, new_fields|
|
141
|
+
inner_scope = scope.enter(obj_type)
|
142
|
+
inner_scope.each do |scoped_type|
|
143
|
+
prev_fields = @scoped_children[scoped_type]
|
144
|
+
new_fields.each do |name, new_node|
|
145
|
+
prev_node = prev_fields[name]
|
146
|
+
if prev_node
|
147
|
+
prev_node.deep_merge_node(new_node)
|
148
|
+
else
|
149
|
+
prev_fields[name] = new_node
|
150
|
+
end
|
139
151
|
end
|
140
152
|
end
|
141
153
|
end
|
@@ -24,12 +24,9 @@ module GraphQL
|
|
24
24
|
# visiting the node itself and each of its typed children.
|
25
25
|
def each_node(node)
|
26
26
|
yield(node)
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
children.each do |name, node|
|
31
|
-
each_node(node, &visit_block)
|
32
|
-
end
|
27
|
+
node.typed_children.each do |obj_type, children|
|
28
|
+
children.each do |name, node|
|
29
|
+
each_node(node) { |n| yield(n) }
|
33
30
|
end
|
34
31
|
end
|
35
32
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module GraphQL
|
3
|
+
module Introspection
|
4
|
+
class BaseObject < GraphQL::Schema::Object
|
5
|
+
def self.field(*args, **kwargs, &block)
|
6
|
+
kwargs[:introspection] = true
|
7
|
+
super(*args, **kwargs, &block)
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.inherited(child_class)
|
11
|
+
child_class.introspection(true)
|
12
|
+
super
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -1,11 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
module GraphQL
|
3
|
+
module Introspection
|
4
|
+
class DirectiveLocationEnum < GraphQL::Schema::Enum
|
5
|
+
graphql_name "__DirectiveLocation"
|
6
|
+
description "A Directive can be adjacent to many parts of the GraphQL language, "\
|
7
|
+
"a __DirectiveLocation describes one such possible adjacencies."
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
+
GraphQL::Directive::LOCATIONS.each do |location|
|
10
|
+
value(location.to_s, GraphQL::Directive::LOCATION_DESCRIPTIONS[location], value: location)
|
11
|
+
end
|
12
|
+
introspection true
|
13
|
+
end
|
9
14
|
end
|
10
|
-
introspection true
|
11
15
|
end
|
@@ -1,18 +1,25 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
2
|
+
module GraphQL
|
3
|
+
module Introspection
|
4
|
+
class DirectiveType < Introspection::BaseObject
|
5
|
+
graphql_name "__Directive"
|
6
|
+
description "A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document."\
|
7
|
+
"\n\n"\
|
8
|
+
"In some cases, you need to provide options to alter GraphQL's execution behavior "\
|
9
|
+
"in ways field arguments will not suffice, such as conditionally including or "\
|
10
|
+
"skipping a field. Directives provide this by describing additional information "\
|
11
|
+
"to the executor."
|
12
|
+
field :name, String, null: false
|
13
|
+
field :description, String, null: true
|
14
|
+
field :locations, [GraphQL::Schema::LateBoundType.new("__DirectiveLocation")], null: false
|
15
|
+
field :args, [GraphQL::Schema::LateBoundType.new("__InputValue")], null: false
|
16
|
+
field :on_operation, Boolean, null: false, deprecation_reason: "Use `locations`.", method: :on_operation?
|
17
|
+
field :on_fragment, Boolean, null: false, deprecation_reason: "Use `locations`.", method: :on_fragment?
|
18
|
+
field :on_field, Boolean, null: false, deprecation_reason: "Use `locations`.", method: :on_field?
|
19
|
+
|
20
|
+
def args
|
21
|
+
@context.warden.arguments(@object)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
18
25
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module GraphQL
|
3
|
+
module Introspection
|
4
|
+
class DynamicFields < GraphQL::Schema::Object
|
5
|
+
field :__typename, String, "The name of this type", null: false, extras: [:irep_node]
|
6
|
+
def __typename(irep_node:)
|
7
|
+
irep_node.owner_type.name
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module GraphQL
|
3
|
+
module Introspection
|
4
|
+
class EntryPoints < GraphQL::Schema::Object
|
5
|
+
field :__schema, GraphQL::Schema::LateBoundType.new("__Schema"), "This GraphQL schema", null: false
|
6
|
+
field :__type, GraphQL::Schema::LateBoundType.new("__Type"), "A type in the GraphQL system", null: true do
|
7
|
+
argument :name, String, required: true
|
8
|
+
end
|
9
|
+
|
10
|
+
def __schema
|
11
|
+
# Apply wrapping manually since this field isn't wrapped by instrumentation
|
12
|
+
schema = @context.query.schema
|
13
|
+
schema_type = schema.introspection_system.schema_type
|
14
|
+
schema_type.metadata[:type_class].new(schema, @context)
|
15
|
+
end
|
16
|
+
|
17
|
+
def __type(name:)
|
18
|
+
type = @context.warden.get_type(name)
|
19
|
+
if type
|
20
|
+
# Apply wrapping manually since this field isn't wrapped by instrumentation
|
21
|
+
type_type = @context.schema.introspection_system.type_type
|
22
|
+
type_type.metadata[:type_class].new(type, @context)
|
23
|
+
else
|
24
|
+
nil
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -1,14 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
2
|
+
module GraphQL
|
3
|
+
module Introspection
|
4
|
+
class EnumValueType < Introspection::BaseObject
|
5
|
+
graphql_name "__EnumValue"
|
6
|
+
description "One possible value for a given Enum. Enum values are unique values, not a "\
|
7
|
+
"placeholder for a string or numeric value. However an Enum value is returned in "\
|
8
|
+
"a JSON response as a string."
|
9
|
+
field :name, String, null: false
|
10
|
+
field :description, String, null: true
|
11
|
+
field :is_deprecated, Boolean, null: false
|
12
|
+
field :deprecation_reason, String, null: true
|
13
|
+
|
14
|
+
def is_deprecated
|
15
|
+
!!@object.deprecation_reason
|
16
|
+
end
|
17
|
+
end
|
11
18
|
end
|
12
|
-
field :deprecationReason, types.String, property: :deprecation_reason
|
13
|
-
introspection true
|
14
19
|
end
|