graphql 2.6.14 → 2.6.16

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 (381) hide show
  1. checksums.yaml +4 -4
  2. data/lib/generators/graphql/core.rb +1 -0
  3. data/lib/generators/graphql/detailed_trace_generator.rb +1 -0
  4. data/lib/generators/graphql/enum_generator.rb +1 -0
  5. data/lib/generators/graphql/field_extractor.rb +1 -0
  6. data/lib/generators/graphql/input_generator.rb +1 -0
  7. data/lib/generators/graphql/install/mutation_root_generator.rb +1 -0
  8. data/lib/generators/graphql/install_generator.rb +1 -0
  9. data/lib/generators/graphql/interface_generator.rb +1 -0
  10. data/lib/generators/graphql/loader_generator.rb +1 -0
  11. data/lib/generators/graphql/mutation_create_generator.rb +1 -0
  12. data/lib/generators/graphql/mutation_delete_generator.rb +1 -0
  13. data/lib/generators/graphql/mutation_generator.rb +1 -0
  14. data/lib/generators/graphql/mutation_update_generator.rb +1 -0
  15. data/lib/generators/graphql/object_generator.rb +1 -0
  16. data/lib/generators/graphql/orm_mutations_base.rb +1 -0
  17. data/lib/generators/graphql/relay.rb +1 -0
  18. data/lib/generators/graphql/relay_generator.rb +1 -0
  19. data/lib/generators/graphql/scalar_generator.rb +1 -0
  20. data/lib/generators/graphql/templates/graphql_controller.erb +7 -1
  21. data/lib/generators/graphql/type_generator.rb +1 -0
  22. data/lib/generators/graphql/union_generator.rb +1 -0
  23. data/lib/graphql/analysis/analyzer.rb +1 -0
  24. data/lib/graphql/analysis/field_usage.rb +1 -0
  25. data/lib/graphql/analysis/max_query_complexity.rb +3 -1
  26. data/lib/graphql/analysis/max_query_depth.rb +3 -1
  27. data/lib/graphql/analysis/query_complexity.rb +7 -2
  28. data/lib/graphql/analysis/query_depth.rb +2 -1
  29. data/lib/graphql/analysis/visitor.rb +15 -2
  30. data/lib/graphql/analysis.rb +5 -5
  31. data/lib/graphql/analysis_error.rb +2 -1
  32. data/lib/graphql/autoload.rb +1 -0
  33. data/lib/graphql/backtrace/table.rb +1 -0
  34. data/lib/graphql/backtrace/traced_error.rb +1 -0
  35. data/lib/graphql/backtrace.rb +1 -0
  36. data/lib/graphql/coercion_error.rb +2 -1
  37. data/lib/graphql/current.rb +6 -1
  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 +2 -1
  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 +1 -0
  50. data/lib/graphql/dataloader/null_dataloader.rb +1 -0
  51. data/lib/graphql/dataloader/request.rb +1 -0
  52. data/lib/graphql/dataloader/request_all.rb +1 -0
  53. data/lib/graphql/dataloader/source.rb +1 -0
  54. data/lib/graphql/dataloader.rb +1 -0
  55. data/lib/graphql/date_encoding_error.rb +4 -1
  56. data/lib/graphql/dig.rb +1 -0
  57. data/lib/graphql/duration_encoding_error.rb +4 -1
  58. data/lib/graphql/execution/directive_checks.rb +3 -1
  59. data/lib/graphql/execution/errors.rb +19 -7
  60. data/lib/graphql/execution/field_resolve_step.rb +4 -3
  61. data/lib/graphql/execution/finalize.rb +1 -0
  62. data/lib/graphql/execution/input_values.rb +196 -120
  63. data/lib/graphql/execution/interpreter/argument_value.rb +1 -0
  64. data/lib/graphql/execution/interpreter/arguments.rb +1 -0
  65. data/lib/graphql/execution/interpreter/arguments_cache.rb +1 -0
  66. data/lib/graphql/execution/interpreter/execution_errors.rb +7 -4
  67. data/lib/graphql/execution/interpreter/handles_raw_value.rb +6 -2
  68. data/lib/graphql/execution/interpreter/resolve.rb +6 -2
  69. data/lib/graphql/execution/interpreter/runtime/graphql_result.rb +1 -0
  70. data/lib/graphql/execution/interpreter/runtime.rb +14 -8
  71. data/lib/graphql/execution/interpreter.rb +7 -4
  72. data/lib/graphql/execution/lazy/lazy_method_map.rb +1 -0
  73. data/lib/graphql/execution/lazy.rb +1 -0
  74. data/lib/graphql/execution/load_argument_step.rb +1 -0
  75. data/lib/graphql/execution/lookahead.rb +21 -8
  76. data/lib/graphql/execution/multiplex.rb +1 -0
  77. data/lib/graphql/execution/next.rb +2 -0
  78. data/lib/graphql/execution/prepare_object_step.rb +3 -5
  79. data/lib/graphql/execution/resolve_type_step.rb +1 -0
  80. data/lib/graphql/execution/runner.rb +21 -12
  81. data/lib/graphql/execution/selections_step.rb +2 -1
  82. data/lib/graphql/execution/variable_values.rb +262 -0
  83. data/lib/graphql/execution.rb +1 -0
  84. data/lib/graphql/execution_error.rb +1 -0
  85. data/lib/graphql/float_decoding_error.rb +4 -1
  86. data/lib/graphql/float_encoding_error.rb +1 -0
  87. data/lib/graphql/integer_decoding_error.rb +4 -1
  88. data/lib/graphql/integer_encoding_error.rb +1 -0
  89. data/lib/graphql/introspection/base_object.rb +2 -1
  90. data/lib/graphql/introspection/directive_location_enum.rb +2 -1
  91. data/lib/graphql/introspection/directive_type.rb +4 -1
  92. data/lib/graphql/introspection/dynamic_fields.rb +4 -1
  93. data/lib/graphql/introspection/entry_points.rb +1 -0
  94. data/lib/graphql/introspection/enum_value_type.rb +4 -1
  95. data/lib/graphql/introspection/field_type.rb +6 -1
  96. data/lib/graphql/introspection/input_value_type.rb +1 -0
  97. data/lib/graphql/introspection/introspection_query.rb +10 -7
  98. data/lib/graphql/introspection/schema_type.rb +1 -0
  99. data/lib/graphql/introspection/type_kind_enum.rb +2 -1
  100. data/lib/graphql/introspection/type_type.rb +1 -0
  101. data/lib/graphql/introspection.rb +3 -1
  102. data/lib/graphql/invalid_name_error.rb +1 -0
  103. data/lib/graphql/invalid_null_error.rb +1 -0
  104. data/lib/graphql/language/block_string.rb +12 -5
  105. data/lib/graphql/language/cache.rb +1 -0
  106. data/lib/graphql/language/comment.rb +3 -1
  107. data/lib/graphql/language/definition_slice.rb +1 -0
  108. data/lib/graphql/language/document_from_schema_definition.rb +1 -0
  109. data/lib/graphql/language/generation.rb +3 -1
  110. data/lib/graphql/language/lexer.rb +33 -25
  111. data/lib/graphql/language/nodes.rb +1 -0
  112. data/lib/graphql/language/parser.rb +11 -7
  113. data/lib/graphql/language/printer.rb +1 -0
  114. data/lib/graphql/language/sanitized_printer.rb +1 -0
  115. data/lib/graphql/language/static_visitor.rb +1 -0
  116. data/lib/graphql/language/visitor.rb +1 -0
  117. data/lib/graphql/language.rb +2 -1
  118. data/lib/graphql/load_application_object_failed_error.rb +1 -0
  119. data/lib/graphql/name_validator.rb +3 -1
  120. data/lib/graphql/pagination/active_record_relation_connection.rb +9 -1
  121. data/lib/graphql/pagination/array_connection.rb +1 -0
  122. data/lib/graphql/pagination/connection.rb +1 -0
  123. data/lib/graphql/pagination/connections.rb +1 -0
  124. data/lib/graphql/pagination/mongoid_relation_connection.rb +6 -1
  125. data/lib/graphql/pagination/relation_connection.rb +5 -4
  126. data/lib/graphql/pagination/sequel_dataset_connection.rb +6 -1
  127. data/lib/graphql/pagination.rb +2 -1
  128. data/lib/graphql/parse_error.rb +1 -0
  129. data/lib/graphql/query/context/scoped_context.rb +1 -0
  130. data/lib/graphql/query/context.rb +1 -0
  131. data/lib/graphql/query/fingerprint.rb +3 -1
  132. data/lib/graphql/query/input_validation_result.rb +44 -0
  133. data/lib/graphql/query/null_context.rb +1 -0
  134. data/lib/graphql/query/partial.rb +5 -0
  135. data/lib/graphql/query/result.rb +1 -0
  136. data/lib/graphql/query/validation_pipeline.rb +1 -0
  137. data/lib/graphql/query/variable_validation_error.rb +1 -0
  138. data/lib/graphql/query.rb +9 -12
  139. data/lib/graphql/railtie.rb +2 -1
  140. data/lib/graphql/rake_task/validate.rb +1 -0
  141. data/lib/graphql/rake_task.rb +1 -0
  142. data/lib/graphql/relay/range_add.rb +1 -0
  143. data/lib/graphql/relay.rb +2 -1
  144. data/lib/graphql/rubocop/graphql/base_cop.rb +1 -0
  145. data/lib/graphql/rubocop/graphql/default_null_true.rb +1 -0
  146. data/lib/graphql/rubocop/graphql/default_required_true.rb +1 -0
  147. data/lib/graphql/rubocop/graphql/field_type_in_block.rb +1 -0
  148. data/lib/graphql/rubocop/graphql/root_types_in_block.rb +1 -0
  149. data/lib/graphql/rubocop.rb +2 -1
  150. data/lib/graphql/runtime_error.rb +2 -1
  151. data/lib/graphql/runtime_type_error.rb +2 -1
  152. data/lib/graphql/schema/addition.rb +1 -0
  153. data/lib/graphql/schema/always_visible.rb +4 -1
  154. data/lib/graphql/schema/argument.rb +1 -0
  155. data/lib/graphql/schema/base_64_encoder.rb +4 -1
  156. data/lib/graphql/schema/build_from_definition/resolve_map/default_resolve.rb +6 -3
  157. data/lib/graphql/schema/build_from_definition/resolve_map.rb +1 -0
  158. data/lib/graphql/schema/build_from_definition.rb +1 -0
  159. data/lib/graphql/schema/built_in_types.rb +3 -2
  160. data/lib/graphql/schema/directive/deprecated.rb +2 -1
  161. data/lib/graphql/schema/directive/feature.rb +1 -0
  162. data/lib/graphql/schema/directive/flagged.rb +5 -1
  163. data/lib/graphql/schema/directive/include.rb +3 -1
  164. data/lib/graphql/schema/directive/one_of.rb +5 -2
  165. data/lib/graphql/schema/directive/skip.rb +3 -1
  166. data/lib/graphql/schema/directive/specified_by.rb +2 -1
  167. data/lib/graphql/schema/directive/transform.rb +9 -4
  168. data/lib/graphql/schema/directive.rb +1 -0
  169. data/lib/graphql/schema/enum.rb +1 -0
  170. data/lib/graphql/schema/enum_value.rb +1 -0
  171. data/lib/graphql/schema/field/connection_extension.rb +6 -2
  172. data/lib/graphql/schema/field/scope_extension.rb +3 -1
  173. data/lib/graphql/schema/field.rb +4 -0
  174. data/lib/graphql/schema/field_extension.rb +1 -0
  175. data/lib/graphql/schema/find_inherited_value.rb +6 -1
  176. data/lib/graphql/schema/finder.rb +1 -0
  177. data/lib/graphql/schema/has_single_input_argument.rb +1 -0
  178. data/lib/graphql/schema/input_object.rb +1 -0
  179. data/lib/graphql/schema/interface.rb +1 -0
  180. data/lib/graphql/schema/introspection_system.rb +1 -0
  181. data/lib/graphql/schema/late_bound_type.rb +1 -0
  182. data/lib/graphql/schema/list.rb +1 -0
  183. data/lib/graphql/schema/loader.rb +1 -0
  184. data/lib/graphql/schema/member/base_dsl_methods.rb +1 -0
  185. data/lib/graphql/schema/member/build_type.rb +1 -0
  186. data/lib/graphql/schema/member/graphql_type_names.rb +2 -1
  187. data/lib/graphql/schema/member/has_arguments.rb +1 -0
  188. data/lib/graphql/schema/member/has_ast_node.rb +7 -2
  189. data/lib/graphql/schema/member/has_authorization.rb +7 -4
  190. data/lib/graphql/schema/member/has_dataloader.rb +1 -0
  191. data/lib/graphql/schema/member/has_deprecation_reason.rb +7 -2
  192. data/lib/graphql/schema/member/has_directives.rb +21 -22
  193. data/lib/graphql/schema/member/has_fields.rb +1 -0
  194. data/lib/graphql/schema/member/has_interfaces.rb +1 -0
  195. data/lib/graphql/schema/member/has_path.rb +3 -1
  196. data/lib/graphql/schema/member/has_unresolved_type_error.rb +3 -1
  197. data/lib/graphql/schema/member/has_validators.rb +1 -0
  198. data/lib/graphql/schema/member/relay_shortcuts.rb +1 -0
  199. data/lib/graphql/schema/member/scoped.rb +7 -3
  200. data/lib/graphql/schema/member/type_system_helpers.rb +1 -0
  201. data/lib/graphql/schema/member/validates_input.rb +7 -1
  202. data/lib/graphql/schema/member.rb +4 -2
  203. data/lib/graphql/schema/mutation.rb +7 -1
  204. data/lib/graphql/schema/non_null.rb +1 -0
  205. data/lib/graphql/schema/object.rb +2 -1
  206. data/lib/graphql/schema/printer.rb +1 -0
  207. data/lib/graphql/schema/ractor_shareable.rb +1 -0
  208. data/lib/graphql/schema/relay_classic_mutation.rb +8 -3
  209. data/lib/graphql/schema/resolver/has_payload_type.rb +1 -0
  210. data/lib/graphql/schema/resolver.rb +5 -3
  211. data/lib/graphql/schema/scalar.rb +27 -3
  212. data/lib/graphql/schema/subscription.rb +1 -0
  213. data/lib/graphql/schema/timeout.rb +1 -0
  214. data/lib/graphql/schema/type_expression.rb +4 -1
  215. data/lib/graphql/schema/type_membership.rb +1 -0
  216. data/lib/graphql/schema/union.rb +1 -0
  217. data/lib/graphql/schema/unique_within_type.rb +1 -0
  218. data/lib/graphql/schema/validator/all_validator.rb +7 -3
  219. data/lib/graphql/schema/validator/allow_blank_validator.rb +5 -2
  220. data/lib/graphql/schema/validator/allow_null_validator.rb +6 -3
  221. data/lib/graphql/schema/validator/exclusion_validator.rb +7 -4
  222. data/lib/graphql/schema/validator/format_validator.rb +7 -4
  223. data/lib/graphql/schema/validator/inclusion_validator.rb +6 -3
  224. data/lib/graphql/schema/validator/length_validator.rb +1 -0
  225. data/lib/graphql/schema/validator/numericality_validator.rb +1 -0
  226. data/lib/graphql/schema/validator/required_validator.rb +1 -0
  227. data/lib/graphql/schema/validator.rb +3 -2
  228. data/lib/graphql/schema/visibility/migration.rb +1 -0
  229. data/lib/graphql/schema/visibility/profile.rb +1 -0
  230. data/lib/graphql/schema/visibility/visit.rb +1 -0
  231. data/lib/graphql/schema/visibility.rb +1 -0
  232. data/lib/graphql/schema/warden.rb +1 -0
  233. data/lib/graphql/schema/wrapper.rb +1 -0
  234. data/lib/graphql/schema.rb +1 -0
  235. data/lib/graphql/static_validation/all_rules.rb +2 -1
  236. data/lib/graphql/static_validation/base_visitor.rb +126 -53
  237. data/lib/graphql/static_validation/definition_dependencies.rb +15 -2
  238. data/lib/graphql/static_validation/error.rb +14 -5
  239. data/lib/graphql/static_validation/interpreter_visitor.rb +2 -1
  240. data/lib/graphql/static_validation/rules/argument_literals_are_compatible.rb +9 -3
  241. data/lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb +16 -8
  242. data/lib/graphql/static_validation/rules/argument_names_are_unique.rb +5 -1
  243. data/lib/graphql/static_validation/rules/argument_names_are_unique_error.rb +8 -3
  244. data/lib/graphql/static_validation/rules/arguments_are_defined.rb +10 -4
  245. data/lib/graphql/static_validation/rules/arguments_are_defined_error.rb +14 -6
  246. data/lib/graphql/static_validation/rules/directives_are_defined.rb +7 -9
  247. data/lib/graphql/static_validation/rules/directives_are_defined_error.rb +8 -3
  248. data/lib/graphql/static_validation/rules/directives_are_in_valid_locations.rb +14 -7
  249. data/lib/graphql/static_validation/rules/directives_are_in_valid_locations_error.rb +10 -4
  250. data/lib/graphql/static_validation/rules/fields_are_defined_on_type.rb +9 -4
  251. data/lib/graphql/static_validation/rules/fields_are_defined_on_type_error.rb +10 -4
  252. data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +1 -0
  253. data/lib/graphql/static_validation/rules/fields_have_appropriate_selections_error.rb +10 -4
  254. data/lib/graphql/static_validation/rules/fields_will_merge.rb +2 -3
  255. data/lib/graphql/static_validation/rules/fields_will_merge_error.rb +15 -4
  256. data/lib/graphql/static_validation/rules/fragment_names_are_unique.rb +10 -5
  257. data/lib/graphql/static_validation/rules/fragment_names_are_unique_error.rb +8 -3
  258. data/lib/graphql/static_validation/rules/fragment_spreads_are_possible.rb +30 -14
  259. data/lib/graphql/static_validation/rules/fragment_spreads_are_possible_error.rb +12 -5
  260. data/lib/graphql/static_validation/rules/fragment_types_exist.rb +11 -6
  261. data/lib/graphql/static_validation/rules/fragment_types_exist_error.rb +8 -3
  262. data/lib/graphql/static_validation/rules/fragments_are_finite.rb +3 -1
  263. data/lib/graphql/static_validation/rules/fragments_are_finite_error.rb +8 -3
  264. data/lib/graphql/static_validation/rules/fragments_are_named.rb +3 -1
  265. data/lib/graphql/static_validation/rules/fragments_are_named_error.rb +5 -1
  266. data/lib/graphql/static_validation/rules/fragments_are_on_composite_types.rb +7 -3
  267. data/lib/graphql/static_validation/rules/fragments_are_on_composite_types_error.rb +8 -4
  268. data/lib/graphql/static_validation/rules/fragments_are_used.rb +3 -1
  269. data/lib/graphql/static_validation/rules/fragments_are_used_error.rb +8 -3
  270. data/lib/graphql/static_validation/rules/input_object_names_are_unique.rb +4 -1
  271. data/lib/graphql/static_validation/rules/input_object_names_are_unique_error.rb +8 -3
  272. data/lib/graphql/static_validation/rules/mutation_root_exists.rb +4 -2
  273. data/lib/graphql/static_validation/rules/mutation_root_exists_error.rb +5 -1
  274. data/lib/graphql/static_validation/rules/no_definitions_are_present.rb +7 -3
  275. data/lib/graphql/static_validation/rules/no_definitions_are_present_error.rb +5 -1
  276. data/lib/graphql/static_validation/rules/not_single_subscription_error.rb +5 -1
  277. data/lib/graphql/static_validation/rules/one_of_input_objects_are_valid.rb +19 -6
  278. data/lib/graphql/static_validation/rules/one_of_input_objects_are_valid_error.rb +7 -2
  279. data/lib/graphql/static_validation/rules/operation_names_are_valid.rb +10 -4
  280. data/lib/graphql/static_validation/rules/operation_names_are_valid_error.rb +7 -2
  281. data/lib/graphql/static_validation/rules/query_root_exists.rb +4 -2
  282. data/lib/graphql/static_validation/rules/query_root_exists_error.rb +5 -1
  283. data/lib/graphql/static_validation/rules/required_arguments_are_present.rb +19 -10
  284. data/lib/graphql/static_validation/rules/required_arguments_are_present_error.rb +12 -5
  285. data/lib/graphql/static_validation/rules/required_input_object_attributes_are_present.rb +5 -1
  286. data/lib/graphql/static_validation/rules/required_input_object_attributes_are_present_error.rb +11 -4
  287. data/lib/graphql/static_validation/rules/subscription_root_exists_and_single_subscription_selection.rb +9 -6
  288. data/lib/graphql/static_validation/rules/subscription_root_exists_error.rb +5 -1
  289. data/lib/graphql/static_validation/rules/unique_directives_per_location.rb +7 -5
  290. data/lib/graphql/static_validation/rules/unique_directives_per_location_error.rb +8 -3
  291. data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed.rb +3 -1
  292. data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed_error.rb +13 -6
  293. data/lib/graphql/static_validation/rules/variable_names_are_unique.rb +3 -1
  294. data/lib/graphql/static_validation/rules/variable_names_are_unique_error.rb +8 -3
  295. data/lib/graphql/static_validation/rules/variable_usages_are_allowed.rb +17 -9
  296. data/lib/graphql/static_validation/rules/variable_usages_are_allowed_error.rb +14 -6
  297. data/lib/graphql/static_validation/rules/variables_are_input_types.rb +9 -6
  298. data/lib/graphql/static_validation/rules/variables_are_input_types_error.rb +10 -4
  299. data/lib/graphql/static_validation/rules/variables_are_used_and_defined.rb +1 -0
  300. data/lib/graphql/static_validation/rules/variables_are_used_and_defined_error.rb +11 -5
  301. data/lib/graphql/static_validation/validation_context.rb +52 -14
  302. data/lib/graphql/static_validation/validation_timeout_error.rb +5 -1
  303. data/lib/graphql/static_validation/validator.rb +7 -3
  304. data/lib/graphql/static_validation.rb +2 -2
  305. data/lib/graphql/string_encoding_error.rb +1 -0
  306. data/lib/graphql/subscriptions/action_cable_subscriptions.rb +15 -13
  307. data/lib/graphql/subscriptions/broadcast_analyzer.rb +1 -0
  308. data/lib/graphql/subscriptions/default_subscription_resolve_extension.rb +1 -0
  309. data/lib/graphql/subscriptions/event.rb +1 -0
  310. data/lib/graphql/subscriptions/serialize.rb +1 -0
  311. data/lib/graphql/subscriptions.rb +1 -0
  312. data/lib/graphql/testing/helpers.rb +1 -0
  313. data/lib/graphql/testing/mock_action_cable.rb +1 -0
  314. data/lib/graphql/testing.rb +2 -1
  315. data/lib/graphql/tracing/active_support_notifications_trace.rb +1 -0
  316. data/lib/graphql/tracing/active_support_notifications_tracing.rb +1 -0
  317. data/lib/graphql/tracing/appoptics_trace.rb +1 -0
  318. data/lib/graphql/tracing/appoptics_tracing.rb +1 -0
  319. data/lib/graphql/tracing/appsignal_trace.rb +1 -0
  320. data/lib/graphql/tracing/appsignal_tracing.rb +1 -0
  321. data/lib/graphql/tracing/call_legacy_tracers.rb +1 -0
  322. data/lib/graphql/tracing/data_dog_trace.rb +1 -0
  323. data/lib/graphql/tracing/data_dog_tracing.rb +1 -0
  324. data/lib/graphql/tracing/detailed_trace/active_record_backend.rb +1 -0
  325. data/lib/graphql/tracing/detailed_trace/memory_backend.rb +1 -0
  326. data/lib/graphql/tracing/detailed_trace/redis_backend.rb +1 -0
  327. data/lib/graphql/tracing/detailed_trace.rb +1 -0
  328. data/lib/graphql/tracing/legacy_hooks_trace.rb +1 -0
  329. data/lib/graphql/tracing/legacy_trace.rb +2 -1
  330. data/lib/graphql/tracing/monitor_trace.rb +1 -0
  331. data/lib/graphql/tracing/new_relic_trace.rb +1 -0
  332. data/lib/graphql/tracing/new_relic_tracing.rb +1 -0
  333. data/lib/graphql/tracing/notifications_trace.rb +1 -0
  334. data/lib/graphql/tracing/notifications_tracing.rb +1 -0
  335. data/lib/graphql/tracing/null_trace.rb +2 -1
  336. data/lib/graphql/tracing/perfetto_trace/trace_pb.rb +1 -0
  337. data/lib/graphql/tracing/perfetto_trace.rb +1 -0
  338. data/lib/graphql/tracing/platform_trace.rb +1 -0
  339. data/lib/graphql/tracing/platform_tracing.rb +1 -0
  340. data/lib/graphql/tracing/prometheus_trace/graphql_collector.rb +1 -0
  341. data/lib/graphql/tracing/prometheus_trace.rb +1 -0
  342. data/lib/graphql/tracing/prometheus_tracing.rb +1 -0
  343. data/lib/graphql/tracing/scout_trace.rb +1 -0
  344. data/lib/graphql/tracing/scout_tracing.rb +1 -0
  345. data/lib/graphql/tracing/sentry_trace.rb +1 -0
  346. data/lib/graphql/tracing/statsd_trace.rb +1 -0
  347. data/lib/graphql/tracing/statsd_tracing.rb +1 -0
  348. data/lib/graphql/tracing/trace.rb +1 -0
  349. data/lib/graphql/tracing.rb +1 -0
  350. data/lib/graphql/type_kinds.rb +1 -0
  351. data/lib/graphql/types/big_int.rb +5 -1
  352. data/lib/graphql/types/boolean.rb +4 -1
  353. data/lib/graphql/types/float.rb +4 -1
  354. data/lib/graphql/types/id.rb +4 -1
  355. data/lib/graphql/types/int.rb +6 -3
  356. data/lib/graphql/types/iso_8601_date.rb +4 -1
  357. data/lib/graphql/types/iso_8601_date_time.rb +7 -2
  358. data/lib/graphql/types/iso_8601_duration.rb +7 -2
  359. data/lib/graphql/types/json.rb +4 -1
  360. data/lib/graphql/types/relay/base_connection.rb +2 -1
  361. data/lib/graphql/types/relay/base_edge.rb +2 -1
  362. data/lib/graphql/types/relay/connection_behaviors.rb +1 -2
  363. data/lib/graphql/types/relay/edge_behaviors.rb +1 -2
  364. data/lib/graphql/types/relay/has_node_field.rb +7 -1
  365. data/lib/graphql/types/relay/has_nodes_field.rb +7 -1
  366. data/lib/graphql/types/relay/node.rb +2 -1
  367. data/lib/graphql/types/relay/node_behaviors.rb +7 -1
  368. data/lib/graphql/types/relay/page_info.rb +2 -1
  369. data/lib/graphql/types/relay/page_info_behaviors.rb +5 -1
  370. data/lib/graphql/types/relay.rb +2 -1
  371. data/lib/graphql/types/string.rb +4 -1
  372. data/lib/graphql/types.rb +2 -1
  373. data/lib/graphql/unauthorized_enum_value_error.rb +1 -0
  374. data/lib/graphql/unauthorized_error.rb +1 -0
  375. data/lib/graphql/unauthorized_field_error.rb +1 -0
  376. data/lib/graphql/unresolved_type_error.rb +1 -0
  377. data/lib/graphql/version.rb +3 -2
  378. data/lib/graphql.rb +1 -0
  379. metadata +3 -4
  380. data/lib/graphql/query/variables.rb +0 -99
  381. data/lib/graphql/static_validation/literal_validator.rb +0 -157
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ #--
2
3
  # typed: true
3
4
  module GraphQL
4
5
  # This error is raised when `Types::Float` is asked to return a non-finite value.
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
- # typed: true
2
+ #--
3
+ # typed: strict
3
4
  module GraphQL
4
5
  # This error is raised when `Types::Int` is given an input value outside of 32-bit integer range.
5
6
  #
@@ -8,8 +9,10 @@ module GraphQL
8
9
  # See [GraphQL::Types::Int](rdoc-ref:GraphQL::Types::Int) which raises this error
9
10
  class IntegerDecodingError < GraphQL::RuntimeTypeError
10
11
  # The value which couldn't be decoded
12
+ #: Integer
11
13
  attr_reader :integer_value
12
14
 
15
+ #: (Integer value) -> void
13
16
  def initialize(value)
14
17
  @integer_value = value
15
18
  super("Integer out of bounds: #{value}. \nConsider using GraphQL::Types::BigInt instead.")
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ #--
2
3
  # typed: true
3
4
  module GraphQL
4
5
  # This error is raised when `Types::Int` is asked to return a value outside of 32-bit integer range.
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
- # typed: true
2
+ #--
3
+ # typed: strict
3
4
  module GraphQL
4
5
  module Introspection
5
6
  class BaseObject < GraphQL::Schema::Object
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
- # typed: true
2
+ #--
3
+ # typed: strict
3
4
  module GraphQL
4
5
  module Introspection
5
6
  class DirectiveLocationEnum < GraphQL::Schema::Enum
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
- # typed: true
2
+ #--
3
+ # typed: strict
3
4
  module GraphQL
4
5
  module Introspection
5
6
  class DirectiveType < Introspection::BaseObject
@@ -22,12 +23,14 @@ module GraphQL
22
23
 
23
24
  field :is_repeatable, Boolean, method: :repeatable?
24
25
 
26
+ #: (singleton(GraphQL::Schema::Directive) object, GraphQL::Query::Context context, include_deprecated: bool) -> Array[GraphQL::Schema::Argument]
25
27
  def self.resolve_args(object, context, include_deprecated:)
26
28
  args = context.types.arguments(object)
27
29
  args = args.reject(&:deprecation_reason) unless include_deprecated
28
30
  args
29
31
  end
30
32
 
33
+ #: (include_deprecated: bool) -> Array[GraphQL::Schema::Argument]
31
34
  def args(include_deprecated:)
32
35
  self.class.resolve_args(object, context, include_deprecated: include_deprecated)
33
36
  end
@@ -1,14 +1,17 @@
1
1
  # frozen_string_literal: true
2
- # typed: true
2
+ #--
3
+ # typed: strict
3
4
  module GraphQL
4
5
  module Introspection
5
6
  class DynamicFields < Introspection::BaseObject
6
7
  field :__typename, String, "The name of this type", null: false, dynamic_introspection: true, resolve_each: true
7
8
 
9
+ #: -> ::String
8
10
  def __typename
9
11
  self.class.__typename(object, context)
10
12
  end
11
13
 
14
+ #: (untyped object, GraphQL::Query::Context context) -> ::String
12
15
  def self.__typename(object, context)
13
16
  object.class.graphql_name
14
17
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ #--
2
3
  # typed: true
3
4
  module GraphQL
4
5
  module Introspection
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
- # typed: true
2
+ #--
3
+ # typed: strict
3
4
  module GraphQL
4
5
  module Introspection
5
6
  class EnumValueType < Introspection::BaseObject
@@ -12,10 +13,12 @@ module GraphQL
12
13
  field :is_deprecated, Boolean, null: false, resolve_each: :resolve_is_deprecated
13
14
  field :deprecation_reason, String
14
15
 
16
+ #: (GraphQL::Schema::EnumValue object, GraphQL::Query::Context context) -> bool
15
17
  def self.resolve_is_deprecated(object, context)
16
18
  !!object.deprecation_reason
17
19
  end
18
20
 
21
+ #: -> bool
19
22
  def is_deprecated
20
23
  self.class.resolve_is_deprecated(object, context)
21
24
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
- # typed: true
2
+ #--
3
+ # typed: strict
3
4
  module GraphQL
4
5
  module Introspection
5
6
  class FieldType < Introspection::BaseObject
@@ -15,20 +16,24 @@ module GraphQL
15
16
  field :is_deprecated, Boolean, null: false, resolve_each: :resolve_is_deprecated
16
17
  field :deprecation_reason, String
17
18
 
19
+ #: (GraphQL::Schema::Field object, GraphQL::Query::Context _context) -> bool
18
20
  def self.resolve_is_deprecated(object, _context)
19
21
  !!object.deprecation_reason
20
22
  end
21
23
 
24
+ #: -> bool
22
25
  def is_deprecated
23
26
  self.class.resolve_is_deprecated(object, context)
24
27
  end
25
28
 
29
+ #: (GraphQL::Schema::Field object, GraphQL::Query::Context context, include_deprecated: bool) -> Array[GraphQL::Schema::Argument]
26
30
  def self.resolve_args(object, context, include_deprecated:)
27
31
  args = context.types.arguments(object)
28
32
  args = args.reject(&:deprecation_reason) unless include_deprecated
29
33
  args
30
34
  end
31
35
 
36
+ #: (include_deprecated: bool) -> Array[GraphQL::Schema::Argument]
32
37
  def args(include_deprecated:)
33
38
  self.class.resolve_args(object, context, include_deprecated: include_deprecated)
34
39
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ #--
2
3
  # typed: true
3
4
  module GraphQL
4
5
  module Introspection
@@ -1,8 +1,11 @@
1
1
  # frozen_string_literal: true
2
- # typed: true
3
-
4
- # This query is used by graphql-client so don't add the includeDeprecated
5
- # argument for inputFields since the server may not support it. Two stage
6
- # introspection queries will be required to handle this in clients.
7
- GraphQL::Introspection::INTROSPECTION_QUERY = GraphQL::Introspection.query
8
-
2
+ #--
3
+ # typed: strict
4
+ module GraphQL
5
+ module Introspection
6
+ # This query is used by graphql-client so don't add the includeDeprecated
7
+ # argument for inputFields since the server may not support it. Two stage
8
+ # introspection queries will be required to handle this in clients.
9
+ INTROSPECTION_QUERY = GraphQL::Introspection.query #: String
10
+ end
11
+ end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ #--
2
3
  # typed: true
3
4
 
4
5
  module GraphQL
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
- # typed: true
2
+ #--
3
+ # typed: strict
3
4
  module GraphQL
4
5
  module Introspection
5
6
  class TypeKindEnum < GraphQL::Schema::Enum
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ #--
2
3
  # typed: true
3
4
  module GraphQL
4
5
  module Introspection
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
- # typed: true
2
+ #--
3
+ # typed: strict
3
4
  module GraphQL
4
5
  module Introspection
6
+ #: (?include_deprecated_args: bool, ?include_schema_description: bool, ?include_is_repeatable: bool, ?include_specified_by_url: bool, ?include_is_one_of: bool) -> String
5
7
  def self.query(include_deprecated_args: false, include_schema_description: false, include_is_repeatable: false, include_specified_by_url: false, include_is_one_of: false)
6
8
  # The introspection query to end all introspection queries, copied from
7
9
  # https://github.com/graphql/graphql-js/blob/master/src/utilities/introspectionQuery.js
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ #--
2
3
  # typed: true
3
4
  module GraphQL
4
5
  class InvalidNameError < GraphQL::Error
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ #--
2
3
  # typed: true
3
4
  module GraphQL
4
5
  # Raised automatically when a field's resolve function returns `nil`
@@ -1,10 +1,12 @@
1
1
  # frozen_string_literal: true
2
- # typed: true
2
+ #--
3
+ # typed: strict
3
4
  module GraphQL
4
5
  module Language
5
6
  module BlockString
6
7
  # Remove leading and trailing whitespace from a block string.
7
8
  # See "Block Strings" in https://github.com/facebook/graphql/blob/master/spec/Section%202%20--%20Language.md
9
+ #: (String str) -> String
8
10
  def self.trim_whitespace(str)
9
11
  # Early return for the most common cases:
10
12
  if str == ""
@@ -43,10 +45,10 @@ module GraphQL
43
45
  end
44
46
 
45
47
  # Remove leading & trailing blank lines
46
- while lines.size > 0 && contains_only_whitespace?(lines.first)
48
+ while (first_line = lines.first) && contains_only_whitespace?(first_line)
47
49
  lines.shift
48
50
  end
49
- while lines.size > 0 && contains_only_whitespace?(lines.last)
51
+ while (last_line = lines.last) && contains_only_whitespace?(last_line)
50
52
  lines.pop
51
53
  end
52
54
 
@@ -54,6 +56,7 @@ module GraphQL
54
56
  lines.size > 1 ? lines.join("\n") : (lines.first || "".dup)
55
57
  end
56
58
 
59
+ #: (String str, ?indent: String) -> String
57
60
  def self.print(str, indent: '')
58
61
  line_length = 120 - indent.length
59
62
  block_str = "".dup
@@ -87,13 +90,16 @@ module GraphQL
87
90
 
88
91
  private
89
92
 
90
- def self.break_line(line, length)
93
+ #: (String line, Integer length) { (String) -> void } -> void
94
+ def self.break_line(line, length, &block)
91
95
  return yield(line) if line.length < length + 5
92
96
 
93
97
  parts = line.split(Regexp.new("((?: |^).{15,#{length - 40}}(?= |$))"))
94
98
  return yield(line) if parts.length < 4
95
99
 
96
- yield(parts.slice!(0, 3).join)
100
+ # `parts` has at least 4 items:
101
+ first_parts = parts.slice!(0, 3) #: as !nil
102
+ yield(first_parts.join)
97
103
 
98
104
  parts.each_with_index do |part, i|
99
105
  next if i % 2 == 1
@@ -103,6 +109,7 @@ module GraphQL
103
109
  nil
104
110
  end
105
111
 
112
+ #: (String line) -> bool
106
113
  def self.contains_only_whitespace?(line)
107
114
  line.match?(/^\s*$/)
108
115
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ #--
2
3
  # typed: true
3
4
 
4
5
  require 'graphql/version'
@@ -1,8 +1,10 @@
1
1
  # frozen_string_literal: true
2
- # typed: true
2
+ #--
3
+ # typed: strict
3
4
  module GraphQL
4
5
  module Language
5
6
  module Comment
7
+ #: (String str, ?indent: String) -> String
6
8
  def self.print(str, indent: '')
7
9
  lines = str.split("\n").map do |line|
8
10
  comment_str = "".dup
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ #--
2
3
  # typed: true
3
4
  module GraphQL
4
5
  module Language
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ #--
2
3
  # typed: true
3
4
  module GraphQL
4
5
  module Language
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
- # typed: true
2
+ #--
3
+ # typed: strict
3
4
  module GraphQL
4
5
  module Language
5
6
  # Exposes [.generate](rdoc-ref:.generate), which turns AST nodes back into query strings.
@@ -30,6 +31,7 @@ module GraphQL
30
31
  #
31
32
  # :call-seq:
32
33
  # generate(GraphQL::Language::Nodes::AbstractNode node, String indent:, GraphQL::Language::Printer printer:) -> String
34
+ #: (GraphQL::Language::Nodes::AbstractNode node, ?indent: String, ?printer: GraphQL::Language::Printer) -> String
33
35
  def generate(node, indent: "", printer: GraphQL::Language::Printer.new)
34
36
  printer.print(node, indent: indent)
35
37
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ #--
2
3
  # typed: true
3
4
  module GraphQL
4
5
  module Language
@@ -32,17 +33,16 @@ module GraphQL
32
33
  attr_reader :pos, :tokens_count
33
34
 
34
35
  def advance
35
- loop do
36
- @scanner.skip(IGNORE_REGEXP)
37
- if @scanner.skip(COMMENT_REGEXP)
38
- @tokens_count += 1
39
- if @tokens_count > @max_tokens
40
- @pos = @scanner.pos
41
- raise_parse_error("This query is too large to execute.")
42
- end
43
- next
36
+ @scanner.skip(IGNORE_REGEXP)
37
+ # A failed skip clears matched_size, which debug_token_value relies on for UNKNOWN_CHAR.
38
+ while @scanner.skip("#")
39
+ @scanner.skip(COMMENT_BODY_REGEXP)
40
+ @tokens_count += 1
41
+ if @tokens_count > @max_tokens
42
+ @pos = @scanner.pos
43
+ raise_parse_error("This query is too large to execute.")
44
44
  end
45
- break
45
+ @scanner.skip(IGNORE_REGEXP)
46
46
  end
47
47
 
48
48
  if @scanner.eos?
@@ -50,10 +50,10 @@ module GraphQL
50
50
  return false
51
51
  end
52
52
  @tokens_count += 1
53
+ @pos = @scanner.pos
53
54
  if @tokens_count > @max_tokens
54
55
  raise_parse_error("This query is too large to execute.")
55
56
  end
56
- @pos = @scanner.pos
57
57
  next_byte = @string.getbyte(@pos)
58
58
  next_byte_is_for = FIRST_BYTES[next_byte]
59
59
  case next_byte_is_for
@@ -82,11 +82,12 @@ module GraphQL
82
82
  @scanner.skip(IDENTIFIER_REGEXP)
83
83
  :IDENTIFIER
84
84
  when ByteFor::NUMBER
85
- if len = @scanner.skip(NUMERIC_REGEXP)
86
-
87
- if GraphQL.reject_numbers_followed_by_names
88
- new_pos = @scanner.pos
89
- peek_byte = @string.getbyte(new_pos)
85
+ if @scanner.skip(NUMERIC_REGEXP)
86
+ peek_byte = @string.getbyte(@scanner.pos)
87
+ if peek_byte == 46 || (peek_byte && peek_byte >= 48 && peek_byte <= 57)
88
+ raise_parse_error("Invalid number: unexpected character #{peek_byte.chr.inspect}")
89
+ end
90
+ if peek_byte && GraphQL.reject_numbers_followed_by_names
90
91
  next_first_byte = FIRST_BYTES[peek_byte]
91
92
  if next_first_byte == ByteFor::NAME || next_first_byte == ByteFor::IDENTIFIER
92
93
  number_part = token_value
@@ -152,7 +153,9 @@ module GraphQL
152
153
  "\\t" => "\t",
153
154
  }
154
155
  UTF_8 = /\\u(?:([\da-f]{4})|\{([\da-f]+)\})(?:\\u([\da-f]{4}))?/i
155
- VALID_STRING = /\A(?:[^\\]|#{ESCAPES}|#{UTF_8})*\z/o
156
+ # Surrogate pairs are combined by `UTF_8` during replacement; validating each escape alone keeps this unambiguous, so it can't backtrack exponentially.
157
+ VALID_UTF_8 = /\\u(?:[\da-f]{4}|\{[\da-f]+\})/i
158
+ VALID_STRING = /\A(?:[^\\]|#{ESCAPES}|#{VALID_UTF_8})*\z/o
156
159
  ESCAPED = /(?:#{ESCAPES}|#{UTF_8})/o
157
160
 
158
161
  def string_value
@@ -183,13 +186,20 @@ module GraphQL
183
186
  end
184
187
 
185
188
  def line_number
186
- @scanner.string.byteslice(0, @pos).b.count("\n".b) + 1
189
+ line_prefix = @scanner.string.byteslice(0, @pos).b
190
+ line_number = line_prefix.count("\r") + line_prefix.count("\n") + 1
191
+ offset = 0 #: Integer?
192
+ while (offset = line_prefix.index("\r\n", offset))
193
+ line_number -= 1
194
+ offset += 2
195
+ end
196
+ line_number
187
197
  end
188
198
 
189
199
  def column_number
190
200
  line_prefix = @scanner.string.byteslice(0, @pos)
191
201
  line_prefix = line_prefix.b unless line_prefix.valid_encoding?
192
- newline_index = line_prefix.rindex("\n")
202
+ newline_index = line_prefix.rindex(/[\r\n]/)
193
203
  newline_index ? line_prefix.length - newline_index : line_prefix.length + 1
194
204
  end
195
205
 
@@ -198,12 +208,11 @@ module GraphQL
198
208
  end
199
209
 
200
210
  IGNORE_REGEXP = /[, \r\n\t\uFEFF]+/
201
- COMMENT_REGEXP = /\#[^\n]*/
211
+ COMMENT_BODY_REGEXP = /[^\n\r]*/
202
212
  IDENTIFIER_REGEXP = /[_A-Za-z][_0-9A-Za-z]*/
203
213
  INT_REGEXP = /-?(?:[0]|[1-9][0-9]*)/
204
214
  FLOAT_DECIMAL_REGEXP = /[.][0-9]+/
205
215
  FLOAT_EXP_REGEXP = /[eE][+-]?[0-9]+/
206
- # TODO: FLOAT_EXP_REGEXP should not be allowed to follow INT_REGEXP, integers are not allowed to have exponent parts.
207
216
  NUMERIC_REGEXP = /#{INT_REGEXP}(#{FLOAT_DECIMAL_REGEXP}#{FLOAT_EXP_REGEXP}|#{FLOAT_DECIMAL_REGEXP}|#{FLOAT_EXP_REGEXP})?/
208
217
 
209
218
  KEYWORDS = [
@@ -304,12 +313,11 @@ module GraphQL
304
313
  ESCAPED_QUOTE = /\\"/;
305
314
  STRING_CHAR = /#{ESCAPED_QUOTE}|[^"\\\n\r]|#{UNICODE_ESCAPE}|#{STRING_ESCAPE}/
306
315
  QUOTED_STRING_REGEXP = %r{#{QUOTE} (?:#{STRING_CHAR})* #{QUOTE}}x
316
+ # Keep repeated alternatives disjoint to avoid exponential backtracking on older Rubies.
307
317
  BLOCK_STRING_REGEXP = %r{
308
318
  #{BLOCK_QUOTE}
309
- (?: [^"\\] | # Any characters that aren't a quote or slash
310
- (?<!") ["]{1,2} (?!") | # Any quotes that don't have quotes next to them
311
- \\"{0,3}(?!") | # A slash followed by <= 3 quotes that aren't followed by a quote
312
- \\ | # A slash
319
+ (?: [^"] | # Any character that isn't a quote
320
+ (?<=\\) "{3} (?!") | # Escaped triple quotes
313
321
  "{1,2}(?!") # 1 or 2 " followed by something that isn't a quote
314
322
  )*
315
323
  (?:"")?
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ #--
2
3
  # typed: true
3
4
  module GraphQL
4
5
  module Language
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ #--
2
3
  # typed: true
3
4
 
4
5
  require "strscan"
@@ -47,7 +48,7 @@ module GraphQL
47
48
  document
48
49
  end
49
50
  rescue SystemStackError
50
- raise GraphQL::ParseError.new("This query is too large to execute.", nil, nil, @query_str, filename: @filename)
51
+ raise GraphQL::ParseError.new("This query is too large to execute.", nil, nil, @graphql_str, filename: @filename)
51
52
  end
52
53
  end
53
54
 
@@ -89,8 +90,10 @@ module GraphQL
89
90
  la = []
90
91
  idx = 0 #: Integer?
91
92
  while idx
92
- idx = graphql_str.index("\n", idx)
93
+ idx = graphql_str.index(/[\r\n]/, idx)
93
94
  if idx
95
+ # Record the final byte so CRLF counts as one line break.
96
+ idx += 1 if graphql_str.getbyte(idx) == 13 && graphql_str.getbyte(idx + 1) == 10
94
97
  la << idx
95
98
  idx += 1
96
99
  end
@@ -172,7 +175,7 @@ module GraphQL
172
175
  var_type = self.type || raise_parse_error("Missing type definition for variable: $#{var_name}")
173
176
  default_value = if at?(:EQUALS)
174
177
  advance_token
175
- value
178
+ value(const: true)
176
179
  end
177
180
 
178
181
  directives = parse_directives #: untyped
@@ -491,7 +494,7 @@ module GraphQL
491
494
  type = self.type
492
495
  default_value = if at?(:EQUALS)
493
496
  advance_token
494
- value
497
+ value(const: true)
495
498
  else
496
499
  nil
497
500
  end
@@ -715,7 +718,7 @@ module GraphQL
715
718
  token_value
716
719
  end
717
720
 
718
- def value
721
+ def value(const: false)
719
722
  case token_name
720
723
  when :INT
721
724
  expect_token_value(:INT).to_i
@@ -738,7 +741,7 @@ module GraphQL
738
741
  advance_token
739
742
  list = []
740
743
  while !at?(:RBRACKET)
741
- list << value
744
+ list << value(const: const)
742
745
  end
743
746
  expect_token(:RBRACKET)
744
747
  list
@@ -750,11 +753,12 @@ module GraphQL
750
753
  loc = pos #: untyped
751
754
  n = parse_name
752
755
  expect_token(:COLON)
753
- args << Argument.new(pos: loc, name: n, value: value, filename: @filename, source: self)
756
+ args << Argument.new(pos: loc, name: n, value: value(const: const), filename: @filename, source: self)
754
757
  end
755
758
  expect_token(:RCURLY)
756
759
  InputObject.new(pos: start, arguments: args, filename: @filename, source: self)
757
760
  when :VAR_SIGN
761
+ raise_parse_error("Unexpected variable in constant value") if const
758
762
  loc = pos
759
763
  advance_token
760
764
  VariableIdentifier.new(pos: loc, name: parse_name, filename: @filename, source: self)
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ #--
2
3
  # typed: true
3
4
  module GraphQL
4
5
  module Language
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ #--
2
3
  # typed: true
3
4
  module GraphQL
4
5
  module Language
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ #--
2
3
  # typed: true
3
4
  module GraphQL
4
5
  module Language
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ #--
2
3
  # typed: true
3
4
  module GraphQL
4
5
  module Language
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ #--
2
3
  # typed: true
3
4
  require "graphql/language/block_string"
4
5
  require "graphql/language/comment"
@@ -59,7 +60,7 @@ module GraphQL
59
60
  if scanner.skip('"""')
60
61
  inside_triple_quoted_string = !inside_triple_quoted_string
61
62
  new_query_str && (new_query_str << scanner.matched)
62
- elsif scanner.skip(/(?:\\"|[^"\n\r])+/m)
63
+ elsif scanner.skip(inside_single_quoted_string ? /(?>\\[\\"]|[^"\n\r])+/ : /(?:\\"|[^"\n\r])+/m)
63
64
  new_query_str && (new_query_str << scanner.matched)
64
65
  elsif scanner.skip('"')
65
66
  new_query_str && (new_query_str << '"')
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ #--
2
3
  # typed: true
3
4
 
4
5
  module GraphQL
@@ -1,9 +1,11 @@
1
1
  # frozen_string_literal: true
2
- # typed: true
2
+ #--
3
+ # typed: strict
3
4
  module GraphQL
4
5
  class NameValidator
5
6
  VALID_NAME_REGEX = /^[_a-zA-Z][_a-zA-Z0-9]*$/
6
7
 
8
+ #: (String | Symbol name) -> void
7
9
  def self.validate!(name)
8
10
  name = name.is_a?(String) ? name : name.to_s
9
11
  raise GraphQL::InvalidNameError.new(name, VALID_NAME_REGEX) unless name.match?(VALID_NAME_REGEX)