graphql 2.6.11 → 2.6.13

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.
Files changed (382) hide show
  1. checksums.yaml +4 -4
  2. data/.rdoc_options +4 -0
  3. data/lib/generators/graphql/core.rb +1 -0
  4. data/lib/generators/graphql/detailed_trace_generator.rb +1 -0
  5. data/lib/generators/graphql/enum_generator.rb +1 -0
  6. data/lib/generators/graphql/field_extractor.rb +1 -0
  7. data/lib/generators/graphql/input_generator.rb +1 -0
  8. data/lib/generators/graphql/install/mutation_root_generator.rb +1 -0
  9. data/lib/generators/graphql/install_generator.rb +1 -0
  10. data/lib/generators/graphql/interface_generator.rb +1 -0
  11. data/lib/generators/graphql/loader_generator.rb +8 -2
  12. data/lib/generators/graphql/mutation_create_generator.rb +8 -2
  13. data/lib/generators/graphql/mutation_delete_generator.rb +8 -2
  14. data/lib/generators/graphql/mutation_generator.rb +8 -2
  15. data/lib/generators/graphql/mutation_update_generator.rb +8 -2
  16. data/lib/generators/graphql/object_generator.rb +1 -0
  17. data/lib/generators/graphql/orm_mutations_base.rb +8 -2
  18. data/lib/generators/graphql/relay.rb +1 -0
  19. data/lib/generators/graphql/relay_generator.rb +1 -0
  20. data/lib/generators/graphql/scalar_generator.rb +1 -0
  21. data/lib/generators/graphql/type_generator.rb +38 -8
  22. data/lib/generators/graphql/union_generator.rb +1 -0
  23. data/lib/graphql/analysis/analyzer.rb +35 -9
  24. data/lib/graphql/analysis/field_usage.rb +1 -0
  25. data/lib/graphql/analysis/max_query_complexity.rb +2 -1
  26. data/lib/graphql/analysis/max_query_depth.rb +1 -0
  27. data/lib/graphql/analysis/query_complexity.rb +57 -20
  28. data/lib/graphql/analysis/query_depth.rb +17 -12
  29. data/lib/graphql/analysis/visitor.rb +79 -16
  30. data/lib/graphql/analysis.rb +23 -6
  31. data/lib/graphql/analysis_error.rb +1 -0
  32. data/lib/graphql/autoload.rb +30 -7
  33. data/lib/graphql/backtrace/table.rb +21 -5
  34. data/lib/graphql/backtrace/traced_error.rb +8 -3
  35. data/lib/graphql/backtrace.rb +14 -9
  36. data/lib/graphql/coercion_error.rb +1 -0
  37. data/lib/graphql/current.rb +44 -19
  38. data/lib/graphql/dashboard/application_controller.rb +1 -0
  39. data/lib/graphql/dashboard/detailed_traces.rb +1 -0
  40. data/lib/graphql/dashboard/installable.rb +1 -0
  41. data/lib/graphql/dashboard/landings_controller.rb +1 -0
  42. data/lib/graphql/dashboard/limiters.rb +1 -0
  43. data/lib/graphql/dashboard/operation_store.rb +1 -0
  44. data/lib/graphql/dashboard/statics_controller.rb +1 -0
  45. data/lib/graphql/dashboard/subscriptions.rb +1 -0
  46. data/lib/graphql/dashboard.rb +36 -22
  47. data/lib/graphql/dataloader/active_record_association_source.rb +1 -0
  48. data/lib/graphql/dataloader/active_record_source.rb +1 -0
  49. data/lib/graphql/dataloader/async_dataloader.rb +10 -7
  50. data/lib/graphql/dataloader/null_dataloader.rb +4 -3
  51. data/lib/graphql/dataloader/request.rb +8 -2
  52. data/lib/graphql/dataloader/request_all.rb +8 -2
  53. data/lib/graphql/dataloader/source.rb +127 -35
  54. data/lib/graphql/dataloader.rb +93 -42
  55. data/lib/graphql/date_encoding_error.rb +2 -1
  56. data/lib/graphql/dig.rb +12 -3
  57. data/lib/graphql/duration_encoding_error.rb +2 -1
  58. data/lib/graphql/execution/directive_checks.rb +8 -3
  59. data/lib/graphql/execution/errors.rb +20 -6
  60. data/lib/graphql/execution/field_resolve_step.rb +40 -13
  61. data/lib/graphql/execution/finalize.rb +12 -6
  62. data/lib/graphql/execution/input_values.rb +2 -1
  63. data/lib/graphql/execution/interpreter/argument_value.rb +17 -5
  64. data/lib/graphql/execution/interpreter/arguments.rb +24 -9
  65. data/lib/graphql/execution/interpreter/arguments_cache.rb +2 -1
  66. data/lib/graphql/execution/interpreter/execution_errors.rb +1 -0
  67. data/lib/graphql/execution/interpreter/handles_raw_value.rb +1 -0
  68. data/lib/graphql/execution/interpreter/resolve.rb +18 -8
  69. data/lib/graphql/execution/interpreter/runtime/graphql_result.rb +4 -1
  70. data/lib/graphql/execution/interpreter/runtime.rb +72 -25
  71. data/lib/graphql/execution/interpreter.rb +15 -6
  72. data/lib/graphql/execution/lazy/lazy_method_map.rb +21 -8
  73. data/lib/graphql/execution/lazy.rb +34 -10
  74. data/lib/graphql/execution/load_argument_step.rb +1 -0
  75. data/lib/graphql/execution/lookahead.rb +137 -54
  76. data/lib/graphql/execution/multiplex.rb +4 -4
  77. data/lib/graphql/execution/next.rb +7 -0
  78. data/lib/graphql/execution/prepare_object_step.rb +1 -0
  79. data/lib/graphql/execution/resolve_type_step.rb +2 -1
  80. data/lib/graphql/execution/runner.rb +9 -3
  81. data/lib/graphql/execution/selections_step.rb +3 -2
  82. data/lib/graphql/execution.rb +2 -2
  83. data/lib/graphql/execution_error.rb +19 -10
  84. data/lib/graphql/float_decoding_error.rb +1 -0
  85. data/lib/graphql/float_encoding_error.rb +7 -2
  86. data/lib/graphql/integer_decoding_error.rb +2 -1
  87. data/lib/graphql/integer_encoding_error.rb +8 -3
  88. data/lib/graphql/introspection/base_object.rb +3 -1
  89. data/lib/graphql/introspection/directive_location_enum.rb +1 -0
  90. data/lib/graphql/introspection/directive_type.rb +1 -0
  91. data/lib/graphql/introspection/dynamic_fields.rb +1 -0
  92. data/lib/graphql/introspection/entry_points.rb +1 -0
  93. data/lib/graphql/introspection/enum_value_type.rb +1 -0
  94. data/lib/graphql/introspection/field_type.rb +1 -0
  95. data/lib/graphql/introspection/input_value_type.rb +1 -0
  96. data/lib/graphql/introspection/introspection_query.rb +1 -0
  97. data/lib/graphql/introspection/schema_type.rb +1 -0
  98. data/lib/graphql/introspection/type_kind_enum.rb +1 -0
  99. data/lib/graphql/introspection/type_type.rb +1 -0
  100. data/lib/graphql/introspection.rb +1 -0
  101. data/lib/graphql/invalid_name_error.rb +1 -0
  102. data/lib/graphql/invalid_null_error.rb +19 -6
  103. data/lib/graphql/language/block_string.rb +2 -1
  104. data/lib/graphql/language/cache.rb +10 -4
  105. data/lib/graphql/language/comment.rb +1 -0
  106. data/lib/graphql/language/definition_slice.rb +1 -0
  107. data/lib/graphql/language/document_from_schema_definition.rb +9 -10
  108. data/lib/graphql/language/generation.rb +23 -9
  109. data/lib/graphql/language/lexer.rb +5 -0
  110. data/lib/graphql/language/nodes.rb +2094 -419
  111. data/lib/graphql/language/parser.rb +24 -17
  112. data/lib/graphql/language/printer.rb +31 -16
  113. data/lib/graphql/language/sanitized_printer.rb +16 -5
  114. data/lib/graphql/language/static_visitor.rb +19 -4
  115. data/lib/graphql/language/visitor.rb +51 -29
  116. data/lib/graphql/language.rb +13 -7
  117. data/lib/graphql/load_application_object_failed_error.rb +14 -5
  118. data/lib/graphql/name_validator.rb +1 -0
  119. data/lib/graphql/pagination/active_record_relation_connection.rb +1 -0
  120. data/lib/graphql/pagination/array_connection.rb +20 -6
  121. data/lib/graphql/pagination/connection.rb +178 -48
  122. data/lib/graphql/pagination/connections.rb +21 -14
  123. data/lib/graphql/pagination/mongoid_relation_connection.rb +1 -0
  124. data/lib/graphql/pagination/relation_connection.rb +123 -22
  125. data/lib/graphql/pagination/sequel_dataset_connection.rb +1 -0
  126. data/lib/graphql/pagination.rb +1 -0
  127. data/lib/graphql/parse_error.rb +1 -0
  128. data/lib/graphql/query/context/scoped_context.rb +2 -1
  129. data/lib/graphql/query/context.rb +106 -35
  130. data/lib/graphql/query/fingerprint.rb +15 -7
  131. data/lib/graphql/query/input_validation_result.rb +1 -0
  132. data/lib/graphql/query/null_context.rb +1 -0
  133. data/lib/graphql/query/partial.rb +28 -15
  134. data/lib/graphql/query/result.rb +15 -5
  135. data/lib/graphql/query/validation_pipeline.rb +16 -6
  136. data/lib/graphql/query/variable_validation_error.rb +1 -0
  137. data/lib/graphql/query/variables.rb +9 -2
  138. data/lib/graphql/query.rb +193 -49
  139. data/lib/graphql/railtie.rb +7 -3
  140. data/lib/graphql/rake_task/validate.rb +72 -17
  141. data/lib/graphql/rake_task.rb +55 -23
  142. data/lib/graphql/relay/range_add.rb +32 -21
  143. data/lib/graphql/relay.rb +1 -0
  144. data/lib/graphql/rubocop/graphql/base_cop.rb +1 -0
  145. data/lib/graphql/rubocop/graphql/default_null_true.rb +9 -6
  146. data/lib/graphql/rubocop/graphql/default_required_true.rb +9 -6
  147. data/lib/graphql/rubocop/graphql/field_type_in_block.rb +12 -8
  148. data/lib/graphql/rubocop/graphql/root_types_in_block.rb +9 -5
  149. data/lib/graphql/rubocop.rb +1 -0
  150. data/lib/graphql/runtime_error.rb +1 -0
  151. data/lib/graphql/runtime_type_error.rb +1 -0
  152. data/lib/graphql/schema/addition.rb +18 -6
  153. data/lib/graphql/schema/always_visible.rb +1 -0
  154. data/lib/graphql/schema/argument.rb +265 -42
  155. data/lib/graphql/schema/base_64_encoder.rb +2 -2
  156. data/lib/graphql/schema/build_from_definition/resolve_map/default_resolve.rb +1 -0
  157. data/lib/graphql/schema/build_from_definition/resolve_map.rb +2 -2
  158. data/lib/graphql/schema/build_from_definition.rb +94 -27
  159. data/lib/graphql/schema/built_in_types.rb +1 -0
  160. data/lib/graphql/schema/directive/deprecated.rb +1 -0
  161. data/lib/graphql/schema/directive/feature.rb +39 -22
  162. data/lib/graphql/schema/directive/flagged.rb +6 -1
  163. data/lib/graphql/schema/directive/include.rb +1 -0
  164. data/lib/graphql/schema/directive/one_of.rb +1 -0
  165. data/lib/graphql/schema/directive/skip.rb +1 -0
  166. data/lib/graphql/schema/directive/specified_by.rb +1 -0
  167. data/lib/graphql/schema/directive/transform.rb +17 -8
  168. data/lib/graphql/schema/directive.rb +12 -7
  169. data/lib/graphql/schema/enum.rb +99 -38
  170. data/lib/graphql/schema/enum_value.rb +21 -13
  171. data/lib/graphql/schema/field/connection_extension.rb +10 -2
  172. data/lib/graphql/schema/field/scope_extension.rb +1 -0
  173. data/lib/graphql/schema/field.rb +621 -109
  174. data/lib/graphql/schema/field_extension.rb +89 -34
  175. data/lib/graphql/schema/find_inherited_value.rb +5 -3
  176. data/lib/graphql/schema/finder.rb +22 -8
  177. data/lib/graphql/schema/has_single_input_argument.rb +39 -6
  178. data/lib/graphql/schema/input_object.rb +40 -13
  179. data/lib/graphql/schema/interface.rb +33 -17
  180. data/lib/graphql/schema/introspection_system.rb +7 -3
  181. data/lib/graphql/schema/late_bound_type.rb +2 -2
  182. data/lib/graphql/schema/list.rb +15 -4
  183. data/lib/graphql/schema/loader.rb +23 -12
  184. data/lib/graphql/schema/member/base_dsl_methods.rb +58 -12
  185. data/lib/graphql/schema/member/build_type.rb +16 -5
  186. data/lib/graphql/schema/member/graphql_type_names.rb +10 -6
  187. data/lib/graphql/schema/member/has_arguments.rb +115 -48
  188. data/lib/graphql/schema/member/has_ast_node.rb +1 -0
  189. data/lib/graphql/schema/member/has_authorization.rb +5 -0
  190. data/lib/graphql/schema/member/has_dataloader.rb +91 -34
  191. data/lib/graphql/schema/member/has_deprecation_reason.rb +15 -2
  192. data/lib/graphql/schema/member/has_directives.rb +38 -10
  193. data/lib/graphql/schema/member/has_fields.rb +151 -70
  194. data/lib/graphql/schema/member/has_interfaces.rb +10 -2
  195. data/lib/graphql/schema/member/has_path.rb +14 -5
  196. data/lib/graphql/schema/member/has_unresolved_type_error.rb +1 -0
  197. data/lib/graphql/schema/member/has_validators.rb +19 -4
  198. data/lib/graphql/schema/member/relay_shortcuts.rb +10 -2
  199. data/lib/graphql/schema/member/scoped.rb +14 -3
  200. data/lib/graphql/schema/member/type_system_helpers.rb +36 -6
  201. data/lib/graphql/schema/member/validates_input.rb +1 -0
  202. data/lib/graphql/schema/member.rb +9 -2
  203. data/lib/graphql/schema/mutation.rb +50 -46
  204. data/lib/graphql/schema/non_null.rb +21 -5
  205. data/lib/graphql/schema/object.rb +33 -12
  206. data/lib/graphql/schema/printer.rb +52 -31
  207. data/lib/graphql/schema/ractor_shareable.rb +6 -2
  208. data/lib/graphql/schema/relay_classic_mutation.rb +3 -3
  209. data/lib/graphql/schema/resolver/has_payload_type.rb +29 -7
  210. data/lib/graphql/schema/resolver.rb +156 -45
  211. data/lib/graphql/schema/scalar.rb +1 -0
  212. data/lib/graphql/schema/subscription.rb +67 -28
  213. data/lib/graphql/schema/timeout.rb +65 -25
  214. data/lib/graphql/schema/type_expression.rb +14 -5
  215. data/lib/graphql/schema/type_membership.rb +29 -10
  216. data/lib/graphql/schema/union.rb +4 -2
  217. data/lib/graphql/schema/unique_within_type.rb +24 -5
  218. data/lib/graphql/schema/validator/all_validator.rb +17 -9
  219. data/lib/graphql/schema/validator/allow_blank_validator.rb +8 -2
  220. data/lib/graphql/schema/validator/allow_null_validator.rb +8 -2
  221. data/lib/graphql/schema/validator/exclusion_validator.rb +14 -5
  222. data/lib/graphql/schema/validator/format_validator.rb +21 -10
  223. data/lib/graphql/schema/validator/inclusion_validator.rb +15 -6
  224. data/lib/graphql/schema/validator/length_validator.rb +23 -12
  225. data/lib/graphql/schema/validator/numericality_validator.rb +29 -16
  226. data/lib/graphql/schema/validator/required_validator.rb +45 -31
  227. data/lib/graphql/schema/validator.rb +89 -25
  228. data/lib/graphql/schema/visibility/migration.rb +14 -7
  229. data/lib/graphql/schema/visibility/profile.rb +65 -20
  230. data/lib/graphql/schema/visibility/visit.rb +12 -10
  231. data/lib/graphql/schema/visibility.rb +24 -20
  232. data/lib/graphql/schema/warden.rb +117 -31
  233. data/lib/graphql/schema/wrapper.rb +4 -1
  234. data/lib/graphql/schema.rb +1046 -300
  235. data/lib/graphql/static_validation/all_rules.rb +2 -1
  236. data/lib/graphql/static_validation/base_visitor.rb +59 -9
  237. data/lib/graphql/static_validation/definition_dependencies.rb +27 -7
  238. data/lib/graphql/static_validation/error.rb +3 -0
  239. data/lib/graphql/static_validation/interpreter_visitor.rb +1 -0
  240. data/lib/graphql/static_validation/literal_validator.rb +1 -0
  241. data/lib/graphql/static_validation/rules/argument_literals_are_compatible.rb +4 -0
  242. data/lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb +1 -0
  243. data/lib/graphql/static_validation/rules/argument_names_are_unique.rb +3 -0
  244. data/lib/graphql/static_validation/rules/argument_names_are_unique_error.rb +1 -0
  245. data/lib/graphql/static_validation/rules/arguments_are_defined.rb +3 -0
  246. data/lib/graphql/static_validation/rules/arguments_are_defined_error.rb +1 -0
  247. data/lib/graphql/static_validation/rules/directives_are_defined.rb +3 -0
  248. data/lib/graphql/static_validation/rules/directives_are_defined_error.rb +1 -0
  249. data/lib/graphql/static_validation/rules/directives_are_in_valid_locations.rb +3 -0
  250. data/lib/graphql/static_validation/rules/directives_are_in_valid_locations_error.rb +1 -0
  251. data/lib/graphql/static_validation/rules/fields_are_defined_on_type.rb +3 -0
  252. data/lib/graphql/static_validation/rules/fields_are_defined_on_type_error.rb +1 -0
  253. data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +9 -1
  254. data/lib/graphql/static_validation/rules/fields_have_appropriate_selections_error.rb +1 -0
  255. data/lib/graphql/static_validation/rules/fields_will_merge.rb +295 -134
  256. data/lib/graphql/static_validation/rules/fields_will_merge_error.rb +14 -2
  257. data/lib/graphql/static_validation/rules/fragment_names_are_unique.rb +3 -0
  258. data/lib/graphql/static_validation/rules/fragment_names_are_unique_error.rb +1 -0
  259. data/lib/graphql/static_validation/rules/fragment_spreads_are_possible.rb +3 -0
  260. data/lib/graphql/static_validation/rules/fragment_spreads_are_possible_error.rb +1 -0
  261. data/lib/graphql/static_validation/rules/fragment_types_exist.rb +3 -0
  262. data/lib/graphql/static_validation/rules/fragment_types_exist_error.rb +1 -0
  263. data/lib/graphql/static_validation/rules/fragments_are_finite.rb +3 -0
  264. data/lib/graphql/static_validation/rules/fragments_are_finite_error.rb +1 -0
  265. data/lib/graphql/static_validation/rules/fragments_are_named.rb +3 -0
  266. data/lib/graphql/static_validation/rules/fragments_are_named_error.rb +1 -0
  267. data/lib/graphql/static_validation/rules/fragments_are_on_composite_types.rb +3 -0
  268. data/lib/graphql/static_validation/rules/fragments_are_on_composite_types_error.rb +1 -0
  269. data/lib/graphql/static_validation/rules/fragments_are_used.rb +3 -0
  270. data/lib/graphql/static_validation/rules/fragments_are_used_error.rb +1 -0
  271. data/lib/graphql/static_validation/rules/input_object_names_are_unique.rb +3 -0
  272. data/lib/graphql/static_validation/rules/input_object_names_are_unique_error.rb +1 -0
  273. data/lib/graphql/static_validation/rules/mutation_root_exists.rb +3 -0
  274. data/lib/graphql/static_validation/rules/mutation_root_exists_error.rb +1 -0
  275. data/lib/graphql/static_validation/rules/no_definitions_are_present.rb +3 -0
  276. data/lib/graphql/static_validation/rules/no_definitions_are_present_error.rb +1 -0
  277. data/lib/graphql/static_validation/rules/not_single_subscription_error.rb +1 -0
  278. data/lib/graphql/static_validation/rules/one_of_input_objects_are_valid.rb +4 -0
  279. data/lib/graphql/static_validation/rules/one_of_input_objects_are_valid_error.rb +1 -0
  280. data/lib/graphql/static_validation/rules/operation_names_are_valid.rb +3 -0
  281. data/lib/graphql/static_validation/rules/operation_names_are_valid_error.rb +1 -0
  282. data/lib/graphql/static_validation/rules/query_root_exists.rb +3 -0
  283. data/lib/graphql/static_validation/rules/query_root_exists_error.rb +1 -0
  284. data/lib/graphql/static_validation/rules/required_arguments_are_present.rb +4 -1
  285. data/lib/graphql/static_validation/rules/required_arguments_are_present_error.rb +1 -0
  286. data/lib/graphql/static_validation/rules/required_input_object_attributes_are_present.rb +4 -0
  287. data/lib/graphql/static_validation/rules/required_input_object_attributes_are_present_error.rb +1 -0
  288. data/lib/graphql/static_validation/rules/subscription_root_exists_and_single_subscription_selection.rb +43 -5
  289. data/lib/graphql/static_validation/rules/subscription_root_exists_error.rb +1 -0
  290. data/lib/graphql/static_validation/rules/unique_directives_per_location.rb +3 -0
  291. data/lib/graphql/static_validation/rules/unique_directives_per_location_error.rb +1 -0
  292. data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed.rb +3 -0
  293. data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed_error.rb +1 -0
  294. data/lib/graphql/static_validation/rules/variable_names_are_unique.rb +3 -0
  295. data/lib/graphql/static_validation/rules/variable_names_are_unique_error.rb +1 -0
  296. data/lib/graphql/static_validation/rules/variable_usages_are_allowed.rb +207 -51
  297. data/lib/graphql/static_validation/rules/variable_usages_are_allowed_error.rb +1 -0
  298. data/lib/graphql/static_validation/rules/variables_are_input_types.rb +3 -0
  299. data/lib/graphql/static_validation/rules/variables_are_input_types_error.rb +1 -0
  300. data/lib/graphql/static_validation/rules/variables_are_used_and_defined.rb +6 -3
  301. data/lib/graphql/static_validation/rules/variables_are_used_and_defined_error.rb +1 -0
  302. data/lib/graphql/static_validation/validation_context.rb +3 -2
  303. data/lib/graphql/static_validation/validation_timeout_error.rb +1 -0
  304. data/lib/graphql/static_validation/validator.rb +41 -16
  305. data/lib/graphql/static_validation.rb +1 -0
  306. data/lib/graphql/string_encoding_error.rb +1 -0
  307. data/lib/graphql/subscriptions/action_cable_subscriptions.rb +85 -65
  308. data/lib/graphql/subscriptions/broadcast_analyzer.rb +10 -4
  309. data/lib/graphql/subscriptions/default_subscription_resolve_extension.rb +1 -0
  310. data/lib/graphql/subscriptions/event.rb +25 -6
  311. data/lib/graphql/subscriptions/serialize.rb +58 -19
  312. data/lib/graphql/subscriptions.rb +172 -46
  313. data/lib/graphql/testing/helpers.rb +17 -4
  314. data/lib/graphql/testing/mock_action_cable.rb +55 -33
  315. data/lib/graphql/testing.rb +1 -0
  316. data/lib/graphql/tracing/active_support_notifications_trace.rb +17 -9
  317. data/lib/graphql/tracing/active_support_notifications_tracing.rb +2 -1
  318. data/lib/graphql/tracing/appoptics_trace.rb +2 -1
  319. data/lib/graphql/tracing/appoptics_tracing.rb +2 -1
  320. data/lib/graphql/tracing/appsignal_trace.rb +16 -7
  321. data/lib/graphql/tracing/appsignal_tracing.rb +7 -3
  322. data/lib/graphql/tracing/call_legacy_tracers.rb +1 -0
  323. data/lib/graphql/tracing/data_dog_trace.rb +17 -6
  324. data/lib/graphql/tracing/data_dog_tracing.rb +10 -3
  325. data/lib/graphql/tracing/detailed_trace/active_record_backend.rb +1 -0
  326. data/lib/graphql/tracing/detailed_trace/memory_backend.rb +1 -0
  327. data/lib/graphql/tracing/detailed_trace/redis_backend.rb +1 -0
  328. data/lib/graphql/tracing/detailed_trace.rb +105 -42
  329. data/lib/graphql/tracing/legacy_hooks_trace.rb +5 -0
  330. data/lib/graphql/tracing/legacy_trace.rb +1 -0
  331. data/lib/graphql/tracing/monitor_trace.rb +17 -11
  332. data/lib/graphql/tracing/new_relic_trace.rb +17 -8
  333. data/lib/graphql/tracing/new_relic_tracing.rb +7 -3
  334. data/lib/graphql/tracing/notifications_trace.rb +11 -8
  335. data/lib/graphql/tracing/notifications_tracing.rb +23 -7
  336. data/lib/graphql/tracing/null_trace.rb +1 -0
  337. data/lib/graphql/tracing/perfetto_trace/trace_pb.rb +1 -0
  338. data/lib/graphql/tracing/perfetto_trace.rb +41 -19
  339. data/lib/graphql/tracing/platform_trace.rb +3 -1
  340. data/lib/graphql/tracing/platform_tracing.rb +16 -7
  341. data/lib/graphql/tracing/prometheus_trace/graphql_collector.rb +1 -0
  342. data/lib/graphql/tracing/prometheus_trace.rb +22 -13
  343. data/lib/graphql/tracing/prometheus_tracing.rb +1 -0
  344. data/lib/graphql/tracing/scout_trace.rb +10 -4
  345. data/lib/graphql/tracing/scout_tracing.rb +7 -3
  346. data/lib/graphql/tracing/sentry_trace.rb +12 -5
  347. data/lib/graphql/tracing/statsd_trace.rb +12 -6
  348. data/lib/graphql/tracing/statsd_tracing.rb +7 -1
  349. data/lib/graphql/tracing/trace.rb +231 -58
  350. data/lib/graphql/tracing.rb +25 -9
  351. data/lib/graphql/type_kinds.rb +2 -1
  352. data/lib/graphql/types/big_int.rb +1 -0
  353. data/lib/graphql/types/boolean.rb +1 -0
  354. data/lib/graphql/types/float.rb +1 -0
  355. data/lib/graphql/types/id.rb +1 -0
  356. data/lib/graphql/types/int.rb +2 -1
  357. data/lib/graphql/types/iso_8601_date.rb +21 -4
  358. data/lib/graphql/types/iso_8601_date_time.rb +33 -6
  359. data/lib/graphql/types/iso_8601_duration.rb +42 -9
  360. data/lib/graphql/types/json.rb +1 -0
  361. data/lib/graphql/types/relay/base_connection.rb +38 -32
  362. data/lib/graphql/types/relay/base_edge.rb +15 -9
  363. data/lib/graphql/types/relay/connection_behaviors.rb +19 -3
  364. data/lib/graphql/types/relay/edge_behaviors.rb +17 -4
  365. data/lib/graphql/types/relay/has_node_field.rb +6 -1
  366. data/lib/graphql/types/relay/has_nodes_field.rb +6 -1
  367. data/lib/graphql/types/relay/node.rb +1 -0
  368. data/lib/graphql/types/relay/node_behaviors.rb +5 -1
  369. data/lib/graphql/types/relay/page_info.rb +1 -0
  370. data/lib/graphql/types/relay/page_info_behaviors.rb +1 -0
  371. data/lib/graphql/types/relay.rb +4 -3
  372. data/lib/graphql/types/string.rb +1 -0
  373. data/lib/graphql/types.rb +1 -0
  374. data/lib/graphql/unauthorized_enum_value_error.rb +4 -1
  375. data/lib/graphql/unauthorized_error.rb +11 -4
  376. data/lib/graphql/unauthorized_field_error.rb +4 -1
  377. data/lib/graphql/unresolved_type_error.rb +16 -5
  378. data/lib/graphql/version.rb +2 -1
  379. data/lib/graphql.rb +37 -9
  380. data/readme.md +1 -1
  381. metadata +89 -5
  382. data/.yardopts +0 -5
@@ -1,15 +1,26 @@
1
1
  # frozen_string_literal: true
2
+ # typed: ignore
2
3
  require "graphql/tracing/monitor_trace"
3
4
 
4
5
  module GraphQL
5
6
  module Tracing
6
7
  # A tracer for reporting to DataDog
7
- # @example Adding this tracer to your schema
8
- # class MySchema < GraphQL::Schema
9
- # trace_with GraphQL::Tracing::DataDogTrace
10
- # end
11
- # @example Skipping `resolve_type` and `authorized` events
12
- # trace_with GraphQL::Tracing::DataDogTrace, trace_authorized: false, trace_resolve_type: false
8
+ #
9
+ # **Examples**
10
+ #
11
+ # **Example: Adding this tracer to your schema**
12
+ #
13
+ # ```ruby
14
+ # class MySchema < GraphQL::Schema
15
+ # trace_with GraphQL::Tracing::DataDogTrace
16
+ # end
17
+ # ```
18
+ #
19
+ # **Example: Skipping `resolve_type` and `authorized` events**
20
+ #
21
+ # ```ruby
22
+ # trace_with GraphQL::Tracing::DataDogTrace, trace_authorized: false, trace_resolve_type: false
23
+ # ```
13
24
  DataDogTrace = MonitorTrace.create_module("datadog")
14
25
  module DataDogTrace
15
26
  class DatadogMonitor < MonitorTrace::Monitor
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ # typed: ignore
2
3
 
3
4
  require "graphql/tracing/platform_tracing"
4
5
 
@@ -49,9 +50,15 @@ module GraphQL
49
50
  end
50
51
 
51
52
  # Implement this method in a subclass to apply custom tags to datadog spans
52
- # @param key [String] The event being traced
53
- # @param data [Hash] The runtime data for this event (@see GraphQL::Tracing for keys for each event)
54
- # @param span [Datadog::Tracing::SpanOperation] The datadog span for this event
53
+ #
54
+ # **Parameters**
55
+ #
56
+ # - `key` (`String`) — The event being traced
57
+ # - `data` (`Hash`) — The runtime data for this event; see [GraphQL::Tracing](rdoc-ref:GraphQL::Tracing) for keys for each event
58
+ # - `span` (`Datadog::Tracing::SpanOperation`) — The datadog span for this event
59
+ #
60
+ # :call-seq:
61
+ # prepare_span(String key, Hash data, Datadog::Tracing::SpanOperation span)
55
62
  def prepare_span(key, data, span)
56
63
  end
57
64
 
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ # typed: true
2
3
 
3
4
  module GraphQL
4
5
  module Tracing
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ # typed: true
2
3
 
3
4
  module GraphQL
4
5
  module Tracing
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ # typed: true
2
3
 
3
4
  module GraphQL
4
5
  module Tracing
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ # typed: true
2
3
  if defined?(ActiveRecord)
3
4
  require "graphql/tracing/detailed_trace/active_record_backend"
4
5
  end
@@ -13,7 +14,7 @@ module GraphQL
13
14
  # overriding the one in `context[:trace_mode]`.
14
15
  #
15
16
  # By default, the detailed tracer calls `.inspect` on application objects returned from fields. You can customize
16
- # this behavior by extending {DetailedTrace} and overriding {#inspect_object}. You can opt out of debug annotations
17
+ # this behavior by extending [DetailedTrace](rdoc-ref:DetailedTrace) and overriding [inspect object](rdoc-ref:#inspect_object). You can opt out of debug annotations
17
18
  # entirely with `use ..., debug: false` or for a single query with `context: { detailed_trace_debug: false }`.
18
19
  #
19
20
  # You can store saved traces in two ways:
@@ -26,46 +27,67 @@ module GraphQL
26
27
  #
27
28
  # If you need to save traces indefinitely, you can download them from Perfetto after opening them there.
28
29
  #
29
- # @example Installing with Rails
30
- # rails generate graphql:detailed_trace # optional: --redis
30
+ # See [GraphQL::Dashboard](rdoc-ref:GraphQL::Dashboard) for viewing stored results.
31
31
  #
32
- # @example Adding the sampler to your schema
33
- # class MySchema < GraphQL::Schema
34
- # # Add the sampler:
35
- # use GraphQL::Tracing::DetailedTrace, redis: Redis.new(...), limit: 100
32
+ # **Examples**
36
33
  #
37
- # # And implement this hook to tell it when to take a sample:
38
- # def self.detailed_trace?(query)
39
- # # Could use `query.context`, `query.selected_operation_name`, `query.query_string` here
40
- # # Could call out to Flipper, etc
41
- # rand <= 0.000_1 # one in ten thousand
42
- # end
34
+ # **Example: Installing with Rails**
35
+ #
36
+ # ```ruby
37
+ # rails generate graphql:detailed_trace # optional: --redis
38
+ # ```
39
+ #
40
+ # **Example: Adding the sampler to your schema**
41
+ #
42
+ # ```ruby
43
+ # class MySchema < GraphQL::Schema
44
+ # # Add the sampler:
45
+ # use GraphQL::Tracing::DetailedTrace, redis: Redis.new(...), limit: 100
46
+ #
47
+ # # And implement this hook to tell it when to take a sample:
48
+ # def self.detailed_trace?(query)
49
+ # # Could use `query.context`, `query.selected_operation_name`, `query.query_string` here
50
+ # # Could call out to Flipper, etc
51
+ # rand <= 0.000_1 # one in ten thousand
43
52
  # end
53
+ # end
54
+ # ```
55
+ #
56
+ # **Example: Customizing debug output in traces**
44
57
  #
45
- # @see Graphql::Dashboard GraphQL::Dashboard for viewing stored results
46
- #
47
- # @example Customizing debug output in traces
48
- # class CustomDetailedTrace < GraphQL::Tracing::DetailedTrace
49
- # def inspect_object(object)
50
- # if object.is_a?(SomeThing)
51
- # # handle it specially ...
52
- # else
53
- # super
54
- # end
55
- # end
58
+ # ```ruby
59
+ # class CustomDetailedTrace < GraphQL::Tracing::DetailedTrace
60
+ # def inspect_object(object)
61
+ # if object.is_a?(SomeThing)
62
+ # # handle it specially ...
63
+ # else
64
+ # super
65
+ # end
56
66
  # end
67
+ # end
68
+ # ```
69
+ #
70
+ # **Example: disabling debug annotations completely**
57
71
  #
58
- # @example disabling debug annotations completely
59
- # use DetailedTrace, debug: false, ...
72
+ # ```ruby
73
+ # use DetailedTrace, debug: false, ...
74
+ # ```
60
75
  #
61
- # @example disabling debug annotations for one query
62
- # MySchema.execute(query_str, context: { detailed_trace_debug: false })
76
+ # **Example: disabling debug annotations for one query**
63
77
  #
78
+ # ```ruby
79
+ # MySchema.execute(query_str, context: { detailed_trace_debug: false })
80
+ # ```
64
81
  class DetailedTrace
65
- # @param redis [Redis] If provided, profiles will be stored in Redis for later review
66
- # @param limit [Integer] A maximum number of profiles to store
67
- # @param debug [Boolean] if `false`, it won't create `debug` annotations in Perfetto traces (reduces overhead)
68
- # @param model_class [Class<ActiveRecord::Base>] Overrides {ActiveRecordBackend::GraphqlDetailedTrace} if present
82
+ # **Parameters**
83
+ #
84
+ # - `redis` (`Redis`) — If provided, profiles will be stored in Redis for later review
85
+ # - `limit` (`Integer`) — A maximum number of profiles to store
86
+ # - `debug` (`Boolean`) — if `false`, it won't create `debug` annotations in Perfetto traces (reduces overhead)
87
+ # - `model_class` (`Class<ActiveRecord::Base>`) — Overrides [ActiveRecordBackend::GraphqlDetailedTrace](rdoc-ref:ActiveRecordBackend::GraphqlDetailedTrace) if present
88
+ #
89
+ # :call-seq:
90
+ # use(schema, trace_mode:, memory:, bool debug:, Redis redis:, Integer limit:, Class[ActiveRecord::Base] model_class:)
69
91
  def self.use(schema, trace_mode: :profile_sample, memory: false, debug: debug?, redis: nil, limit: nil, model_class: nil)
70
92
  storage = if redis
71
93
  RedisBackend.new(redis: redis, limit: limit)
@@ -87,37 +109,72 @@ module GraphQL
87
109
  @debug = debug
88
110
  end
89
111
 
90
- # @return [Symbol] The trace mode to use when {Schema.detailed_trace?} returns `true`
112
+ # **Returns**
113
+ #
114
+ # - `Symbol` — The trace mode to use when [Schema.detailed_trace?](rdoc-ref:Schema.detailed_trace?) returns `true`
91
115
  attr_reader :trace_mode
92
116
 
93
- # @return [String] ID of saved trace
117
+ # **Returns**
118
+ #
119
+ # - `String` — ID of saved trace
120
+ #
121
+ # :call-seq:
122
+ # save_trace(operation_name, duration_ms, begin_ms, trace_data) -> String
94
123
  def save_trace(operation_name, duration_ms, begin_ms, trace_data)
95
124
  @storage.save_trace(operation_name, duration_ms, begin_ms, trace_data)
96
125
  end
97
126
 
98
- # @return [Boolean]
127
+ # **Returns**
128
+ #
129
+ # - `Boolean`
130
+ #
131
+ # :call-seq:
132
+ # debug?() -> bool
99
133
  def debug?
100
134
  @debug
101
135
  end
102
136
 
103
- # @param last [Integer]
104
- # @param before [Integer] Timestamp in milliseconds since epoch
105
- # @return [Enumerable<StoredTrace>]
137
+ # **Parameters**
138
+ #
139
+ # - `last` (`Integer`)
140
+ # - `before` (`Integer`) — Timestamp in milliseconds since epoch
141
+ #
142
+ # **Returns**
143
+ #
144
+ # - `Enumerable<StoredTrace>`
145
+ #
146
+ # :call-seq:
147
+ # traces(Integer last:, Integer before:) -> Enumerable[StoredTrace]
106
148
  def traces(last: nil, before: nil)
107
149
  @storage.traces(last: last, before: before)
108
150
  end
109
151
 
110
- # @return [StoredTrace, nil]
152
+ # **Returns**
153
+ #
154
+ # - `StoredTrace, nil`
155
+ #
156
+ # :call-seq:
157
+ # find_trace(id) -> StoredTrace | nil
111
158
  def find_trace(id)
112
159
  @storage.find_trace(id)
113
160
  end
114
161
 
115
- # @return [void]
162
+ # **Returns**
163
+ #
164
+ # - `void`
165
+ #
166
+ # :call-seq:
167
+ # delete_trace(id) -> void
116
168
  def delete_trace(id)
117
169
  @storage.delete_trace(id)
118
170
  end
119
171
 
120
- # @return [void]
172
+ # **Returns**
173
+ #
174
+ # - `void`
175
+ #
176
+ # :call-seq:
177
+ # delete_all_traces() -> void
121
178
  def delete_all_traces
122
179
  @storage.delete_all_traces
123
180
  end
@@ -135,7 +192,13 @@ module GraphQL
135
192
  end
136
193
 
137
194
  # Default debug setting
138
- # @return [true]
195
+ #
196
+ # **Returns**
197
+ #
198
+ # - `true`
199
+ #
200
+ # :call-seq:
201
+ # debug?() -> true
139
202
  def self.debug?
140
203
  true
141
204
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ # typed: true
2
3
 
3
4
  module GraphQL
4
5
  module Tracing
@@ -14,6 +15,10 @@ module GraphQL
14
15
  end
15
16
  end
16
17
 
18
+ #--
19
+
20
+ # @requires_ancestor: Kernel
21
+
17
22
  module RunHooks
18
23
  module_function
19
24
  # Call the before_ hooks of each query,
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ # typed: true
2
3
 
3
4
  require "graphql/tracing/trace"
4
5
  require "graphql/tracing/call_legacy_tracers"
@@ -1,11 +1,12 @@
1
1
  # frozen_string_literal: true
2
+ # typed: true
2
3
 
3
4
  module GraphQL
4
5
  module Tracing
5
6
  # This module is the basis for Ruby-level integration with third-party monitoring platforms.
6
7
  # Platform-specific traces include this module and implement an adapter.
7
8
  #
8
- # @see ActiveSupportNotificationsTrace Integration via ActiveSupport::Notifications, an alternative approach.
9
+ # See [ActiveSupportNotificationsTrace](rdoc-ref:ActiveSupportNotificationsTrace) Integration via ActiveSupport::Notifications, an alternative approach.
9
10
  module MonitorTrace
10
11
  class Monitor
11
12
  def initialize(trace:, set_transaction_name:, **_rest)
@@ -22,7 +23,7 @@ module GraphQL
22
23
  end
23
24
 
24
25
  def start_event(keyword, object)
25
- ev = self.class::Event.new(self, keyword, object)
26
+ ev = self.class.const_get(:Event).new(self, keyword, object)
26
27
  ev.start
27
28
  ev
28
29
  end
@@ -55,11 +56,11 @@ module GraphQL
55
56
  @platform_resolve_type_key_cache[object]
56
57
  when :dataloader_source
57
58
  @platform_source_class_key_cache[object.class]
58
- when :parse then self.class::PARSE_NAME
59
- when :lex then self.class::LEX_NAME
60
- when :execute then self.class::EXECUTE_NAME
61
- when :analyze then self.class::ANALYZE_NAME
62
- when :validate then self.class::VALIDATE_NAME
59
+ when :parse then self.class.const_get(:PARSE_NAME)
60
+ when :lex then self.class.const_get(:LEX_NAME)
61
+ when :execute then self.class.const_get(:EXECUTE_NAME)
62
+ when :analyze then self.class.const_get(:ANALYZE_NAME)
63
+ when :validate then self.class.const_get(:VALIDATE_NAME)
63
64
  else
64
65
  raise "No name for #{keyword.inspect}"
65
66
  end
@@ -147,10 +148,15 @@ module GraphQL
147
148
  end
148
149
 
149
150
  MODULE_TEMPLATE = <<~RUBY
150
- # @param set_transaction_name [Boolean] If `true`, use the GraphQL operation name as the request name on the monitoring platform
151
- # @param trace_scalars [Boolean] If `true`, leaf fields will be traced too (Scalars _and_ Enums)
152
- # @param trace_authorized [Boolean] If `false`, skip tracing `authorized?` calls
153
- # @param trace_resolve_type [Boolean] If `false`, skip tracing `resolve_type?` calls
151
+ # **Parameters**
152
+ #
153
+ # - `set_transaction_name` (`Boolean`) — If `true`, use the GraphQL operation name as the request name on the monitoring platform
154
+ # - `trace_scalars` (`Boolean`) — If `true`, leaf fields will be traced too (Scalars _and_ Enums)
155
+ # - `trace_authorized` (`Boolean`) — If `false`, skip tracing `authorized?` calls
156
+ # - `trace_resolve_type` (`Boolean`) — If `false`, skip tracing `resolve_type?` calls
157
+ #
158
+ # :call-seq:
159
+ # initialize(...)
154
160
  def initialize(...)
155
161
  setup_%{monitor}_monitor(...)
156
162
  super
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ # typed: ignore
2
3
 
3
4
  require "graphql/tracing/monitor_trace"
4
5
 
@@ -6,16 +7,24 @@ module GraphQL
6
7
  module Tracing
7
8
  # A tracer for reporting GraphQL-Ruby time to New Relic
8
9
  #
9
- # @example Installing the tracer
10
- # class MySchema < GraphQL::Schema
11
- # trace_with GraphQL::Tracing::NewRelicTrace
10
+ # **Examples**
12
11
  #
13
- # # Optional, use the operation name to set the new relic transaction name:
14
- # # trace_with GraphQL::Tracing::NewRelicTrace, set_transaction_name: true
15
- # end
12
+ # **Example: Installing the tracer**
16
13
  #
17
- # @example Installing without trace events for `authorized?` or `resolve_type` calls
18
- # trace_with GraphQL::Tracing::NewRelicTrace, trace_authorized: false, trace_resolve_type: false
14
+ # ```ruby
15
+ # class MySchema < GraphQL::Schema
16
+ # trace_with GraphQL::Tracing::NewRelicTrace
17
+ #
18
+ # # Optional, use the operation name to set the new relic transaction name:
19
+ # # trace_with GraphQL::Tracing::NewRelicTrace, set_transaction_name: true
20
+ # end
21
+ # ```
22
+ #
23
+ # **Example: Installing without trace events for `authorized?` or `resolve_type` calls**
24
+ #
25
+ # ```ruby
26
+ # trace_with GraphQL::Tracing::NewRelicTrace, trace_authorized: false, trace_resolve_type: false
27
+ # ```
19
28
  NewRelicTrace = MonitorTrace.create_module("newrelic")
20
29
  module NewRelicTrace
21
30
  class NewrelicMonitor < MonitorTrace::Monitor
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ # typed: ignore
2
3
 
3
4
  require "graphql/tracing/platform_tracing"
4
5
 
@@ -16,9 +17,12 @@ module GraphQL
16
17
  "execute_query_lazy" => "GraphQL/execute",
17
18
  }
18
19
 
19
- # @param set_transaction_name [Boolean] If true, the GraphQL operation name will be used as the transaction name.
20
- # This is not advised if you run more than one query per HTTP request, for example, with `graphql-client` or multiplexing.
21
- # It can also be specified per-query with `context[:set_new_relic_transaction_name]`.
20
+ # **Parameters**
21
+ #
22
+ # - `set_transaction_name` (`Boolean`) — If true, the GraphQL operation name will be used as the transaction name. This is not advised if you run more than one query per HTTP request, for example, with `graphql-client` or multiplexing. It can also be specified per-query with `context[:set_new_relic_transaction_name]`.
23
+ #
24
+ # :call-seq:
25
+ # initialize(options)
22
26
  def initialize(options = {})
23
27
  @set_transaction_name = options.fetch(:set_transaction_name, false)
24
28
  super
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
+ # typed: ignore
2
3
 
3
4
  module GraphQL
4
5
  module Tracing
5
6
  # This implementation forwards events to a notification handler
6
7
  # (i.e. ActiveSupport::Notifications or Dry::Monitor::Notifications) with a `graphql` suffix.
7
8
  #
8
- # @see ActiveSupportNotificationsTrace ActiveSupport::Notifications integration
9
+ # See [ActiveSupportNotificationsTrace](rdoc-ref:ActiveSupportNotificationsTrace) ActiveSupport::Notifications integration
9
10
  module NotificationsTrace
10
- # @api private
11
- class Adapter
11
+ class Adapter # :nodoc:
12
12
  def instrument(keyword, payload, &block)
13
13
  raise "Implement #{self.class}#instrument to measure the block"
14
14
  end
@@ -37,8 +37,7 @@ module GraphQL
37
37
  end
38
38
  end
39
39
 
40
- # @api private
41
- class DryMonitorAdapter < Adapter
40
+ class DryMonitorAdapter < Adapter # :nodoc:
42
41
  def instrument(...)
43
42
  Dry::Monitor.instrument(...)
44
43
  end
@@ -54,8 +53,7 @@ module GraphQL
54
53
  end
55
54
  end
56
55
 
57
- # @api private
58
- class ActiveSupportNotificationsAdapter < Adapter
56
+ class ActiveSupportNotificationsAdapter < Adapter # :nodoc:
59
57
  def instrument(...)
60
58
  ActiveSupport::Notifications.instrument(...)
61
59
  end
@@ -73,7 +71,12 @@ module GraphQL
73
71
  end
74
72
  end
75
73
 
76
- # @param engine [Class] The notifications engine to use, eg `Dry::Monitor` or `ActiveSupport::Notifications`
74
+ # **Parameters**
75
+ #
76
+ # - `engine` (`Class`) — The notifications engine to use, eg `Dry::Monitor` or `ActiveSupport::Notifications`
77
+ #
78
+ # :call-seq:
79
+ # initialize(Class engine:, **rest)
77
80
  def initialize(engine:, **rest)
78
81
  adapter = if defined?(Dry::Monitor) && engine == Dry::Monitor
79
82
  DryMonitoringAdapter
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ # typed: true
2
3
 
3
4
  require "graphql/tracing/platform_tracing"
4
5
 
@@ -8,7 +9,7 @@ module GraphQL
8
9
  # ActiveSupport::Notifications or Dry::Monitor::Notifications)
9
10
  # with a `graphql` suffix.
10
11
  #
11
- # @see KEYS for event names
12
+ # See [KEYS](rdoc-ref:KEYS) for event names
12
13
  class NotificationsTracing
13
14
  # A cache of frequently-used keys to avoid needless string allocations
14
15
  KEYS = {
@@ -31,21 +32,36 @@ module GraphQL
31
32
 
32
33
  # Initialize a new NotificationsTracing instance
33
34
  #
34
- # @param [Object] notifications_engine The notifications engine to use
35
+ # **Parameters**
36
+ #
37
+ # - `notifications_engine` (`Object`) — The notifications engine to use
38
+ #
39
+ # :call-seq:
40
+ # initialize(Object notifications_engine)
35
41
  def initialize(notifications_engine)
36
42
  @notifications_engine = notifications_engine
37
43
  end
38
44
 
39
45
  # Sends a GraphQL tracing event to the notification handler
40
46
  #
41
- # @example
42
- # . notifications_engine = Dry::Monitor::Notifications.new(:graphql)
47
+ # **Yields:** The block to execute for the event
48
+ #
49
+ # **Examples**
50
+ #
51
+ # **Example: . notifications_engine = Dry::Monitor::Notifications.new(:graphql)**
52
+ #
53
+ # ```ruby
43
54
  # . tracer = GraphQL::Tracing::NotificationsTracing.new(notifications_engine)
44
55
  # . tracer.trace("lex") { ... }
56
+ # ```
57
+ #
58
+ # **Parameters**
59
+ #
60
+ # - `key` (`string`) — The key for the event
61
+ # - `metadata` (`Hash`) — The metadata for the event
45
62
  #
46
- # @param [string] key The key for the event
47
- # @param [Hash] metadata The metadata for the event
48
- # @yield The block to execute for the event
63
+ # :call-seq:
64
+ # trace(string key, Hash metadata, &blk)
49
65
  def trace(key, metadata, &blk)
50
66
  prefixed_key = KEYS[key] || "#{key}.graphql"
51
67
 
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ # typed: true
2
3
 
3
4
  require "graphql/tracing/trace"
4
5
 
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ # typed: ignore
2
3
  # Generated by the protocol buffer compiler. DO NOT EDIT!
3
4
  # source: trace.proto
4
5
 
@@ -1,32 +1,40 @@
1
1
  # frozen_string_literal: true
2
+ # typed: true
2
3
  module GraphQL
3
4
  module Tracing
4
5
  # This produces a trace file for inspecting in the [Perfetto Trace Viewer](https://ui.perfetto.dev).
5
6
  #
6
- # To get the file, call {#write} on the trace.
7
+ # To get the file, call [write](rdoc-ref:#write) on the trace.
7
8
  #
8
9
  # Use "trace modes" to configure this to run on command or on a sample of traffic.
9
10
  #
10
- # @example Writing trace output
11
+ # **Examples**
11
12
  #
12
- # result = MySchema.execute(...)
13
- # result.query.trace.write(file: "tmp/trace.dump")
13
+ # **Example: Writing trace output**
14
14
  #
15
- # @example Running this instrumenter when `trace: true` is present in the request
15
+ # ```ruby
16
+ # result = MySchema.execute(...)
17
+ # result.query.trace.write(file: "tmp/trace.dump")
18
+ # ```
16
19
  #
17
- # class MySchema < GraphQL::Schema
18
- # # Only run this tracer when `context[:trace_mode]` is `:trace`
19
- # trace_with GraphQL::Tracing::Perfetto, mode: :trace
20
- # end
20
+ # **Example: Running this instrumenter when `trace: true` is present in the request**
21
21
  #
22
- # # In graphql_controller.rb:
22
+ # ```ruby
23
+ # class MySchema < GraphQL::Schema
24
+ # # Only run this tracer when `context[:trace_mode]` is `:trace`
25
+ # trace_with GraphQL::Tracing::Perfetto, mode: :trace
26
+ # end
23
27
  #
24
- # context[:trace_mode] = params[:trace] ? :trace : nil
25
- # result = MySchema.execute(query_str, context: context, variables: variables, ...)
26
- # if context[:trace_mode] == :trace
27
- # result.trace.write(file: ...)
28
- # end
28
+ # # In graphql_controller.rb:
29
29
  #
30
+ # context[:trace_mode] = params[:trace] ? :trace : nil
31
+ # result = MySchema.execute(query_str, context: context, variables: variables, ...)
32
+ # if context[:trace_mode] == :trace
33
+ # result.trace.write(file: ...)
34
+ # end
35
+ # ```
36
+ #--
37
+ # @requires_ancestor: Kernel
30
38
  module PerfettoTrace
31
39
  # TODOs:
32
40
  # - Make debug annotations visible on both parts when dataloader is involved
@@ -74,7 +82,12 @@ module GraphQL
74
82
  DEBUG_INSPECT_EVENT_NAME_IID = 17
75
83
  DA_DEBUG_INSPECT_FOR_IID = 18
76
84
 
77
- # @param active_support_notifications_pattern [String, RegExp, false] A filter for `ActiveSupport::Notifications`, if it's present. Or `false` to skip subscribing.
85
+ # **Parameters**
86
+ #
87
+ # - `active_support_notifications_pattern` (`String, RegExp, false`) — A filter for `ActiveSupport::Notifications`, if it's present. Or `false` to skip subscribing.
88
+ #
89
+ # :call-seq:
90
+ # initialize(String | RegExp | false active_support_notifications_pattern:, save_profile:, **_rest)
78
91
  def initialize(active_support_notifications_pattern: nil, save_profile: false, **_rest)
79
92
  super
80
93
  @active_support_notifications_pattern = active_support_notifications_pattern
@@ -571,9 +584,18 @@ module GraphQL
571
584
  end
572
585
 
573
586
  # Dump protobuf output in the specified file.
574
- # @param file [String] path to a file in a directory that already exists
575
- # @param debug_json [Boolean] True to print JSON instead of binary
576
- # @return [nil, String, Hash] If `file` was given, `nil`. If `file` was `nil`, a Hash if `debug_json: true`, else binary data.
587
+ #
588
+ # **Parameters**
589
+ #
590
+ # - `file` (`String`) — path to a file in a directory that already exists
591
+ # - `debug_json` (`Boolean`) — True to print JSON instead of binary
592
+ #
593
+ # **Returns**
594
+ #
595
+ # - `nil, String, Hash` — If `file` was given, `nil`. If `file` was `nil`, a Hash if `debug_json: true`, else binary data.
596
+ #
597
+ # :call-seq:
598
+ # write(String file:, bool debug_json:) -> nil | String | Hash
577
599
  def write(file:, debug_json: false)
578
600
  trace = Trace.new(
579
601
  packet: @packets,
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ # typed: true
2
3
 
3
4
  module GraphQL
4
5
  module Tracing
@@ -6,7 +7,7 @@ module GraphQL
6
7
  def initialize(trace_scalars: false, **_options)
7
8
  @trace_scalars = trace_scalars
8
9
 
9
- @platform_key_cache = Hash.new { |h, mod| h[mod] = mod::KeyCache.new }
10
+ @platform_key_cache = Hash.new { |h, mod| h[mod] = mod.const_get(:KeyCache).new }
10
11
  super
11
12
  end
12
13
 
@@ -22,6 +23,7 @@ module GraphQL
22
23
 
23
24
 
24
25
  def platform_execute_field_lazy(*args, &block)
26
+ args = args #: untyped
25
27
  platform_execute_field(*args, &block)
26
28
  end
27
29