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,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ # typed: true
2
3
  module GraphQL
3
4
  class Schema
4
5
  # Extend this class to make field-level customizations to resolve behavior.
@@ -9,19 +10,31 @@ module GraphQL
9
10
  # The instance is frozen so that instance variables aren't modified during query execution,
10
11
  # which could cause all kinds of issues due to race conditions.
11
12
  class FieldExtension
12
- # @return [GraphQL::Schema::Field]
13
+ # **Returns**
14
+ #
15
+ # - `GraphQL::Schema::Field`
13
16
  attr_reader :field
14
17
 
15
- # @return [Object]
18
+ # **Returns**
19
+ #
20
+ # - `Object`
16
21
  attr_reader :options
17
22
 
18
- # @return [Array<Symbol>, nil] `default_argument`s added, if any were added (otherwise, `nil`)
23
+ # **Returns**
24
+ #
25
+ # - `Array<Symbol>, nil` — `default_argument`s added, if any were added (otherwise, `nil`)
19
26
  attr_reader :added_default_arguments
20
27
 
21
28
  # Called when the extension is mounted with `extension(name, options)`.
22
29
  # The instance will be frozen to avoid improper use of state during execution.
23
- # @param field [GraphQL::Schema::Field] The field where this extension was mounted
24
- # @param options [Object] The second argument to `extension`, or `{}` if nothing was passed.
30
+ #
31
+ # **Parameters**
32
+ #
33
+ # - `field` (`GraphQL::Schema::Field`) — The field where this extension was mounted
34
+ # - `options` (`Object`) — The second argument to `extension`, or `{}` if nothing was passed.
35
+ #
36
+ # :call-seq:
37
+ # initialize(GraphQL::Schema::Field field:, Object options:)
25
38
  def initialize(field:, options:)
26
39
  @field = field
27
40
  @options = options || {}
@@ -30,7 +43,12 @@ module GraphQL
30
43
  end
31
44
 
32
45
  class << self
33
- # @return [Array(Array, Hash), nil] A list of default argument configs, or `nil` if there aren't any
46
+ # **Returns**
47
+ #
48
+ # - `Array(Array, Hash), nil` — A list of default argument configs, or `nil` if there aren't any
49
+ #
50
+ # :call-seq:
51
+ # default_argument_configurations() -> Array(Array, Hash) | nil
34
52
  def default_argument_configurations
35
53
  args = superclass.respond_to?(:default_argument_configurations) ? superclass.default_argument_configurations : nil
36
54
  if @own_default_argument_configurations
@@ -43,8 +61,8 @@ module GraphQL
43
61
  args
44
62
  end
45
63
 
46
- # @see Argument#initialize
47
- # @see HasArguments#argument
64
+ # See the [GraphQL::Schema::Argument](rdoc-ref:GraphQL::Schema::Argument) API.
65
+ # See [HasArguments#argument](rdoc-ref:GraphQL::Schema::Member::HasArguments#argument) for argument configuration.
48
66
  def default_argument(*argument_args, **argument_kwargs)
49
67
  configs = @own_default_argument_configurations ||= []
50
68
  configs << [argument_args, argument_kwargs]
@@ -54,8 +72,16 @@ module GraphQL
54
72
  # but removed by from `arguments` before the field's `resolve` is called.
55
73
  # (The extras _will_ be present for other extensions, though.)
56
74
  #
57
- # @param new_extras [Array<Symbol>] If provided, assign extras used by this extension
58
- # @return [Array<Symbol>] any extras assigned to this extension
75
+ # **Parameters**
76
+ #
77
+ # - `new_extras` (`Array<Symbol>`) — If provided, assign extras used by this extension
78
+ #
79
+ # **Returns**
80
+ #
81
+ # - `Array<Symbol>` — any extras assigned to this extension
82
+ #
83
+ # :call-seq:
84
+ # extras(Array[Symbol] new_extras) -> Array[Symbol]
59
85
  def extras(new_extras = nil)
60
86
  if new_extras
61
87
  @own_extras = new_extras
@@ -78,18 +104,29 @@ module GraphQL
78
104
 
79
105
  # Called when this extension is attached to a field.
80
106
  # The field definition may be extended during this method.
81
- # @return [void]
107
+ #
108
+ # **Returns**
109
+ #
110
+ # - `void`
111
+ #
112
+ # :call-seq:
113
+ # apply() -> void
82
114
  def apply
83
115
  end
84
116
 
85
117
  # Called after the field's definition block has been executed.
86
118
  # (Any arguments from the block are present on `field`)
87
- # @return [void]
119
+ #
120
+ # **Returns**
121
+ #
122
+ # - `void`
123
+ #
124
+ # :call-seq:
125
+ # after_define() -> void
88
126
  def after_define
89
127
  end
90
128
 
91
- # @api private
92
- def after_define_apply
129
+ def after_define_apply # :nodoc:
93
130
  after_define
94
131
  if (configs = self.class.default_argument_configurations)
95
132
  existing_keywords = field.all_argument_definitions.map(&:keyword)
@@ -113,41 +150,59 @@ module GraphQL
113
150
  freeze
114
151
  end
115
152
 
116
- # @api private
117
- attr_reader :added_extras
153
+ attr_reader :added_extras # :nodoc:
118
154
 
119
- # Called before resolving {#field}. It should either:
155
+ # Called before resolving [field](rdoc-ref:#field). It should either:
120
156
  #
121
157
  # - `yield` values to continue execution; OR
122
158
  # - return something else to shortcut field execution.
123
159
  #
124
160
  # Whatever this method returns will be used for execution.
125
161
  #
126
- # @param object [Object] The object the field is being resolved on (not passed by new execution)
127
- # @param objects [Array<Object>] The objects the field is being resolved on (passed by new execution)
128
- # @param arguments [Hash] Ruby keyword arguments for resolving this field
129
- # @param context [Query::Context] the context for this query
130
- # @yieldparam object_or_objects [Object, Array<Object>] The object or objects (new execution) to continue resolving the field on
131
- # @yieldparam arguments [Hash] The keyword arguments to continue resolving with
132
- # @yieldparam memo [Object] Any extension-specific value which will be passed to {#after_resolve} later
133
- # @return [Object] The return value for this field.
162
+ # **Parameters**
163
+ #
164
+ # - `object` (`Object`) — The object the field is being resolved on (not passed by new execution)
165
+ # - `objects` (`Array<Object>`) — The objects the field is being resolved on (passed by new execution)
166
+ # - `arguments` (`Hash`) — Ruby keyword arguments for resolving this field
167
+ # - `context` (`Query::Context`) — the context for this query
168
+ #
169
+ # **Yields**
170
+ #
171
+ # - `object_or_objects` (`Object, Array<Object>`) — The object or objects (new execution) to continue resolving the field on
172
+ # - `arguments` (`Hash`) — The keyword arguments to continue resolving with
173
+ # - `memo` (`Object`) — Any extension-specific value which will be passed to [after resolve](rdoc-ref:#after_resolve) later
174
+ #
175
+ # **Returns**
176
+ #
177
+ # - `Object` — The return value for this field.
178
+ #
179
+ # :call-seq:
180
+ # resolve(Object object:, Array[Object] objects:, Hash arguments:, Query::Context context:) -> Object
134
181
  def resolve(object: nil, objects: nil, arguments:, context:)
135
182
  yield(object.nil? ? objects : object, arguments, nil)
136
183
  end
137
184
 
138
- # Called after {#field} was resolved, and after any lazy values (like `Promise`s) were synced,
185
+ # Called after [field](rdoc-ref:#field) was resolved, and after any lazy values (like `Promise`s) were synced,
139
186
  # but before the value was added to the GraphQL response.
140
187
  #
141
188
  # Whatever this hook returns will be used as the return value.
142
189
  #
143
- # @param object [Object] The object the field is being resolved on (not passed by new execution)
144
- # @param objects [Array<Object>] The object the field is being resolved on (passed by new execution)
145
- # @param arguments [Hash] Ruby keyword arguments for resolving this field
146
- # @param context [Query::Context] the context for this query
147
- # @param value [Object] Whatever the field previously returned (not passed by new execution)
148
- # @param values [Array<Object>] Whatever the field previously returned (passed by new execution)
149
- # @param memo [Object] The third value yielded by {#resolve}, or `nil` if there wasn't one
150
- # @return [Object] The return value for this field.
190
+ # **Parameters**
191
+ #
192
+ # - `object` (`Object`) — The object the field is being resolved on (not passed by new execution)
193
+ # - `objects` (`Array<Object>`) — The object the field is being resolved on (passed by new execution)
194
+ # - `arguments` (`Hash`) — Ruby keyword arguments for resolving this field
195
+ # - `context` (`Query::Context`) — the context for this query
196
+ # - `value` (`Object`) — Whatever the field previously returned (not passed by new execution)
197
+ # - `values` (`Array<Object>`) — Whatever the field previously returned (passed by new execution)
198
+ # - `memo` (`Object`) — The third value yielded by [resolve](rdoc-ref:#resolve), or `nil` if there wasn't one
199
+ #
200
+ # **Returns**
201
+ #
202
+ # - `Object` — The return value for this field.
203
+ #
204
+ # :call-seq:
205
+ # after_resolve(Object object:, Array[Object] objects:, Hash arguments:, Query::Context context:, Array[Object] values:, Object value:, Object memo:) -> Object
151
206
  def after_resolve(object: nil, objects: nil, arguments:, context:, values: nil, value: nil, memo:)
152
207
  value.nil? ? values : value
153
208
  end
@@ -1,6 +1,9 @@
1
1
  # frozen_string_literal: true
2
+ # typed: true
2
3
  module GraphQL
3
4
  class Schema
5
+ #--
6
+ # @requires_ancestor: Module
4
7
  module FindInheritedValue
5
8
  def self.extended(child_cls)
6
9
  child_cls.singleton_class.include(GraphQL::EmptyObjects)
@@ -16,9 +19,8 @@ module GraphQL
16
19
  if self.is_a?(Class)
17
20
  superclass.respond_to?(method_name, true) ? superclass.send(method_name) : default_value
18
21
  else
19
- ancestors_except_self = ancestors
20
- ancestors_except_self.delete(self)
21
- ancestors_except_self.each do |ancestor|
22
+ ancestors.each do |ancestor|
23
+ next if ancestor.equal?(self)
22
24
  if ancestor.respond_to?(method_name, true)
23
25
  return ancestor.send(method_name)
24
26
  end
@@ -1,21 +1,35 @@
1
1
  # frozen_string_literal: true
2
+ # typed: true
2
3
 
3
4
  module GraphQL
4
5
  class Schema
5
6
  # Find schema members using string paths
6
7
  #
7
- # @example Finding object types
8
- # MySchema.find("SomeObjectType")
8
+ # **Examples**
9
9
  #
10
- # @example Finding fields
11
- # MySchema.find("SomeObjectType.myField")
10
+ # **Example: Finding object types**
12
11
  #
13
- # @example Finding arguments
14
- # MySchema.find("SomeObjectType.myField.anArgument")
12
+ # ```ruby
13
+ # MySchema.find("SomeObjectType")
14
+ # ```
15
15
  #
16
- # @example Finding directives
17
- # MySchema.find("@include")
16
+ # **Example: Finding fields**
18
17
  #
18
+ # ```ruby
19
+ # MySchema.find("SomeObjectType.myField")
20
+ # ```
21
+ #
22
+ # **Example: Finding arguments**
23
+ #
24
+ # ```ruby
25
+ # MySchema.find("SomeObjectType.myField.anArgument")
26
+ # ```
27
+ #
28
+ # **Example: Finding directives**
29
+ #
30
+ # ```ruby
31
+ # MySchema.find("@include")
32
+ # ```
19
33
  class Finder
20
34
  class MemberNotFoundError < ArgumentError; end
21
35
 
@@ -1,7 +1,10 @@
1
1
  # frozen_string_literal: true
2
+ # typed: true
2
3
 
3
4
  module GraphQL
4
5
  class Schema
6
+ #--
7
+ # @requires_ancestor: GraphQL::Schema::Resolver
5
8
  module HasSingleInputArgument
6
9
  def resolve_with_support(**inputs)
7
10
  input_kwargs = flatten_arguments(inputs)
@@ -31,7 +34,8 @@ module GraphQL
31
34
  end
32
35
 
33
36
  new_extras = field ? field.extras : []
34
- all_extras = self.class.extras + new_extras
37
+ resolver_class = self.class #: as singleton(GraphQL::Schema::Resolver)
38
+ all_extras = resolver_class.extras + new_extras
35
39
 
36
40
  # Transfer these from the top-level hash to the
37
41
  # shortcutted `input:` object
@@ -54,6 +58,8 @@ module GraphQL
54
58
  input_kwargs
55
59
  end
56
60
 
61
+ #--
62
+ # @requires_ancestor: singleton(GraphQL::Schema::Resolver)
57
63
  module ClassMethods
58
64
  def dummy
59
65
  @dummy ||= begin
@@ -89,6 +95,7 @@ module GraphQL
89
95
  # Also apply this argument to the input type:
90
96
  def argument(*args, own_argument: false, **kwargs, &block)
91
97
  it = input_type # make sure any inherited arguments are already added to it
98
+ args = args #: untyped
92
99
  arg = super(*args, **kwargs, &block)
93
100
 
94
101
  # This definition might be overriding something inherited;
@@ -111,8 +118,17 @@ module GraphQL
111
118
  end
112
119
 
113
120
  # The base class for generated input object types
114
- # @param new_class [Class] The base class to use for generating input object definitions
115
- # @return [Class] The base class for this mutation's generated input object (default is {GraphQL::Schema::InputObject})
121
+ #
122
+ # **Parameters**
123
+ #
124
+ # - `new_class` (`Class`) — The base class to use for generating input object definitions
125
+ #
126
+ # **Returns**
127
+ #
128
+ # - `Class` — The base class for this mutation's generated input object (default is [GraphQL::Schema::InputObject](rdoc-ref:GraphQL::Schema::InputObject))
129
+ #
130
+ # :call-seq:
131
+ # input_object_class(Class new_class) -> Class
116
132
  def input_object_class(new_class = nil)
117
133
  if new_class
118
134
  @input_object_class = new_class
@@ -120,8 +136,16 @@ module GraphQL
120
136
  @input_object_class || (superclass.respond_to?(:input_object_class) ? superclass.input_object_class : GraphQL::Schema::InputObject)
121
137
  end
122
138
 
123
- # @param new_input_type [Class, nil] If provided, it configures this mutation to accept `new_input_type` instead of generating an input type
124
- # @return [Class] The generated {Schema::InputObject} class for this mutation's `input`
139
+ # **Parameters**
140
+ #
141
+ # - `new_input_type` (`Class, nil`) — If provided, it configures this mutation to accept `new_input_type` instead of generating an input type
142
+ #
143
+ # **Returns**
144
+ #
145
+ # - `Class` — The generated [Schema::InputObject](rdoc-ref:Schema::InputObject) class for this mutation's `input`
146
+ #
147
+ # :call-seq:
148
+ # input_type(Class | nil new_input_type) -> Class
125
149
  def input_type(new_input_type = nil)
126
150
  if new_input_type
127
151
  @input_type = new_input_type
@@ -133,17 +157,26 @@ module GraphQL
133
157
 
134
158
  # Generate the input type for the `input:` argument
135
159
  # To customize how input objects are generated, override this method
136
- # @return [Class] a subclass of {.input_object_class}
160
+ #
161
+ # **Returns**
162
+ #
163
+ # - `Class` — a subclass of [.input_object_class](rdoc-ref:.input_object_class)
164
+ #
165
+ # :call-seq:
166
+ # generate_input_type() -> Class
137
167
  def generate_input_type
138
168
  mutation_args = all_argument_definitions
139
169
  mutation_class = self
140
170
  Class.new(input_object_class) do
171
+ #: self as singleton(GraphQL::Schema::InputObject)
141
172
  class << self
142
173
  def default_graphql_name
174
+ #: self as singleton(GraphQL::Schema::InputObject)
143
175
  "#{self.mutation.graphql_name}Input"
144
176
  end
145
177
 
146
178
  def description(new_desc = nil)
179
+ #: self as singleton(GraphQL::Schema::InputObject)
147
180
  super || "Autogenerated input type of #{self.mutation.graphql_name}"
148
181
  end
149
182
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ # typed: true
2
3
  module GraphQL
3
4
  class Schema
4
5
  class InputObject < GraphQL::Schema::Member
@@ -18,9 +19,13 @@ module GraphQL
18
19
  end
19
20
  end
20
21
 
21
- # @return [GraphQL::Query::Context] The context for this query
22
+ # **Returns**
23
+ #
24
+ # - `GraphQL::Query::Context` — The context for this query
22
25
  attr_reader :context
23
- # @return [GraphQL::Execution::Interpereter::Arguments] The underlying arguments instance
26
+ # **Returns**
27
+ #
28
+ # - `GraphQL::Execution::Interpereter::Arguments` — The underlying arguments instance
24
29
  attr_reader :arguments
25
30
 
26
31
  # Ruby-like hash behaviors, read-only
@@ -72,8 +77,8 @@ module GraphQL
72
77
  when Array
73
78
  value.map { |item| unwrap_value(item) }
74
79
  when Hash
75
- value.reduce({}) do |h, (key, value)|
76
- h.merge!(key => unwrap_value(value))
80
+ value.reduce({}) do |h, (key, nested_value)|
81
+ h.merge!(key => unwrap_value(nested_value))
77
82
  end
78
83
  when InputObject
79
84
  value.to_h
@@ -84,7 +89,13 @@ module GraphQL
84
89
 
85
90
  # Lookup a key on this object, it accepts new-style underscored symbols
86
91
  # Or old-style camelized identifiers.
87
- # @param key [Symbol, String]
92
+ #
93
+ # **Parameters**
94
+ #
95
+ # - `key` (`Symbol, String`)
96
+ #
97
+ # :call-seq:
98
+ # [](Symbol | String key)
88
99
  def [](key)
89
100
  if @ruby_style_hash.key?(key)
90
101
  @ruby_style_hash[key]
@@ -104,8 +115,7 @@ module GraphQL
104
115
  @ruby_style_hash.dup
105
116
  end
106
117
 
107
- # @api private
108
- def validate_for(context)
118
+ def validate_for(context) # :nodoc:
109
119
  object = context[:current_object]
110
120
  # Pass this object's class with `as` so that messages are rendered correctly from inherited validators
111
121
  Schema::Validator.validate!(self.class.validators, object, context, @ruby_style_hash, as: self.class)
@@ -145,6 +155,7 @@ module GraphQL
145
155
  end
146
156
 
147
157
  def argument(*args, **kwargs, &block)
158
+ args = args #: untyped
148
159
  argument_defn = super(*args, **kwargs, &block)
149
160
  if one_of?
150
161
  if argument_defn.type.non_null?
@@ -165,7 +176,7 @@ module GraphQL
165
176
  GraphQL::TypeKinds::INPUT_OBJECT
166
177
  end
167
178
 
168
- # @api private
179
+ # :nodoc:
169
180
  INVALID_OBJECT_MESSAGE = "Expected %{object} to be a key-value object."
170
181
 
171
182
  def validate_non_null_input(input, ctx, max_errors: nil)
@@ -181,7 +192,7 @@ module GraphQL
181
192
  end
182
193
 
183
194
 
184
- result = nil
195
+ result = nil #: GraphQL::Query::InputValidationResult?
185
196
 
186
197
 
187
198
  input.each do |argument_name, value|
@@ -270,14 +281,27 @@ module GraphQL
270
281
  result
271
282
  end
272
283
 
273
- # @param new_has_no_arguments [Boolean] Call with `true` to make this InputObject type ignore the requirement to have any defined arguments.
274
- # @return [void]
284
+ # **Parameters**
285
+ #
286
+ # - `new_has_no_arguments` (`Boolean`) — Call with `true` to make this InputObject type ignore the requirement to have any defined arguments.
287
+ #
288
+ # **Returns**
289
+ #
290
+ # - `void`
291
+ #
292
+ # :call-seq:
293
+ # has_no_arguments(bool new_has_no_arguments) -> void
275
294
  def has_no_arguments(new_has_no_arguments)
276
295
  @has_no_arguments = new_has_no_arguments
277
296
  nil
278
297
  end
279
298
 
280
- # @return [Boolean] `true` if `has_no_arguments(true)` was configued
299
+ # **Returns**
300
+ #
301
+ # - `Boolean` — `true` if `has_no_arguments(true)` was configued
302
+ #
303
+ # :call-seq:
304
+ # has_no_arguments?() -> bool
281
305
  def has_no_arguments?
282
306
  @has_no_arguments
283
307
  end
@@ -301,7 +325,10 @@ module GraphQL
301
325
  end
302
326
 
303
327
  def define_accessor_method(method_name)
304
- define_method(method_name) { self[method_name] }
328
+ define_method(method_name) {
329
+ #: self as GraphQL::Schema::InputObject
330
+ self[method_name]
331
+ }
305
332
  alias_method(method_name, method_name)
306
333
  end
307
334
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ # typed: true
2
3
  module GraphQL
3
4
  class Schema
4
5
  module Interface
@@ -28,32 +29,36 @@ module GraphQL
28
29
  defn_methods_module = Module.new
29
30
  @_definition_methods = defn_methods_module
30
31
  const_set(:DefinitionMethods, defn_methods_module)
31
- extend(self::DefinitionMethods)
32
+ extend(defn_methods_module)
32
33
  end
33
- self::DefinitionMethods.module_exec(&block)
34
+ const_get(:DefinitionMethods).module_exec(&block)
34
35
  end
35
36
 
36
37
  # Instance methods defined in this block will become class methods on objects that implement this interface.
37
38
  # Use it to implement `resolve_each:`, `resolve_batch:`, and `resolve_static:` fields.
38
- # @example
39
- # field :thing, String, resolve_static: true
40
39
  #
41
- # resolver_methods do
42
- # def thing
43
- # Somehow.get.thing
44
- # end
40
+ # **Examples**
41
+ #
42
+ # **Example: field :thing, String, resolve_static: true**
43
+ #
44
+ # ```ruby
45
+ # resolver_methods do
46
+ # def thing
47
+ # Somehow.get.thing
45
48
  # end
49
+ # end
50
+ # ```
46
51
  def resolver_methods(&block)
47
52
  if !defined?(@_resolver_methods)
48
53
  resolver_methods_module = Module.new
49
54
  @_resolver_methods = resolver_methods_module
50
55
  const_set(:ResolverMethods, resolver_methods_module)
51
- extend(self::ResolverMethods)
56
+ extend(resolver_methods_module)
52
57
  end
53
- self::ResolverMethods.module_exec(&block)
58
+ const_get(:ResolverMethods).module_exec(&block)
54
59
  end
55
60
 
56
- # @see {Schema::Warden} hides interfaces without visible implementations
61
+ # See [Schema::Warden](rdoc-ref:Schema::Warden) hides interfaces without visible implementations
57
62
  def visible?(context)
58
63
  true
59
64
  end
@@ -78,7 +83,7 @@ module GraphQL
78
83
  child_class.type_membership_class(self.type_membership_class)
79
84
  child_class.ancestors.reverse_each do |ancestor|
80
85
  if ancestor.const_defined?(:DefinitionMethods) && ancestor != child_class
81
- child_class.extend(ancestor::DefinitionMethods)
86
+ child_class.extend(ancestor.const_get(:DefinitionMethods))
82
87
  end
83
88
  end
84
89
 
@@ -91,9 +96,11 @@ module GraphQL
91
96
  end
92
97
  elsif child_class < GraphQL::Schema::Object
93
98
  # This is being included into an object type, make sure it's using `implements(...)`
94
- backtrace_line = caller_locations(0, 10).find do |location|
99
+ locations = caller_locations(0, 10) #: as !nil
100
+ backtrace_line = locations.find do |location|
101
+ location_path = location.path #: as !nil
95
102
  location.base_label == "implements" &&
96
- location.path.end_with?("schema/member/has_interfaces.rb")
103
+ location_path.end_with?("schema/member/has_interfaces.rb")
97
104
  end
98
105
 
99
106
  if !backtrace_line
@@ -102,7 +109,7 @@ module GraphQL
102
109
 
103
110
  child_class.ancestors.reverse_each do |ancestor|
104
111
  if ancestor != child_class && ancestor <= GraphQL::Schema::Interface && ancestor.const_defined?(:ResolverMethods, false)
105
- child_class.extend(ancestor::ResolverMethods)
112
+ child_class.extend(ancestor.const_get(:ResolverMethods))
106
113
  end
107
114
  end
108
115
  end
@@ -114,8 +121,17 @@ module GraphQL
114
121
  #
115
122
  # When those Interfaces or Objects aren't used as the return values of fields,
116
123
  # they may have to be registered using this method so that GraphQL-Ruby can find them.
117
- # @param types [Class, Module]
118
- # @return [Array<Module, Class>] Implementers of this interface, if they're registered
124
+ #
125
+ # **Parameters**
126
+ #
127
+ # - `types` (`Class, Module`)
128
+ #
129
+ # **Returns**
130
+ #
131
+ # - `Array<Module, Class>` — Implementers of this interface, if they're registered
132
+ #
133
+ # :call-seq:
134
+ # orphan_types(Class | Module *types) -> Array[Module | Class]
119
135
  def orphan_types(*types)
120
136
  if !types.empty?
121
137
  @orphan_types ||= []
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ # typed: true
2
3
  module GraphQL
3
4
  class Schema
4
5
  class IntrospectionSystem
@@ -64,9 +65,11 @@ module GraphQL
64
65
  # Replace those with the objects that they refer to, since LateBoundTypes
65
66
  # aren't handled at runtime.
66
67
  #
67
- # @api private
68
- # @return void
69
- def resolve_late_bindings
68
+ #
69
+ # **Returns**
70
+ #
71
+ # - `Object` — void
72
+ def resolve_late_bindings # :nodoc:
70
73
  @types.each do |name, t|
71
74
  if t.kind.fields?
72
75
  t.all_field_definitions.each do |field_defn|
@@ -123,6 +126,7 @@ module GraphQL
123
126
  def dup_type_class(type_class)
124
127
  type_name = type_class.graphql_name
125
128
  Class.new(type_class) do
129
+ #: self as untyped
126
130
  # This won't be inherited like other things will
127
131
  graphql_name(type_name)
128
132
 
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
+ # typed: true
2
3
  module GraphQL
3
4
  class Schema
4
5
  # A stand-in for a type which will be resolved in a given schema, by name.
5
6
  # TODO: support argument types too, make this a public API somehow
6
- # @api Private
7
- class LateBoundType
7
+ class LateBoundType # :nodoc:
8
8
  attr_reader :name
9
9
  alias :graphql_name :name
10
10
  def initialize(local_name)
@@ -1,19 +1,30 @@
1
1
  # frozen_string_literal: true
2
+ # typed: true
2
3
 
3
4
  module GraphQL
4
5
  class Schema
5
6
  # Represents a list type in the schema.
6
- # Wraps a {Schema::Member} as a list type.
7
- # @see Schema::Member::TypeSystemHelpers#to_list_type Create a list type from another GraphQL type
7
+ # Wraps a [Schema::Member](rdoc-ref:Schema::Member) as a list type.
8
+ # See [Schema::Member::TypeSystemHelpers#to_list_type](rdoc-ref:Schema::Member::TypeSystemHelpers#to_list_type) Create a list type from another GraphQL type
8
9
  class List < GraphQL::Schema::Wrapper
9
10
  include Schema::Member::ValidatesInput
10
11
 
11
- # @return [GraphQL::TypeKinds::LIST]
12
+ # **Returns**
13
+ #
14
+ # - `GraphQL::TypeKinds::LIST`
15
+ #
16
+ # :call-seq:
17
+ # kind() -> GraphQL::TypeKinds::LIST
12
18
  def kind
13
19
  GraphQL::TypeKinds::LIST
14
20
  end
15
21
 
16
- # @return [true]
22
+ # **Returns**
23
+ #
24
+ # - `true`
25
+ #
26
+ # :call-seq:
27
+ # list?() -> true
17
28
  def list?
18
29
  true
19
30
  end