graphql 1.10.2 → 2.0.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (402) hide show
  1. checksums.yaml +4 -4
  2. data/lib/generators/graphql/core.rb +21 -10
  3. data/lib/generators/graphql/enum_generator.rb +4 -10
  4. data/lib/generators/graphql/field_extractor.rb +31 -0
  5. data/lib/generators/graphql/input_generator.rb +50 -0
  6. data/lib/generators/graphql/install/mutation_root_generator.rb +34 -0
  7. data/lib/generators/graphql/{templates → install/templates}/base_mutation.erb +2 -0
  8. data/lib/generators/graphql/{templates → install/templates}/mutation_type.erb +2 -0
  9. data/lib/generators/graphql/install_generator.rb +45 -8
  10. data/lib/generators/graphql/interface_generator.rb +7 -7
  11. data/lib/generators/graphql/loader_generator.rb +1 -0
  12. data/lib/generators/graphql/mutation_create_generator.rb +22 -0
  13. data/lib/generators/graphql/mutation_delete_generator.rb +22 -0
  14. data/lib/generators/graphql/mutation_generator.rb +6 -30
  15. data/lib/generators/graphql/mutation_update_generator.rb +22 -0
  16. data/lib/generators/graphql/object_generator.rb +28 -12
  17. data/lib/generators/graphql/orm_mutations_base.rb +40 -0
  18. data/lib/generators/graphql/relay.rb +49 -0
  19. data/lib/generators/graphql/relay_generator.rb +21 -0
  20. data/lib/generators/graphql/scalar_generator.rb +4 -2
  21. data/lib/generators/graphql/templates/base_argument.erb +2 -0
  22. data/lib/generators/graphql/templates/base_connection.erb +8 -0
  23. data/lib/generators/graphql/templates/base_edge.erb +8 -0
  24. data/lib/generators/graphql/templates/base_enum.erb +2 -0
  25. data/lib/generators/graphql/templates/base_field.erb +2 -0
  26. data/lib/generators/graphql/templates/base_input_object.erb +2 -0
  27. data/lib/generators/graphql/templates/base_interface.erb +2 -0
  28. data/lib/generators/graphql/templates/base_object.erb +2 -0
  29. data/lib/generators/graphql/templates/base_scalar.erb +2 -0
  30. data/lib/generators/graphql/templates/base_union.erb +2 -0
  31. data/lib/generators/graphql/templates/enum.erb +7 -1
  32. data/lib/generators/graphql/templates/graphql_controller.erb +16 -12
  33. data/lib/generators/graphql/templates/input.erb +9 -0
  34. data/lib/generators/graphql/templates/interface.erb +6 -2
  35. data/lib/generators/graphql/templates/loader.erb +2 -0
  36. data/lib/generators/graphql/templates/mutation.erb +3 -1
  37. data/lib/generators/graphql/templates/mutation_create.erb +20 -0
  38. data/lib/generators/graphql/templates/mutation_delete.erb +20 -0
  39. data/lib/generators/graphql/templates/mutation_update.erb +21 -0
  40. data/lib/generators/graphql/templates/node_type.erb +9 -0
  41. data/lib/generators/graphql/templates/object.erb +7 -3
  42. data/lib/generators/graphql/templates/query_type.erb +3 -3
  43. data/lib/generators/graphql/templates/scalar.erb +5 -1
  44. data/lib/generators/graphql/templates/schema.erb +24 -33
  45. data/lib/generators/graphql/templates/union.erb +6 -2
  46. data/lib/generators/graphql/type_generator.rb +47 -10
  47. data/lib/generators/graphql/union_generator.rb +5 -5
  48. data/lib/graphql/analysis/ast/field_usage.rb +30 -1
  49. data/lib/graphql/analysis/ast/max_query_complexity.rb +0 -1
  50. data/lib/graphql/analysis/ast/query_complexity.rb +125 -117
  51. data/lib/graphql/analysis/ast/query_depth.rb +0 -1
  52. data/lib/graphql/analysis/ast/visitor.rb +52 -36
  53. data/lib/graphql/analysis/ast.rb +7 -8
  54. data/lib/graphql/analysis.rb +0 -7
  55. data/lib/graphql/backtrace/inspect_result.rb +0 -1
  56. data/lib/graphql/backtrace/table.rb +31 -18
  57. data/lib/graphql/backtrace/trace.rb +96 -0
  58. data/lib/graphql/backtrace/traced_error.rb +0 -1
  59. data/lib/graphql/backtrace/tracer.rb +39 -9
  60. data/lib/graphql/backtrace.rb +26 -18
  61. data/lib/graphql/dataloader/null_dataloader.rb +24 -0
  62. data/lib/graphql/dataloader/request.rb +19 -0
  63. data/lib/graphql/dataloader/request_all.rb +19 -0
  64. data/lib/graphql/dataloader/source.rb +164 -0
  65. data/lib/graphql/dataloader.rb +311 -0
  66. data/lib/graphql/date_encoding_error.rb +16 -0
  67. data/lib/graphql/deprecation.rb +9 -0
  68. data/lib/graphql/dig.rb +1 -1
  69. data/lib/graphql/execution/errors.rb +77 -44
  70. data/lib/graphql/execution/interpreter/argument_value.rb +28 -0
  71. data/lib/graphql/execution/interpreter/arguments.rb +88 -0
  72. data/lib/graphql/execution/interpreter/arguments_cache.rb +104 -0
  73. data/lib/graphql/execution/interpreter/handles_raw_value.rb +18 -0
  74. data/lib/graphql/execution/interpreter/resolve.rb +62 -24
  75. data/lib/graphql/execution/interpreter/runtime.rb +826 -464
  76. data/lib/graphql/execution/interpreter.rb +206 -68
  77. data/lib/graphql/execution/lazy.rb +11 -21
  78. data/lib/graphql/execution/lookahead.rb +55 -136
  79. data/lib/graphql/execution/multiplex.rb +6 -162
  80. data/lib/graphql/execution.rb +11 -4
  81. data/lib/graphql/filter.rb +7 -2
  82. data/lib/graphql/integer_decoding_error.rb +17 -0
  83. data/lib/graphql/integer_encoding_error.rb +18 -2
  84. data/lib/graphql/introspection/directive_location_enum.rb +2 -2
  85. data/lib/graphql/introspection/directive_type.rb +11 -5
  86. data/lib/graphql/introspection/dynamic_fields.rb +3 -8
  87. data/lib/graphql/introspection/entry_points.rb +4 -17
  88. data/lib/graphql/introspection/enum_value_type.rb +2 -2
  89. data/lib/graphql/introspection/field_type.rb +9 -5
  90. data/lib/graphql/introspection/input_value_type.rb +15 -3
  91. data/lib/graphql/introspection/introspection_query.rb +6 -92
  92. data/lib/graphql/introspection/schema_type.rb +11 -6
  93. data/lib/graphql/introspection/type_type.rb +31 -14
  94. data/lib/graphql/introspection.rb +100 -0
  95. data/lib/graphql/invalid_null_error.rb +18 -0
  96. data/lib/graphql/language/block_string.rb +20 -5
  97. data/lib/graphql/language/cache.rb +37 -0
  98. data/lib/graphql/language/document_from_schema_definition.rb +96 -44
  99. data/lib/graphql/language/lexer.rb +216 -1462
  100. data/lib/graphql/language/nodes.rb +126 -129
  101. data/lib/graphql/language/parser.rb +997 -933
  102. data/lib/graphql/language/parser.y +148 -118
  103. data/lib/graphql/language/printer.rb +48 -23
  104. data/lib/graphql/language/sanitized_printer.rb +222 -0
  105. data/lib/graphql/language/token.rb +0 -4
  106. data/lib/graphql/language/visitor.rb +192 -84
  107. data/lib/graphql/language.rb +2 -0
  108. data/lib/graphql/name_validator.rb +2 -7
  109. data/lib/graphql/pagination/active_record_relation_connection.rb +45 -3
  110. data/lib/graphql/pagination/array_connection.rb +6 -4
  111. data/lib/graphql/pagination/connection.rb +105 -23
  112. data/lib/graphql/pagination/connections.rb +62 -35
  113. data/lib/graphql/pagination/relation_connection.rb +88 -36
  114. data/lib/graphql/parse_error.rb +0 -1
  115. data/lib/graphql/query/context.rb +203 -198
  116. data/lib/graphql/query/fingerprint.rb +26 -0
  117. data/lib/graphql/query/input_validation_result.rb +33 -7
  118. data/lib/graphql/query/null_context.rb +22 -9
  119. data/lib/graphql/query/validation_pipeline.rb +16 -38
  120. data/lib/graphql/query/variable_validation_error.rb +3 -3
  121. data/lib/graphql/query/variables.rb +36 -12
  122. data/lib/graphql/query.rb +92 -44
  123. data/lib/graphql/railtie.rb +6 -102
  124. data/lib/graphql/rake_task/validate.rb +1 -1
  125. data/lib/graphql/rake_task.rb +41 -10
  126. data/lib/graphql/relay/range_add.rb +17 -10
  127. data/lib/graphql/relay.rb +0 -15
  128. data/lib/graphql/rubocop/graphql/base_cop.rb +36 -0
  129. data/lib/graphql/rubocop/graphql/default_null_true.rb +43 -0
  130. data/lib/graphql/rubocop/graphql/default_required_true.rb +43 -0
  131. data/lib/graphql/rubocop.rb +4 -0
  132. data/lib/graphql/schema/addition.rb +245 -0
  133. data/lib/graphql/schema/argument.rb +250 -46
  134. data/lib/graphql/schema/base_64_encoder.rb +2 -0
  135. data/lib/graphql/schema/build_from_definition/resolve_map.rb +3 -1
  136. data/lib/graphql/schema/build_from_definition.rb +243 -89
  137. data/lib/graphql/schema/directive/deprecated.rb +1 -1
  138. data/lib/graphql/schema/directive/feature.rb +1 -1
  139. data/lib/graphql/schema/directive/flagged.rb +57 -0
  140. data/lib/graphql/schema/directive/include.rb +1 -1
  141. data/lib/graphql/schema/directive/one_of.rb +12 -0
  142. data/lib/graphql/schema/directive/skip.rb +1 -1
  143. data/lib/graphql/schema/directive/transform.rb +14 -2
  144. data/lib/graphql/schema/directive.rb +108 -20
  145. data/lib/graphql/schema/enum.rb +105 -44
  146. data/lib/graphql/schema/enum_value.rb +15 -25
  147. data/lib/graphql/schema/field/connection_extension.rb +50 -30
  148. data/lib/graphql/schema/field/scope_extension.rb +1 -1
  149. data/lib/graphql/schema/field.rb +476 -331
  150. data/lib/graphql/schema/field_extension.rb +86 -2
  151. data/lib/graphql/schema/find_inherited_value.rb +6 -8
  152. data/lib/graphql/schema/finder.rb +5 -5
  153. data/lib/graphql/schema/input_object.rb +133 -121
  154. data/lib/graphql/schema/interface.rb +17 -45
  155. data/lib/graphql/schema/introspection_system.rb +3 -8
  156. data/lib/graphql/schema/late_bound_type.rb +8 -2
  157. data/lib/graphql/schema/list.rb +25 -8
  158. data/lib/graphql/schema/loader.rb +139 -103
  159. data/lib/graphql/schema/member/base_dsl_methods.rb +29 -35
  160. data/lib/graphql/schema/member/build_type.rb +19 -14
  161. data/lib/graphql/schema/member/has_arguments.rb +310 -26
  162. data/lib/graphql/schema/member/has_ast_node.rb +16 -1
  163. data/lib/graphql/schema/member/has_deprecation_reason.rb +24 -0
  164. data/lib/graphql/schema/member/has_directives.rb +118 -0
  165. data/lib/graphql/schema/member/has_fields.rb +164 -42
  166. data/lib/graphql/schema/member/has_interfaces.rb +129 -0
  167. data/lib/graphql/schema/member/has_unresolved_type_error.rb +15 -0
  168. data/lib/graphql/schema/member/has_validators.rb +57 -0
  169. data/lib/graphql/schema/member/relay_shortcuts.rb +47 -2
  170. data/lib/graphql/schema/member/type_system_helpers.rb +20 -3
  171. data/lib/graphql/schema/member/validates_input.rb +3 -3
  172. data/lib/graphql/schema/member.rb +6 -6
  173. data/lib/graphql/schema/mutation.rb +4 -9
  174. data/lib/graphql/schema/non_null.rb +12 -7
  175. data/lib/graphql/schema/object.rb +35 -69
  176. data/lib/graphql/schema/printer.rb +16 -34
  177. data/lib/graphql/schema/relay_classic_mutation.rb +90 -43
  178. data/lib/graphql/schema/resolver/has_payload_type.rb +51 -11
  179. data/lib/graphql/schema/resolver.rb +144 -79
  180. data/lib/graphql/schema/scalar.rb +27 -18
  181. data/lib/graphql/schema/subscription.rb +55 -26
  182. data/lib/graphql/schema/timeout.rb +45 -35
  183. data/lib/graphql/schema/type_expression.rb +1 -1
  184. data/lib/graphql/schema/type_membership.rb +21 -4
  185. data/lib/graphql/schema/union.rb +48 -13
  186. data/lib/graphql/schema/unique_within_type.rb +1 -2
  187. data/lib/graphql/schema/validator/allow_blank_validator.rb +29 -0
  188. data/lib/graphql/schema/validator/allow_null_validator.rb +26 -0
  189. data/lib/graphql/schema/validator/exclusion_validator.rb +33 -0
  190. data/lib/graphql/schema/validator/format_validator.rb +48 -0
  191. data/lib/graphql/schema/validator/inclusion_validator.rb +35 -0
  192. data/lib/graphql/schema/validator/length_validator.rb +59 -0
  193. data/lib/graphql/schema/validator/numericality_validator.rb +82 -0
  194. data/lib/graphql/schema/validator/required_validator.rb +82 -0
  195. data/lib/graphql/schema/validator.rb +171 -0
  196. data/lib/graphql/schema/warden.rb +185 -32
  197. data/lib/graphql/schema/wrapper.rb +0 -5
  198. data/lib/graphql/schema.rb +471 -1116
  199. data/lib/graphql/static_validation/all_rules.rb +3 -0
  200. data/lib/graphql/static_validation/base_visitor.rb +13 -27
  201. data/lib/graphql/static_validation/definition_dependencies.rb +7 -2
  202. data/lib/graphql/static_validation/error.rb +3 -1
  203. data/lib/graphql/static_validation/literal_validator.rb +69 -26
  204. data/lib/graphql/static_validation/rules/argument_literals_are_compatible.rb +44 -87
  205. data/lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb +22 -6
  206. data/lib/graphql/static_validation/rules/arguments_are_defined.rb +28 -22
  207. data/lib/graphql/static_validation/rules/arguments_are_defined_error.rb +4 -2
  208. data/lib/graphql/static_validation/rules/directives_are_defined.rb +12 -6
  209. data/lib/graphql/static_validation/rules/directives_are_in_valid_locations.rb +13 -13
  210. data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +12 -4
  211. data/lib/graphql/static_validation/rules/fields_will_merge.rb +92 -49
  212. data/lib/graphql/static_validation/rules/fields_will_merge_error.rb +25 -4
  213. data/lib/graphql/static_validation/rules/fragments_are_finite.rb +2 -2
  214. data/lib/graphql/static_validation/rules/input_object_names_are_unique.rb +30 -0
  215. data/lib/graphql/static_validation/rules/input_object_names_are_unique_error.rb +30 -0
  216. data/lib/graphql/static_validation/rules/one_of_input_objects_are_valid.rb +66 -0
  217. data/lib/graphql/static_validation/rules/one_of_input_objects_are_valid_error.rb +29 -0
  218. data/lib/graphql/static_validation/rules/query_root_exists.rb +17 -0
  219. data/lib/graphql/static_validation/rules/query_root_exists_error.rb +26 -0
  220. data/lib/graphql/static_validation/rules/required_arguments_are_present.rb +4 -2
  221. data/lib/graphql/static_validation/rules/required_input_object_attributes_are_present.rb +6 -7
  222. data/lib/graphql/static_validation/rules/unique_directives_per_location.rb +13 -7
  223. data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed.rb +9 -10
  224. data/lib/graphql/static_validation/rules/variable_usages_are_allowed.rb +14 -8
  225. data/lib/graphql/static_validation/rules/variables_are_used_and_defined.rb +4 -2
  226. data/lib/graphql/static_validation/validation_context.rb +13 -3
  227. data/lib/graphql/static_validation/validation_timeout_error.rb +25 -0
  228. data/lib/graphql/static_validation/validator.rb +32 -20
  229. data/lib/graphql/static_validation.rb +1 -2
  230. data/lib/graphql/string_encoding_error.rb +13 -3
  231. data/lib/graphql/subscriptions/action_cable_subscriptions.rb +126 -19
  232. data/lib/graphql/subscriptions/broadcast_analyzer.rb +81 -0
  233. data/lib/graphql/subscriptions/default_subscription_resolve_extension.rb +58 -0
  234. data/lib/graphql/subscriptions/event.rb +81 -35
  235. data/lib/graphql/subscriptions/instrumentation.rb +0 -52
  236. data/lib/graphql/subscriptions/serialize.rb +53 -6
  237. data/lib/graphql/subscriptions.rb +113 -58
  238. data/lib/graphql/tracing/active_support_notifications_trace.rb +16 -0
  239. data/lib/graphql/tracing/active_support_notifications_tracing.rb +8 -21
  240. data/lib/graphql/tracing/appoptics_trace.rb +231 -0
  241. data/lib/graphql/tracing/appoptics_tracing.rb +173 -0
  242. data/lib/graphql/tracing/appsignal_trace.rb +77 -0
  243. data/lib/graphql/tracing/appsignal_tracing.rb +15 -0
  244. data/lib/graphql/tracing/data_dog_trace.rb +148 -0
  245. data/lib/graphql/tracing/data_dog_tracing.rb +26 -2
  246. data/lib/graphql/tracing/legacy_trace.rb +65 -0
  247. data/lib/graphql/tracing/new_relic_trace.rb +75 -0
  248. data/lib/graphql/tracing/new_relic_tracing.rb +1 -12
  249. data/lib/graphql/tracing/notifications_trace.rb +42 -0
  250. data/lib/graphql/tracing/notifications_tracing.rb +59 -0
  251. data/lib/graphql/tracing/platform_trace.rb +109 -0
  252. data/lib/graphql/tracing/platform_tracing.rb +64 -43
  253. data/lib/graphql/tracing/prometheus_trace.rb +89 -0
  254. data/lib/graphql/tracing/prometheus_tracing/graphql_collector.rb +5 -2
  255. data/lib/graphql/tracing/prometheus_tracing.rb +3 -3
  256. data/lib/graphql/tracing/scout_trace.rb +72 -0
  257. data/lib/graphql/tracing/scout_tracing.rb +11 -0
  258. data/lib/graphql/tracing/statsd_trace.rb +56 -0
  259. data/lib/graphql/tracing/statsd_tracing.rb +42 -0
  260. data/lib/graphql/tracing/trace.rb +75 -0
  261. data/lib/graphql/tracing.rb +23 -71
  262. data/lib/graphql/type_kinds.rb +6 -3
  263. data/lib/graphql/types/big_int.rb +5 -1
  264. data/lib/graphql/types/int.rb +10 -3
  265. data/lib/graphql/types/iso_8601_date.rb +20 -9
  266. data/lib/graphql/types/iso_8601_date_time.rb +36 -10
  267. data/lib/graphql/types/relay/base_connection.rb +18 -92
  268. data/lib/graphql/types/relay/base_edge.rb +2 -34
  269. data/lib/graphql/types/relay/connection_behaviors.rb +176 -0
  270. data/lib/graphql/types/relay/edge_behaviors.rb +75 -0
  271. data/lib/graphql/types/relay/has_node_field.rb +41 -0
  272. data/lib/graphql/types/relay/has_nodes_field.rb +41 -0
  273. data/lib/graphql/types/relay/node.rb +2 -4
  274. data/lib/graphql/types/relay/node_behaviors.rb +25 -0
  275. data/lib/graphql/types/relay/page_info.rb +2 -14
  276. data/lib/graphql/types/relay/page_info_behaviors.rb +30 -0
  277. data/lib/graphql/types/relay.rb +10 -5
  278. data/lib/graphql/types/string.rb +8 -2
  279. data/lib/graphql/unauthorized_error.rb +2 -2
  280. data/lib/graphql/version.rb +1 -1
  281. data/lib/graphql.rb +54 -65
  282. data/readme.md +3 -6
  283. metadata +116 -236
  284. data/lib/graphql/analysis/analyze_query.rb +0 -91
  285. data/lib/graphql/analysis/field_usage.rb +0 -45
  286. data/lib/graphql/analysis/max_query_complexity.rb +0 -26
  287. data/lib/graphql/analysis/max_query_depth.rb +0 -26
  288. data/lib/graphql/analysis/query_complexity.rb +0 -88
  289. data/lib/graphql/analysis/query_depth.rb +0 -43
  290. data/lib/graphql/analysis/reducer_state.rb +0 -48
  291. data/lib/graphql/argument.rb +0 -131
  292. data/lib/graphql/authorization.rb +0 -82
  293. data/lib/graphql/backwards_compatibility.rb +0 -60
  294. data/lib/graphql/base_type.rb +0 -230
  295. data/lib/graphql/boolean_type.rb +0 -2
  296. data/lib/graphql/compatibility/execution_specification/counter_schema.rb +0 -53
  297. data/lib/graphql/compatibility/execution_specification/specification_schema.rb +0 -200
  298. data/lib/graphql/compatibility/execution_specification.rb +0 -435
  299. data/lib/graphql/compatibility/lazy_execution_specification/lazy_schema.rb +0 -111
  300. data/lib/graphql/compatibility/lazy_execution_specification.rb +0 -213
  301. data/lib/graphql/compatibility/query_parser_specification/parse_error_specification.rb +0 -87
  302. data/lib/graphql/compatibility/query_parser_specification/query_assertions.rb +0 -79
  303. data/lib/graphql/compatibility/query_parser_specification.rb +0 -264
  304. data/lib/graphql/compatibility/schema_parser_specification.rb +0 -680
  305. data/lib/graphql/compatibility.rb +0 -5
  306. data/lib/graphql/define/assign_argument.rb +0 -12
  307. data/lib/graphql/define/assign_connection.rb +0 -13
  308. data/lib/graphql/define/assign_enum_value.rb +0 -18
  309. data/lib/graphql/define/assign_global_id_field.rb +0 -11
  310. data/lib/graphql/define/assign_mutation_function.rb +0 -34
  311. data/lib/graphql/define/assign_object_field.rb +0 -42
  312. data/lib/graphql/define/defined_object_proxy.rb +0 -53
  313. data/lib/graphql/define/instance_definable.rb +0 -210
  314. data/lib/graphql/define/no_definition_error.rb +0 -7
  315. data/lib/graphql/define/non_null_with_bang.rb +0 -16
  316. data/lib/graphql/define/type_definer.rb +0 -31
  317. data/lib/graphql/define.rb +0 -31
  318. data/lib/graphql/deprecated_dsl.rb +0 -42
  319. data/lib/graphql/directive/deprecated_directive.rb +0 -2
  320. data/lib/graphql/directive/include_directive.rb +0 -2
  321. data/lib/graphql/directive/skip_directive.rb +0 -2
  322. data/lib/graphql/directive.rb +0 -107
  323. data/lib/graphql/enum_type.rb +0 -127
  324. data/lib/graphql/execution/execute.rb +0 -326
  325. data/lib/graphql/execution/flatten.rb +0 -40
  326. data/lib/graphql/execution/instrumentation.rb +0 -92
  327. data/lib/graphql/execution/interpreter/hash_response.rb +0 -46
  328. data/lib/graphql/execution/lazy/resolve.rb +0 -91
  329. data/lib/graphql/execution/typecast.rb +0 -50
  330. data/lib/graphql/field/resolve.rb +0 -59
  331. data/lib/graphql/field.rb +0 -222
  332. data/lib/graphql/float_type.rb +0 -2
  333. data/lib/graphql/function.rb +0 -124
  334. data/lib/graphql/id_type.rb +0 -2
  335. data/lib/graphql/input_object_type.rb +0 -132
  336. data/lib/graphql/int_type.rb +0 -2
  337. data/lib/graphql/interface_type.rb +0 -65
  338. data/lib/graphql/internal_representation/document.rb +0 -27
  339. data/lib/graphql/internal_representation/node.rb +0 -206
  340. data/lib/graphql/internal_representation/print.rb +0 -51
  341. data/lib/graphql/internal_representation/rewrite.rb +0 -184
  342. data/lib/graphql/internal_representation/scope.rb +0 -88
  343. data/lib/graphql/internal_representation/visit.rb +0 -36
  344. data/lib/graphql/internal_representation.rb +0 -7
  345. data/lib/graphql/language/lexer.rl +0 -258
  346. data/lib/graphql/list_type.rb +0 -80
  347. data/lib/graphql/literal_validation_error.rb +0 -6
  348. data/lib/graphql/non_null_type.rb +0 -71
  349. data/lib/graphql/object_type.rb +0 -121
  350. data/lib/graphql/query/arguments.rb +0 -188
  351. data/lib/graphql/query/arguments_cache.rb +0 -25
  352. data/lib/graphql/query/executor.rb +0 -53
  353. data/lib/graphql/query/literal_input.rb +0 -136
  354. data/lib/graphql/query/serial_execution/field_resolution.rb +0 -92
  355. data/lib/graphql/query/serial_execution/operation_resolution.rb +0 -19
  356. data/lib/graphql/query/serial_execution/selection_resolution.rb +0 -23
  357. data/lib/graphql/query/serial_execution/value_resolution.rb +0 -87
  358. data/lib/graphql/query/serial_execution.rb +0 -39
  359. data/lib/graphql/relay/array_connection.rb +0 -85
  360. data/lib/graphql/relay/base_connection.rb +0 -176
  361. data/lib/graphql/relay/connection_instrumentation.rb +0 -54
  362. data/lib/graphql/relay/connection_resolve.rb +0 -43
  363. data/lib/graphql/relay/connection_type.rb +0 -41
  364. data/lib/graphql/relay/edge.rb +0 -27
  365. data/lib/graphql/relay/edge_type.rb +0 -19
  366. data/lib/graphql/relay/edges_instrumentation.rb +0 -40
  367. data/lib/graphql/relay/global_id_resolve.rb +0 -18
  368. data/lib/graphql/relay/mongo_relation_connection.rb +0 -50
  369. data/lib/graphql/relay/mutation/instrumentation.rb +0 -23
  370. data/lib/graphql/relay/mutation/resolve.rb +0 -56
  371. data/lib/graphql/relay/mutation/result.rb +0 -38
  372. data/lib/graphql/relay/mutation.rb +0 -105
  373. data/lib/graphql/relay/node.rb +0 -36
  374. data/lib/graphql/relay/page_info.rb +0 -7
  375. data/lib/graphql/relay/relation_connection.rb +0 -190
  376. data/lib/graphql/relay/type_extensions.rb +0 -30
  377. data/lib/graphql/scalar_type.rb +0 -76
  378. data/lib/graphql/schema/catchall_middleware.rb +0 -35
  379. data/lib/graphql/schema/default_parse_error.rb +0 -10
  380. data/lib/graphql/schema/default_type_error.rb +0 -15
  381. data/lib/graphql/schema/member/accepts_definition.rb +0 -152
  382. data/lib/graphql/schema/member/cached_graphql_definition.rb +0 -31
  383. data/lib/graphql/schema/member/instrumentation.rb +0 -132
  384. data/lib/graphql/schema/middleware_chain.rb +0 -82
  385. data/lib/graphql/schema/possible_types.rb +0 -39
  386. data/lib/graphql/schema/rescue_middleware.rb +0 -60
  387. data/lib/graphql/schema/timeout_middleware.rb +0 -86
  388. data/lib/graphql/schema/traversal.rb +0 -228
  389. data/lib/graphql/schema/validation.rb +0 -303
  390. data/lib/graphql/static_validation/default_visitor.rb +0 -15
  391. data/lib/graphql/static_validation/no_validate_visitor.rb +0 -10
  392. data/lib/graphql/string_type.rb +0 -2
  393. data/lib/graphql/subscriptions/subscription_root.rb +0 -65
  394. data/lib/graphql/tracing/skylight_tracing.rb +0 -70
  395. data/lib/graphql/types/relay/base_field.rb +0 -22
  396. data/lib/graphql/types/relay/base_interface.rb +0 -29
  397. data/lib/graphql/types/relay/base_object.rb +0 -26
  398. data/lib/graphql/types/relay/node_field.rb +0 -43
  399. data/lib/graphql/types/relay/nodes_field.rb +0 -45
  400. data/lib/graphql/union_type.rb +0 -113
  401. data/lib/graphql/upgrader/member.rb +0 -936
  402. data/lib/graphql/upgrader/schema.rb +0 -37
@@ -1,65 +0,0 @@
1
- # frozen_string_literal: true
2
- module GraphQL
3
- # @api deprecated
4
- class InterfaceType < GraphQL::BaseType
5
- accepts_definitions :fields, :orphan_types, :resolve_type, field: GraphQL::Define::AssignObjectField
6
-
7
- attr_accessor :fields, :orphan_types, :resolve_type_proc
8
- ensure_defined :fields, :orphan_types, :resolve_type_proc, :resolve_type
9
-
10
- def initialize
11
- super
12
- @fields = {}
13
- @orphan_types = []
14
- @resolve_type_proc = nil
15
- end
16
-
17
- def initialize_copy(other)
18
- super
19
- @fields = other.fields.dup
20
- @orphan_types = other.orphan_types.dup
21
- end
22
-
23
- def kind
24
- GraphQL::TypeKinds::INTERFACE
25
- end
26
-
27
- def resolve_type(value, ctx)
28
- ctx.query.resolve_type(self, value)
29
- end
30
-
31
- def resolve_type=(resolve_type_callable)
32
- @resolve_type_proc = resolve_type_callable
33
- end
34
-
35
- # @return [GraphQL::Field] The defined field for `field_name`
36
- def get_field(field_name)
37
- fields[field_name]
38
- end
39
-
40
- # These fields don't have instrumenation applied
41
- # @see [Schema#get_fields] Get fields with instrumentation
42
- # @return [Array<GraphQL::Field>] All fields on this type
43
- def all_fields
44
- fields.values
45
- end
46
-
47
- # Get a possible type of this {InterfaceType} by type name
48
- # @param type_name [String]
49
- # @param ctx [GraphQL::Query::Context] The context for the current query
50
- # @return [GraphQL::ObjectType, nil] The type named `type_name` if it exists and implements this {InterfaceType}, (else `nil`)
51
- def get_possible_type(type_name, ctx)
52
- type = ctx.query.get_type(type_name)
53
- type if type && ctx.query.warden.possible_types(self).include?(type)
54
- end
55
-
56
- # Check if a type is a possible type of this {InterfaceType}
57
- # @param type [String, GraphQL::BaseType] Name of the type or a type definition
58
- # @param ctx [GraphQL::Query::Context] The context for the current query
59
- # @return [Boolean] True if the `type` exists and is a member of this {InterfaceType}, (else `nil`)
60
- def possible_type?(type, ctx)
61
- type_name = type.is_a?(String) ? type : type.graphql_name
62
- !get_possible_type(type_name, ctx).nil?
63
- end
64
- end
65
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
- module GraphQL
3
- module InternalRepresentation
4
- class Document
5
- # @return [Hash<String, Node>] Operation Nodes of this query
6
- attr_reader :operation_definitions
7
-
8
- # @return [Hash<String, Node>] Fragment definition Nodes of this query
9
- attr_reader :fragment_definitions
10
-
11
- def initialize
12
- @operation_definitions = {}
13
- @fragment_definitions = {}
14
- end
15
-
16
- def [](key)
17
- warn "#{self.class}#[] is deprecated; use `operation_definitions[]` instead"
18
- operation_definitions[key]
19
- end
20
-
21
- def each(&block)
22
- warn "#{self.class}#each is deprecated; use `operation_definitions.each` instead"
23
- operation_definitions.each(&block)
24
- end
25
- end
26
- end
27
- end
@@ -1,206 +0,0 @@
1
- # frozen_string_literal: true
2
- module GraphQL
3
- module InternalRepresentation
4
- class Node
5
- # @api private
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
-
13
- # @return [String] the name this node has in the response
14
- attr_reader :name
15
-
16
- # @return [GraphQL::ObjectType]
17
- attr_reader :owner_type
18
-
19
- # Each key is a {GraphQL::ObjectType} which this selection _may_ be made on.
20
- # The values for that key are selections which apply to that type.
21
- #
22
- # This value is derived from {#scoped_children} after the rewrite is finished.
23
- # @return [Hash<GraphQL::ObjectType, Hash<String => Node>>]
24
- def typed_children
25
- @typed_children ||= begin
26
- if @scoped_children.any?
27
- new_tc = Hash.new(&DEFAULT_TYPED_CHILDREN)
28
- all_object_types = Set.new
29
- scoped_children.each_key { |t| all_object_types.merge(@query.possible_types(t)) }
30
- # Remove any scoped children which don't follow this return type
31
- # (This can happen with fragment merging where lexical scope is lost)
32
- all_object_types &= @query.possible_types(@return_type.unwrap)
33
- all_object_types.each do |t|
34
- new_tc[t] = get_typed_children(t)
35
- end
36
- new_tc
37
- else
38
- NO_TYPED_CHILDREN
39
- end
40
-
41
- end
42
- end
43
-
44
- # These children correspond closely to scopes in the AST.
45
- # Keys _may_ be abstract types. They're assumed to be read-only after rewrite is finished
46
- # because {#typed_children} is derived from them.
47
- #
48
- # Using {#scoped_children} during the rewrite step reduces the overhead of reifying
49
- # abstract types because they're only reified _after_ the rewrite.
50
- # @return [Hash<GraphQL::BaseType, Hash<String => Node>>]
51
- attr_reader :scoped_children
52
-
53
- # @return [Array<Language::Nodes::AbstractNode>] AST nodes which are represented by this node
54
- attr_reader :ast_nodes
55
-
56
- # @return [Array<GraphQL::Field>] Field definitions for this node (there should only be one!)
57
- attr_reader :definitions
58
-
59
- # @return [GraphQL::BaseType] The expected wrapped type this node must return.
60
- attr_reader :return_type
61
-
62
- # @return [InternalRepresentation::Node, nil]
63
- attr_reader :parent
64
-
65
- def initialize(
66
- name:, owner_type:, query:, return_type:, parent:,
67
- ast_nodes: [],
68
- definitions: []
69
- )
70
- @name = name
71
- @query = query
72
- @owner_type = owner_type
73
- @parent = parent
74
- @typed_children = nil
75
- @scoped_children = Hash.new { |h1, k1| h1[k1] = {} }
76
- @ast_nodes = ast_nodes
77
- @definitions = definitions
78
- @return_type = return_type
79
- end
80
-
81
- def initialize_copy(other_node)
82
- super
83
- # Bust some caches:
84
- @typed_children = nil
85
- @definition = nil
86
- @definition_name = nil
87
- @ast_node = nil
88
- # Shallow-copy some state:
89
- @scoped_children = other_node.scoped_children.dup
90
- @ast_nodes = other_node.ast_nodes.dup
91
- @definitions = other_node.definitions.dup
92
- end
93
-
94
- def ==(other)
95
- other.is_a?(self.class) &&
96
- other.name == name &&
97
- other.parent == parent &&
98
- other.return_type == return_type &&
99
- other.owner_type == owner_type &&
100
- other.scoped_children == scoped_children &&
101
- other.definitions == definitions &&
102
- other.ast_nodes == ast_nodes
103
- end
104
-
105
- def definition_name
106
- definition && definition.name
107
- end
108
-
109
- def arguments
110
- @query.arguments_for(self, definition)
111
- end
112
-
113
- def definition
114
- @definition ||= begin
115
- first_def = @definitions.first
116
- first_def && @query.get_field(@owner_type, first_def.name)
117
- end
118
- end
119
-
120
- def ast_node
121
- @ast_node ||= ast_nodes.first
122
- end
123
-
124
- def inspect
125
- all_children_names = scoped_children.values.map(&:keys).flatten.uniq.join(", ")
126
- all_locations = ast_nodes.map {|n| "#{n.line}:#{n.col}" }.join(", ")
127
- "#<Node #{@owner_type}.#{@name} -> #{@return_type} {#{all_children_names}} @ [#{all_locations}] #{object_id}>"
128
- end
129
-
130
- # Merge selections from `new_parent` into `self`.
131
- # Selections are merged in place, not copied.
132
- def deep_merge_node(new_parent, scope: nil, merge_self: true)
133
- if merge_self
134
- @ast_nodes |= new_parent.ast_nodes
135
- @definitions |= new_parent.definitions
136
- end
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
151
- end
152
- end
153
- end
154
- end
155
- end
156
-
157
- # @return [GraphQL::Query]
158
- attr_reader :query
159
-
160
- def subscription_topic
161
- @subscription_topic ||= begin
162
- scope = if definition.subscription_scope
163
- @query.context[definition.subscription_scope]
164
- else
165
- nil
166
- end
167
- Subscriptions::Event.serialize(
168
- definition_name,
169
- @query.arguments_for(self, definition),
170
- definition,
171
- scope: scope
172
- )
173
- end
174
- end
175
-
176
- protected
177
-
178
- attr_writer :owner_type, :parent
179
-
180
- private
181
-
182
- # Get applicable children from {#scoped_children}
183
- # @param obj_type [GraphQL::ObjectType]
184
- # @return [Hash<String => Node>]
185
- def get_typed_children(obj_type)
186
- new_tc = {}
187
- @scoped_children.each do |scope_type, scope_nodes|
188
- if GraphQL::Execution::Typecast.subtype?(scope_type, obj_type)
189
- scope_nodes.each do |name, new_node|
190
- prev_node = new_tc[name]
191
- if prev_node
192
- prev_node.deep_merge_node(new_node)
193
- else
194
- copied_node = new_node.dup
195
- copied_node.owner_type = obj_type
196
- copied_node.parent = self
197
- new_tc[name] = copied_node
198
- end
199
- end
200
- end
201
- end
202
- new_tc
203
- end
204
- end
205
- end
206
- end
@@ -1,51 +0,0 @@
1
- # frozen_string_literal: true
2
- module GraphQL
3
- module InternalRepresentation
4
- module Print
5
- module_function
6
-
7
- def print(schema, query_string)
8
- query = GraphQL::Query.new(schema, query_string)
9
- print_node(query.irep_selection)
10
- end
11
-
12
- def print_node(node, indent: 0)
13
- padding = " " * indent
14
- typed_children_padding = " " * (indent + 2)
15
- query_str = "".dup
16
-
17
- if !node.definition
18
- op_node = node.ast_node
19
- name = op_node.name ? " " + op_node.name : ""
20
- op_type = op_node.operation_type
21
- query_str << "#{op_type}#{name}"
22
- else
23
- if node.name == node.definition_name
24
- query_str << "#{padding}#{node.name}"
25
- else
26
- query_str << "#{padding}#{node.name}: #{node.definition_name}"
27
- end
28
-
29
- args = node.ast_nodes.map { |n| n.arguments.map(&:to_query_string).join(",") }.uniq
30
- query_str << args.map { |a| "(#{a})"}.join("|")
31
- end
32
-
33
- if node.typed_children.any?
34
- query_str << " {\n"
35
- node.typed_children.each do |type, children|
36
- query_str << "#{typed_children_padding}... on #{type.name} {\n"
37
- children.each do |name, child|
38
- query_str << print_node(child, indent: indent + 4)
39
- end
40
- query_str << "#{typed_children_padding}}\n"
41
- end
42
- query_str << "#{padding}}\n"
43
- else
44
- query_str << "\n"
45
- end
46
-
47
- query_str
48
- end
49
- end
50
- end
51
- end
@@ -1,184 +0,0 @@
1
- # frozen_string_literal: true
2
- module GraphQL
3
- module InternalRepresentation
4
- # While visiting an AST, build a normalized, flattened tree of {InternalRepresentation::Node}s.
5
- #
6
- # No unions or interfaces are present in this tree, only object types.
7
- #
8
- # Selections from the AST are attached to the object types they apply to.
9
- #
10
- # Inline fragments and fragment spreads are preserved in {InternalRepresentation::Node#ast_spreads},
11
- # where they can be used to check for the presence of directives. This might not be sufficient
12
- # for future directives, since the selections' grouping is lost.
13
- #
14
- # The rewritten query tree serves as the basis for the `FieldsWillMerge` validation.
15
- #
16
- module Rewrite
17
- include GraphQL::Language
18
-
19
- NO_DIRECTIVES = [].freeze
20
-
21
- # @return InternalRepresentation::Document
22
- attr_reader :rewrite_document
23
-
24
- def initialize(*)
25
- super
26
- @query = context.query
27
- @rewrite_document = InternalRepresentation::Document.new
28
- # Hash<Nodes::FragmentSpread => Set<InternalRepresentation::Node>>
29
- # A record of fragment spreads and the irep nodes that used them
30
- @rewrite_spread_parents = Hash.new { |h, k| h[k] = Set.new }
31
- # Hash<Nodes::FragmentSpread => Scope>
32
- @rewrite_spread_scopes = {}
33
- # Array<Set<InternalRepresentation::Node>>
34
- # The current point of the irep_tree during visitation
35
- @rewrite_nodes_stack = []
36
- # Array<Scope>
37
- @rewrite_scopes_stack = []
38
- @rewrite_skip_nodes = Set.new
39
-
40
- # Resolve fragment spreads.
41
- # Fragment definitions got their own irep trees during visitation.
42
- # Those nodes are spliced in verbatim (not copied), but this is OK
43
- # because fragments are resolved from the "bottom up", each fragment
44
- # can be shared between its usages.
45
- context.on_dependency_resolve do |defn_ast_node, spread_ast_nodes, frag_ast_node|
46
- frag_name = frag_ast_node.name
47
- fragment_node = @rewrite_document.fragment_definitions[frag_name]
48
-
49
- if fragment_node
50
- spread_ast_nodes.each do |spread_ast_node|
51
- parent_nodes = @rewrite_spread_parents[spread_ast_node]
52
- parent_scope = @rewrite_spread_scopes[spread_ast_node]
53
- parent_nodes.each do |parent_node|
54
- parent_node.deep_merge_node(fragment_node, scope: parent_scope, merge_self: false)
55
- end
56
- end
57
- end
58
- end
59
- end
60
-
61
- # @return [Hash<String, Node>] Roots of this query
62
- def operations
63
- warn "#{self.class}#operations is deprecated; use `document.operation_definitions` instead"
64
- @document.operation_definitions
65
- end
66
-
67
- def on_operation_definition(ast_node, parent)
68
- push_root_node(ast_node, @rewrite_document.operation_definitions) { super }
69
- end
70
-
71
- def on_fragment_definition(ast_node, parent)
72
- push_root_node(ast_node, @rewrite_document.fragment_definitions) { super }
73
- end
74
-
75
- def push_root_node(ast_node, definitions)
76
- # Either QueryType or the fragment type condition
77
- owner_type = context.type_definition
78
- defn_name = ast_node.name
79
-
80
- node = Node.new(
81
- parent: nil,
82
- name: defn_name,
83
- owner_type: owner_type,
84
- query: @query,
85
- ast_nodes: [ast_node],
86
- return_type: owner_type,
87
- )
88
-
89
- definitions[defn_name] = node
90
- @rewrite_scopes_stack.push(Scope.new(@query, owner_type))
91
- @rewrite_nodes_stack.push([node])
92
- yield
93
- @rewrite_nodes_stack.pop
94
- @rewrite_scopes_stack.pop
95
- end
96
-
97
- def on_inline_fragment(node, parent)
98
- # Inline fragments provide two things to the rewritten tree:
99
- # - They _may_ narrow the scope by their type condition
100
- # - They _may_ apply their directives to their children
101
- if skip?(node)
102
- @rewrite_skip_nodes.add(node)
103
- end
104
-
105
- if @rewrite_skip_nodes.empty?
106
- @rewrite_scopes_stack.push(@rewrite_scopes_stack.last.enter(context.type_definition))
107
- end
108
-
109
- super
110
-
111
- if @rewrite_skip_nodes.empty?
112
- @rewrite_scopes_stack.pop
113
- end
114
-
115
- if @rewrite_skip_nodes.include?(node)
116
- @rewrite_skip_nodes.delete(node)
117
- end
118
- end
119
-
120
- def on_field(ast_node, ast_parent)
121
- if skip?(ast_node)
122
- @rewrite_skip_nodes.add(ast_node)
123
- end
124
-
125
- if @rewrite_skip_nodes.empty?
126
- node_name = ast_node.alias || ast_node.name
127
- parent_nodes = @rewrite_nodes_stack.last
128
- next_nodes = []
129
-
130
- field_defn = context.field_definition
131
- if field_defn.nil?
132
- # It's a non-existent field
133
- new_scope = nil
134
- else
135
- field_return_type = field_defn.type
136
- @rewrite_scopes_stack.last.each do |scope_type|
137
- parent_nodes.each do |parent_node|
138
- node = parent_node.scoped_children[scope_type][node_name] ||= Node.new(
139
- parent: parent_node,
140
- name: node_name,
141
- owner_type: scope_type,
142
- query: @query,
143
- return_type: field_return_type,
144
- )
145
- node.ast_nodes << ast_node
146
- node.definitions << field_defn
147
- next_nodes << node
148
- end
149
- end
150
- new_scope = Scope.new(@query, field_return_type.unwrap)
151
- end
152
-
153
- @rewrite_nodes_stack.push(next_nodes)
154
- @rewrite_scopes_stack.push(new_scope)
155
- end
156
-
157
- super
158
-
159
- if @rewrite_skip_nodes.empty?
160
- @rewrite_nodes_stack.pop
161
- @rewrite_scopes_stack.pop
162
- end
163
-
164
- if @rewrite_skip_nodes.include?(ast_node)
165
- @rewrite_skip_nodes.delete(ast_node)
166
- end
167
- end
168
-
169
- def on_fragment_spread(ast_node, ast_parent)
170
- if @rewrite_skip_nodes.empty? && !skip?(ast_node)
171
- # Register the irep nodes that depend on this AST node:
172
- @rewrite_spread_parents[ast_node].merge(@rewrite_nodes_stack.last)
173
- @rewrite_spread_scopes[ast_node] = @rewrite_scopes_stack.last
174
- end
175
- super
176
- end
177
-
178
- def skip?(ast_node)
179
- dir = ast_node.directives
180
- dir.any? && !GraphQL::Execution::DirectiveChecks.include?(dir, @query)
181
- end
182
- end
183
- end
184
- end
@@ -1,88 +0,0 @@
1
- # frozen_string_literal: true
2
- module GraphQL
3
- module InternalRepresentation
4
- # At a point in the AST, selections may apply to one or more types.
5
- # {Scope} represents those types which selections may apply to.
6
- #
7
- # Scopes can be defined by:
8
- #
9
- # - A single concrete or abstract type
10
- # - An array of types
11
- # - `nil`
12
- #
13
- # The AST may be scoped to an array of types when two abstractly-typed
14
- # fragments occur in inside one another.
15
- class Scope
16
- NO_TYPES = [].freeze
17
-
18
- # @param query [GraphQL::Query]
19
- # @param type_defn [GraphQL::BaseType, Array<GraphQL::BaseType>, nil]
20
- def initialize(query, type_defn)
21
- @query = query
22
- @type = type_defn
23
- @abstract_type = false
24
- @types = case type_defn
25
- when Array
26
- type_defn
27
- when GraphQL::BaseType
28
- @abstract_type = true
29
- nil
30
- when nil
31
- NO_TYPES
32
- else
33
- raise "Unexpected scope type: #{type_defn}"
34
- end
35
- end
36
-
37
- # From a starting point of `self`, create a new scope by condition `other_type_defn`.
38
- # @param other_type_defn [GraphQL::BaseType, nil]
39
- # @return [Scope]
40
- def enter(other_type_defn)
41
- case other_type_defn
42
- when nil
43
- # The type wasn't found, who cares
44
- Scope.new(@query, nil)
45
- when @type
46
- # The condition is the same as current, so reuse self
47
- self
48
- when GraphQL::UnionType, GraphQL::InterfaceType
49
- # Make a new scope of the intersection between the previous & next conditions
50
- new_types = @query.possible_types(other_type_defn) & concrete_types
51
- Scope.new(@query, new_types)
52
- when GraphQL::BaseType
53
- # If this type is valid within the current scope,
54
- # return a new scope of _exactly_ this type.
55
- # Otherwise, this type is out-of-scope so the scope is null.
56
- if concrete_types.include?(other_type_defn)
57
- Scope.new(@query, other_type_defn)
58
- else
59
- Scope.new(@query, nil)
60
- end
61
- else
62
- raise "Unexpected scope: #{other_type_defn.inspect}"
63
- end
64
- end
65
-
66
- # Call the block for each type in `self`.
67
- # This uses the simplest possible expression of `self`,
68
- # so if this scope is defined by an abstract type, it gets yielded.
69
- def each
70
- if @abstract_type
71
- yield(@type)
72
- else
73
- @types.each { |t| yield(t) }
74
- end
75
- end
76
-
77
- private
78
-
79
- def concrete_types
80
- @concrete_types ||= if @abstract_type
81
- @query.possible_types(@type)
82
- else
83
- @types
84
- end
85
- end
86
- end
87
- end
88
- end
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
- module GraphQL
3
- module InternalRepresentation
4
- # Traverse a re-written query tree, calling handlers for each node
5
- module Visit
6
- module_function
7
- def visit_each_node(operations, handlers)
8
- return if handlers.empty?
9
- # Post-validation: make some assertions about the rewritten query tree
10
- operations.each do |op_name, op_node|
11
- # Yield each node to listeners which were attached by validators
12
- op_node.typed_children.each do |obj_type, children|
13
- children.each do |name, op_child_node|
14
- each_node(op_child_node) do |node|
15
- for h in handlers
16
- h.call(node)
17
- end
18
- end
19
- end
20
- end
21
- end
22
- end
23
-
24
- # Traverse a node in a rewritten query tree,
25
- # visiting the node itself and each of its typed children.
26
- def each_node(node)
27
- yield(node)
28
- node.typed_children.each do |obj_type, children|
29
- children.each do |name, node|
30
- each_node(node) { |n| yield(n) }
31
- end
32
- end
33
- end
34
- end
35
- end
36
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
- require "graphql/internal_representation/document"
3
- require "graphql/internal_representation/node"
4
- require "graphql/internal_representation/print"
5
- require "graphql/internal_representation/rewrite"
6
- require "graphql/internal_representation/scope"
7
- require "graphql/internal_representation/visit"