graphql 1.9.17 → 2.0.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (416) hide show
  1. checksums.yaml +4 -4
  2. data/lib/generators/graphql/core.rb +21 -10
  3. data/lib/generators/graphql/enum_generator.rb +4 -10
  4. data/lib/generators/graphql/field_extractor.rb +31 -0
  5. data/lib/generators/graphql/input_generator.rb +50 -0
  6. data/lib/generators/graphql/install/mutation_root_generator.rb +34 -0
  7. data/lib/generators/graphql/{templates → install/templates}/base_mutation.erb +2 -0
  8. data/lib/generators/graphql/{templates → install/templates}/mutation_type.erb +2 -0
  9. data/lib/generators/graphql/install_generator.rb +45 -8
  10. data/lib/generators/graphql/interface_generator.rb +7 -7
  11. data/lib/generators/graphql/loader_generator.rb +1 -0
  12. data/lib/generators/graphql/mutation_create_generator.rb +22 -0
  13. data/lib/generators/graphql/mutation_delete_generator.rb +22 -0
  14. data/lib/generators/graphql/mutation_generator.rb +6 -30
  15. data/lib/generators/graphql/mutation_update_generator.rb +22 -0
  16. data/lib/generators/graphql/object_generator.rb +28 -12
  17. data/lib/generators/graphql/orm_mutations_base.rb +40 -0
  18. data/lib/generators/graphql/relay.rb +49 -0
  19. data/lib/generators/graphql/relay_generator.rb +21 -0
  20. data/lib/generators/graphql/scalar_generator.rb +4 -2
  21. data/lib/generators/graphql/templates/base_argument.erb +2 -0
  22. data/lib/generators/graphql/templates/base_connection.erb +8 -0
  23. data/lib/generators/graphql/templates/base_edge.erb +8 -0
  24. data/lib/generators/graphql/templates/base_enum.erb +2 -0
  25. data/lib/generators/graphql/templates/base_field.erb +2 -0
  26. data/lib/generators/graphql/templates/base_input_object.erb +2 -0
  27. data/lib/generators/graphql/templates/base_interface.erb +2 -0
  28. data/lib/generators/graphql/templates/base_object.erb +2 -0
  29. data/lib/generators/graphql/templates/base_scalar.erb +2 -0
  30. data/lib/generators/graphql/templates/base_union.erb +2 -0
  31. data/lib/generators/graphql/templates/enum.erb +7 -1
  32. data/lib/generators/graphql/templates/graphql_controller.erb +16 -12
  33. data/lib/generators/graphql/templates/input.erb +9 -0
  34. data/lib/generators/graphql/templates/interface.erb +6 -2
  35. data/lib/generators/graphql/templates/loader.erb +2 -0
  36. data/lib/generators/graphql/templates/mutation.erb +3 -1
  37. data/lib/generators/graphql/templates/mutation_create.erb +20 -0
  38. data/lib/generators/graphql/templates/mutation_delete.erb +20 -0
  39. data/lib/generators/graphql/templates/mutation_update.erb +21 -0
  40. data/lib/generators/graphql/templates/node_type.erb +9 -0
  41. data/lib/generators/graphql/templates/object.erb +7 -3
  42. data/lib/generators/graphql/templates/query_type.erb +3 -3
  43. data/lib/generators/graphql/templates/scalar.erb +5 -1
  44. data/lib/generators/graphql/templates/schema.erb +25 -27
  45. data/lib/generators/graphql/templates/union.erb +6 -2
  46. data/lib/generators/graphql/type_generator.rb +47 -10
  47. data/lib/generators/graphql/union_generator.rb +5 -5
  48. data/lib/graphql/analysis/ast/field_usage.rb +31 -2
  49. data/lib/graphql/analysis/ast/max_query_complexity.rb +0 -1
  50. data/lib/graphql/analysis/ast/query_complexity.rb +175 -68
  51. data/lib/graphql/analysis/ast/query_depth.rb +0 -1
  52. data/lib/graphql/analysis/ast/visitor.rb +54 -38
  53. data/lib/graphql/analysis/ast.rb +16 -16
  54. data/lib/graphql/analysis.rb +0 -7
  55. data/lib/graphql/backtrace/inspect_result.rb +0 -1
  56. data/lib/graphql/backtrace/table.rb +37 -16
  57. data/lib/graphql/backtrace/trace.rb +96 -0
  58. data/lib/graphql/backtrace/traced_error.rb +0 -1
  59. data/lib/graphql/backtrace/tracer.rb +39 -9
  60. data/lib/graphql/backtrace.rb +26 -18
  61. data/lib/graphql/dataloader/null_dataloader.rb +24 -0
  62. data/lib/graphql/dataloader/request.rb +19 -0
  63. data/lib/graphql/dataloader/request_all.rb +19 -0
  64. data/lib/graphql/dataloader/source.rb +164 -0
  65. data/lib/graphql/dataloader.rb +311 -0
  66. data/lib/graphql/date_encoding_error.rb +16 -0
  67. data/lib/graphql/deprecation.rb +9 -0
  68. data/lib/graphql/dig.rb +1 -1
  69. data/lib/graphql/execution/directive_checks.rb +2 -2
  70. data/lib/graphql/execution/errors.rb +77 -45
  71. data/lib/graphql/execution/interpreter/argument_value.rb +28 -0
  72. data/lib/graphql/execution/interpreter/arguments.rb +88 -0
  73. data/lib/graphql/execution/interpreter/arguments_cache.rb +104 -0
  74. data/lib/graphql/execution/interpreter/handles_raw_value.rb +18 -0
  75. data/lib/graphql/execution/interpreter/resolve.rb +62 -24
  76. data/lib/graphql/execution/interpreter/runtime.rb +830 -417
  77. data/lib/graphql/execution/interpreter.rb +206 -74
  78. data/lib/graphql/execution/lazy/lazy_method_map.rb +4 -0
  79. data/lib/graphql/execution/lazy.rb +11 -21
  80. data/lib/graphql/execution/lookahead.rb +65 -136
  81. data/lib/graphql/execution/multiplex.rb +6 -152
  82. data/lib/graphql/execution.rb +11 -4
  83. data/lib/graphql/filter.rb +8 -3
  84. data/lib/graphql/integer_decoding_error.rb +17 -0
  85. data/lib/graphql/integer_encoding_error.rb +18 -2
  86. data/lib/graphql/introspection/base_object.rb +2 -5
  87. data/lib/graphql/introspection/directive_location_enum.rb +2 -2
  88. data/lib/graphql/introspection/directive_type.rb +12 -6
  89. data/lib/graphql/introspection/dynamic_fields.rb +3 -8
  90. data/lib/graphql/introspection/entry_points.rb +5 -18
  91. data/lib/graphql/introspection/enum_value_type.rb +2 -2
  92. data/lib/graphql/introspection/field_type.rb +9 -5
  93. data/lib/graphql/introspection/input_value_type.rb +41 -11
  94. data/lib/graphql/introspection/introspection_query.rb +6 -92
  95. data/lib/graphql/introspection/schema_type.rb +12 -12
  96. data/lib/graphql/introspection/type_type.rb +34 -17
  97. data/lib/graphql/introspection.rb +100 -0
  98. data/lib/graphql/invalid_null_error.rb +18 -0
  99. data/lib/graphql/language/block_string.rb +20 -5
  100. data/lib/graphql/language/cache.rb +37 -0
  101. data/lib/graphql/language/definition_slice.rb +21 -10
  102. data/lib/graphql/language/document_from_schema_definition.rb +136 -78
  103. data/lib/graphql/language/lexer.rb +216 -1462
  104. data/lib/graphql/language/nodes.rb +129 -132
  105. data/lib/graphql/language/parser.rb +994 -932
  106. data/lib/graphql/language/parser.y +152 -120
  107. data/lib/graphql/language/printer.rb +48 -23
  108. data/lib/graphql/language/sanitized_printer.rb +222 -0
  109. data/lib/graphql/language/token.rb +0 -4
  110. data/lib/graphql/language/visitor.rb +192 -84
  111. data/lib/graphql/language.rb +3 -1
  112. data/lib/graphql/name_validator.rb +2 -7
  113. data/lib/graphql/pagination/active_record_relation_connection.rb +77 -0
  114. data/lib/graphql/pagination/array_connection.rb +79 -0
  115. data/lib/graphql/pagination/connection.rb +253 -0
  116. data/lib/graphql/pagination/connections.rb +135 -0
  117. data/lib/graphql/pagination/mongoid_relation_connection.rb +25 -0
  118. data/lib/graphql/pagination/relation_connection.rb +228 -0
  119. data/lib/graphql/pagination/sequel_dataset_connection.rb +28 -0
  120. data/lib/graphql/pagination.rb +6 -0
  121. data/lib/graphql/parse_error.rb +0 -1
  122. data/lib/graphql/query/context.rb +205 -203
  123. data/lib/graphql/query/fingerprint.rb +26 -0
  124. data/lib/graphql/query/input_validation_result.rb +33 -7
  125. data/lib/graphql/query/null_context.rb +22 -9
  126. data/lib/graphql/query/validation_pipeline.rb +16 -38
  127. data/lib/graphql/query/variable_validation_error.rb +3 -3
  128. data/lib/graphql/query/variables.rb +39 -12
  129. data/lib/graphql/query.rb +95 -43
  130. data/lib/graphql/railtie.rb +6 -102
  131. data/lib/graphql/rake_task/validate.rb +4 -1
  132. data/lib/graphql/rake_task.rb +41 -10
  133. data/lib/graphql/relay/range_add.rb +17 -10
  134. data/lib/graphql/relay.rb +0 -15
  135. data/lib/graphql/rubocop/graphql/base_cop.rb +36 -0
  136. data/lib/graphql/rubocop/graphql/default_null_true.rb +43 -0
  137. data/lib/graphql/rubocop/graphql/default_required_true.rb +43 -0
  138. data/lib/graphql/rubocop.rb +4 -0
  139. data/lib/graphql/schema/addition.rb +245 -0
  140. data/lib/graphql/schema/argument.rb +285 -36
  141. data/lib/graphql/schema/base_64_encoder.rb +2 -0
  142. data/lib/graphql/schema/build_from_definition/resolve_map/default_resolve.rb +1 -1
  143. data/lib/graphql/schema/build_from_definition/resolve_map.rb +13 -5
  144. data/lib/graphql/schema/build_from_definition.rb +348 -205
  145. data/lib/graphql/schema/built_in_types.rb +5 -5
  146. data/lib/graphql/schema/directive/deprecated.rb +18 -0
  147. data/lib/graphql/schema/directive/feature.rb +1 -1
  148. data/lib/graphql/schema/directive/flagged.rb +57 -0
  149. data/lib/graphql/schema/directive/include.rb +2 -2
  150. data/lib/graphql/schema/directive/one_of.rb +12 -0
  151. data/lib/graphql/schema/directive/skip.rb +2 -2
  152. data/lib/graphql/schema/directive/transform.rb +14 -2
  153. data/lib/graphql/schema/directive.rb +134 -15
  154. data/lib/graphql/schema/enum.rb +137 -39
  155. data/lib/graphql/schema/enum_value.rb +17 -23
  156. data/lib/graphql/schema/field/connection_extension.rb +50 -20
  157. data/lib/graphql/schema/field/scope_extension.rb +1 -1
  158. data/lib/graphql/schema/field.rb +504 -331
  159. data/lib/graphql/schema/field_extension.rb +86 -2
  160. data/lib/graphql/schema/find_inherited_value.rb +12 -1
  161. data/lib/graphql/schema/finder.rb +16 -14
  162. data/lib/graphql/schema/input_object.rb +182 -60
  163. data/lib/graphql/schema/interface.rb +24 -49
  164. data/lib/graphql/schema/introspection_system.rb +103 -37
  165. data/lib/graphql/schema/late_bound_type.rb +9 -2
  166. data/lib/graphql/schema/list.rb +61 -3
  167. data/lib/graphql/schema/loader.rb +144 -96
  168. data/lib/graphql/schema/member/base_dsl_methods.rb +41 -37
  169. data/lib/graphql/schema/member/build_type.rb +24 -15
  170. data/lib/graphql/schema/member/has_arguments.rb +310 -26
  171. data/lib/graphql/schema/member/has_ast_node.rb +32 -0
  172. data/lib/graphql/schema/member/has_deprecation_reason.rb +24 -0
  173. data/lib/graphql/schema/member/has_directives.rb +118 -0
  174. data/lib/graphql/schema/member/has_fields.rb +166 -44
  175. data/lib/graphql/schema/member/has_interfaces.rb +129 -0
  176. data/lib/graphql/schema/member/has_unresolved_type_error.rb +15 -0
  177. data/lib/graphql/schema/member/has_validators.rb +57 -0
  178. data/lib/graphql/schema/member/relay_shortcuts.rb +47 -2
  179. data/lib/graphql/schema/member/type_system_helpers.rb +20 -3
  180. data/lib/graphql/schema/member/validates_input.rb +33 -0
  181. data/lib/graphql/schema/member.rb +11 -6
  182. data/lib/graphql/schema/mutation.rb +4 -9
  183. data/lib/graphql/schema/non_null.rb +34 -4
  184. data/lib/graphql/schema/object.rb +36 -60
  185. data/lib/graphql/schema/printer.rb +16 -35
  186. data/lib/graphql/schema/relay_classic_mutation.rb +91 -44
  187. data/lib/graphql/schema/resolver/has_payload_type.rb +51 -11
  188. data/lib/graphql/schema/resolver.rb +147 -94
  189. data/lib/graphql/schema/scalar.rb +40 -15
  190. data/lib/graphql/schema/subscription.rb +60 -31
  191. data/lib/graphql/schema/timeout.rb +45 -35
  192. data/lib/graphql/schema/type_expression.rb +21 -13
  193. data/lib/graphql/schema/type_membership.rb +23 -6
  194. data/lib/graphql/schema/union.rb +49 -15
  195. data/lib/graphql/schema/unique_within_type.rb +1 -2
  196. data/lib/graphql/schema/validator/allow_blank_validator.rb +29 -0
  197. data/lib/graphql/schema/validator/allow_null_validator.rb +26 -0
  198. data/lib/graphql/schema/validator/exclusion_validator.rb +33 -0
  199. data/lib/graphql/schema/validator/format_validator.rb +48 -0
  200. data/lib/graphql/schema/validator/inclusion_validator.rb +35 -0
  201. data/lib/graphql/schema/validator/length_validator.rb +59 -0
  202. data/lib/graphql/schema/validator/numericality_validator.rb +82 -0
  203. data/lib/graphql/schema/validator/required_validator.rb +82 -0
  204. data/lib/graphql/schema/validator.rb +171 -0
  205. data/lib/graphql/schema/warden.rb +213 -35
  206. data/lib/graphql/schema/wrapper.rb +0 -5
  207. data/lib/graphql/schema.rb +857 -884
  208. data/lib/graphql/static_validation/all_rules.rb +3 -0
  209. data/lib/graphql/static_validation/base_visitor.rb +21 -31
  210. data/lib/graphql/static_validation/definition_dependencies.rb +7 -2
  211. data/lib/graphql/static_validation/error.rb +3 -1
  212. data/lib/graphql/static_validation/literal_validator.rb +69 -26
  213. data/lib/graphql/static_validation/rules/argument_literals_are_compatible.rb +45 -83
  214. data/lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb +22 -6
  215. data/lib/graphql/static_validation/rules/arguments_are_defined.rb +35 -26
  216. data/lib/graphql/static_validation/rules/arguments_are_defined_error.rb +4 -2
  217. data/lib/graphql/static_validation/rules/directives_are_defined.rb +12 -6
  218. data/lib/graphql/static_validation/rules/directives_are_in_valid_locations.rb +14 -14
  219. data/lib/graphql/static_validation/rules/fields_are_defined_on_type.rb +4 -4
  220. data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +15 -7
  221. data/lib/graphql/static_validation/rules/fields_will_merge.rb +96 -53
  222. data/lib/graphql/static_validation/rules/fields_will_merge_error.rb +25 -4
  223. data/lib/graphql/static_validation/rules/fragment_spreads_are_possible.rb +3 -3
  224. data/lib/graphql/static_validation/rules/fragments_are_finite.rb +2 -2
  225. data/lib/graphql/static_validation/rules/input_object_names_are_unique.rb +30 -0
  226. data/lib/graphql/static_validation/rules/input_object_names_are_unique_error.rb +30 -0
  227. data/lib/graphql/static_validation/rules/one_of_input_objects_are_valid.rb +66 -0
  228. data/lib/graphql/static_validation/rules/one_of_input_objects_are_valid_error.rb +29 -0
  229. data/lib/graphql/static_validation/rules/query_root_exists.rb +17 -0
  230. data/lib/graphql/static_validation/rules/query_root_exists_error.rb +26 -0
  231. data/lib/graphql/static_validation/rules/required_arguments_are_present.rb +4 -2
  232. data/lib/graphql/static_validation/rules/required_input_object_attributes_are_present.rb +9 -10
  233. data/lib/graphql/static_validation/rules/unique_directives_per_location.rb +13 -7
  234. data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed.rb +12 -13
  235. data/lib/graphql/static_validation/rules/variable_usages_are_allowed.rb +19 -14
  236. data/lib/graphql/static_validation/rules/variables_are_input_types.rb +1 -1
  237. data/lib/graphql/static_validation/rules/variables_are_used_and_defined.rb +5 -3
  238. data/lib/graphql/static_validation/type_stack.rb +2 -2
  239. data/lib/graphql/static_validation/validation_context.rb +13 -3
  240. data/lib/graphql/static_validation/validation_timeout_error.rb +25 -0
  241. data/lib/graphql/static_validation/validator.rb +32 -20
  242. data/lib/graphql/static_validation.rb +1 -2
  243. data/lib/graphql/string_encoding_error.rb +13 -3
  244. data/lib/graphql/subscriptions/action_cable_subscriptions.rb +129 -22
  245. data/lib/graphql/subscriptions/broadcast_analyzer.rb +81 -0
  246. data/lib/graphql/subscriptions/default_subscription_resolve_extension.rb +58 -0
  247. data/lib/graphql/subscriptions/event.rb +84 -35
  248. data/lib/graphql/subscriptions/instrumentation.rb +0 -47
  249. data/lib/graphql/subscriptions/serialize.rb +53 -6
  250. data/lib/graphql/subscriptions.rb +137 -57
  251. data/lib/graphql/tracing/active_support_notifications_trace.rb +16 -0
  252. data/lib/graphql/tracing/active_support_notifications_tracing.rb +8 -17
  253. data/lib/graphql/tracing/appoptics_trace.rb +231 -0
  254. data/lib/graphql/tracing/appoptics_tracing.rb +173 -0
  255. data/lib/graphql/tracing/appsignal_trace.rb +77 -0
  256. data/lib/graphql/tracing/appsignal_tracing.rb +23 -0
  257. data/lib/graphql/tracing/data_dog_trace.rb +148 -0
  258. data/lib/graphql/tracing/data_dog_tracing.rb +34 -2
  259. data/lib/graphql/tracing/legacy_trace.rb +65 -0
  260. data/lib/graphql/tracing/new_relic_trace.rb +75 -0
  261. data/lib/graphql/tracing/new_relic_tracing.rb +9 -12
  262. data/lib/graphql/tracing/notifications_trace.rb +42 -0
  263. data/lib/graphql/tracing/notifications_tracing.rb +59 -0
  264. data/lib/graphql/tracing/platform_trace.rb +109 -0
  265. data/lib/graphql/tracing/platform_tracing.rb +76 -35
  266. data/lib/graphql/tracing/prometheus_trace.rb +89 -0
  267. data/lib/graphql/tracing/prometheus_tracing/graphql_collector.rb +5 -2
  268. data/lib/graphql/tracing/prometheus_tracing.rb +11 -3
  269. data/lib/graphql/tracing/scout_trace.rb +72 -0
  270. data/lib/graphql/tracing/scout_tracing.rb +19 -0
  271. data/lib/graphql/tracing/statsd_trace.rb +56 -0
  272. data/lib/graphql/tracing/statsd_tracing.rb +42 -0
  273. data/lib/graphql/tracing/trace.rb +75 -0
  274. data/lib/graphql/tracing.rb +23 -67
  275. data/lib/graphql/type_kinds.rb +6 -3
  276. data/lib/graphql/types/big_int.rb +5 -1
  277. data/lib/graphql/types/int.rb +10 -3
  278. data/lib/graphql/types/iso_8601_date.rb +20 -9
  279. data/lib/graphql/types/iso_8601_date_time.rb +36 -10
  280. data/lib/graphql/types/relay/base_connection.rb +18 -90
  281. data/lib/graphql/types/relay/base_edge.rb +2 -34
  282. data/lib/graphql/types/relay/connection_behaviors.rb +176 -0
  283. data/lib/graphql/types/relay/edge_behaviors.rb +75 -0
  284. data/lib/graphql/types/relay/has_node_field.rb +41 -0
  285. data/lib/graphql/types/relay/has_nodes_field.rb +41 -0
  286. data/lib/graphql/types/relay/node.rb +2 -4
  287. data/lib/graphql/types/relay/node_behaviors.rb +25 -0
  288. data/lib/graphql/types/relay/page_info.rb +2 -14
  289. data/lib/graphql/types/relay/page_info_behaviors.rb +30 -0
  290. data/lib/graphql/types/relay.rb +10 -5
  291. data/lib/graphql/types/string.rb +8 -2
  292. data/lib/graphql/unauthorized_error.rb +2 -2
  293. data/lib/graphql/unresolved_type_error.rb +2 -2
  294. data/lib/graphql/version.rb +1 -1
  295. data/lib/graphql.rb +63 -65
  296. data/readme.md +3 -6
  297. metadata +127 -236
  298. data/lib/graphql/analysis/analyze_query.rb +0 -91
  299. data/lib/graphql/analysis/field_usage.rb +0 -45
  300. data/lib/graphql/analysis/max_query_complexity.rb +0 -26
  301. data/lib/graphql/analysis/max_query_depth.rb +0 -26
  302. data/lib/graphql/analysis/query_complexity.rb +0 -88
  303. data/lib/graphql/analysis/query_depth.rb +0 -43
  304. data/lib/graphql/analysis/reducer_state.rb +0 -48
  305. data/lib/graphql/argument.rb +0 -159
  306. data/lib/graphql/authorization.rb +0 -82
  307. data/lib/graphql/backwards_compatibility.rb +0 -60
  308. data/lib/graphql/base_type.rb +0 -226
  309. data/lib/graphql/boolean_type.rb +0 -2
  310. data/lib/graphql/compatibility/execution_specification/counter_schema.rb +0 -53
  311. data/lib/graphql/compatibility/execution_specification/specification_schema.rb +0 -200
  312. data/lib/graphql/compatibility/execution_specification.rb +0 -435
  313. data/lib/graphql/compatibility/lazy_execution_specification/lazy_schema.rb +0 -111
  314. data/lib/graphql/compatibility/lazy_execution_specification.rb +0 -213
  315. data/lib/graphql/compatibility/query_parser_specification/parse_error_specification.rb +0 -91
  316. data/lib/graphql/compatibility/query_parser_specification/query_assertions.rb +0 -79
  317. data/lib/graphql/compatibility/query_parser_specification.rb +0 -264
  318. data/lib/graphql/compatibility/schema_parser_specification.rb +0 -680
  319. data/lib/graphql/compatibility.rb +0 -5
  320. data/lib/graphql/define/assign_argument.rb +0 -12
  321. data/lib/graphql/define/assign_connection.rb +0 -13
  322. data/lib/graphql/define/assign_enum_value.rb +0 -18
  323. data/lib/graphql/define/assign_global_id_field.rb +0 -11
  324. data/lib/graphql/define/assign_mutation_function.rb +0 -34
  325. data/lib/graphql/define/assign_object_field.rb +0 -42
  326. data/lib/graphql/define/defined_object_proxy.rb +0 -50
  327. data/lib/graphql/define/instance_definable.rb +0 -300
  328. data/lib/graphql/define/no_definition_error.rb +0 -7
  329. data/lib/graphql/define/non_null_with_bang.rb +0 -16
  330. data/lib/graphql/define/type_definer.rb +0 -31
  331. data/lib/graphql/define.rb +0 -31
  332. data/lib/graphql/deprecated_dsl.rb +0 -42
  333. data/lib/graphql/directive/deprecated_directive.rb +0 -13
  334. data/lib/graphql/directive/include_directive.rb +0 -2
  335. data/lib/graphql/directive/skip_directive.rb +0 -2
  336. data/lib/graphql/directive.rb +0 -104
  337. data/lib/graphql/enum_type.rb +0 -193
  338. data/lib/graphql/execution/execute.rb +0 -326
  339. data/lib/graphql/execution/flatten.rb +0 -40
  340. data/lib/graphql/execution/instrumentation.rb +0 -92
  341. data/lib/graphql/execution/interpreter/hash_response.rb +0 -46
  342. data/lib/graphql/execution/lazy/resolve.rb +0 -91
  343. data/lib/graphql/execution/typecast.rb +0 -50
  344. data/lib/graphql/field/resolve.rb +0 -59
  345. data/lib/graphql/field.rb +0 -330
  346. data/lib/graphql/float_type.rb +0 -2
  347. data/lib/graphql/function.rb +0 -153
  348. data/lib/graphql/id_type.rb +0 -2
  349. data/lib/graphql/input_object_type.rb +0 -154
  350. data/lib/graphql/int_type.rb +0 -2
  351. data/lib/graphql/interface_type.rb +0 -86
  352. data/lib/graphql/internal_representation/document.rb +0 -27
  353. data/lib/graphql/internal_representation/node.rb +0 -206
  354. data/lib/graphql/internal_representation/print.rb +0 -51
  355. data/lib/graphql/internal_representation/rewrite.rb +0 -184
  356. data/lib/graphql/internal_representation/scope.rb +0 -88
  357. data/lib/graphql/internal_representation/visit.rb +0 -36
  358. data/lib/graphql/internal_representation.rb +0 -7
  359. data/lib/graphql/language/lexer.rl +0 -258
  360. data/lib/graphql/list_type.rb +0 -80
  361. data/lib/graphql/literal_validation_error.rb +0 -6
  362. data/lib/graphql/non_null_type.rb +0 -81
  363. data/lib/graphql/object_type.rb +0 -141
  364. data/lib/graphql/query/arguments.rb +0 -187
  365. data/lib/graphql/query/arguments_cache.rb +0 -25
  366. data/lib/graphql/query/executor.rb +0 -53
  367. data/lib/graphql/query/literal_input.rb +0 -116
  368. data/lib/graphql/query/serial_execution/field_resolution.rb +0 -92
  369. data/lib/graphql/query/serial_execution/operation_resolution.rb +0 -19
  370. data/lib/graphql/query/serial_execution/selection_resolution.rb +0 -23
  371. data/lib/graphql/query/serial_execution/value_resolution.rb +0 -87
  372. data/lib/graphql/query/serial_execution.rb +0 -39
  373. data/lib/graphql/relay/array_connection.rb +0 -85
  374. data/lib/graphql/relay/base_connection.rb +0 -172
  375. data/lib/graphql/relay/connection_instrumentation.rb +0 -54
  376. data/lib/graphql/relay/connection_resolve.rb +0 -43
  377. data/lib/graphql/relay/connection_type.rb +0 -40
  378. data/lib/graphql/relay/edge.rb +0 -27
  379. data/lib/graphql/relay/edge_type.rb +0 -18
  380. data/lib/graphql/relay/edges_instrumentation.rb +0 -40
  381. data/lib/graphql/relay/global_id_resolve.rb +0 -18
  382. data/lib/graphql/relay/mongo_relation_connection.rb +0 -50
  383. data/lib/graphql/relay/mutation/instrumentation.rb +0 -23
  384. data/lib/graphql/relay/mutation/resolve.rb +0 -56
  385. data/lib/graphql/relay/mutation/result.rb +0 -38
  386. data/lib/graphql/relay/mutation.rb +0 -190
  387. data/lib/graphql/relay/node.rb +0 -36
  388. data/lib/graphql/relay/page_info.rb +0 -7
  389. data/lib/graphql/relay/relation_connection.rb +0 -190
  390. data/lib/graphql/relay/type_extensions.rb +0 -30
  391. data/lib/graphql/scalar_type.rb +0 -133
  392. data/lib/graphql/schema/catchall_middleware.rb +0 -35
  393. data/lib/graphql/schema/default_parse_error.rb +0 -10
  394. data/lib/graphql/schema/default_type_error.rb +0 -15
  395. data/lib/graphql/schema/member/accepts_definition.rb +0 -152
  396. data/lib/graphql/schema/member/cached_graphql_definition.rb +0 -26
  397. data/lib/graphql/schema/member/instrumentation.rb +0 -132
  398. data/lib/graphql/schema/middleware_chain.rb +0 -82
  399. data/lib/graphql/schema/possible_types.rb +0 -39
  400. data/lib/graphql/schema/rescue_middleware.rb +0 -60
  401. data/lib/graphql/schema/timeout_middleware.rb +0 -86
  402. data/lib/graphql/schema/traversal.rb +0 -228
  403. data/lib/graphql/schema/validation.rb +0 -303
  404. data/lib/graphql/static_validation/default_visitor.rb +0 -15
  405. data/lib/graphql/static_validation/no_validate_visitor.rb +0 -10
  406. data/lib/graphql/string_type.rb +0 -2
  407. data/lib/graphql/subscriptions/subscription_root.rb +0 -66
  408. data/lib/graphql/tracing/skylight_tracing.rb +0 -62
  409. data/lib/graphql/types/relay/base_field.rb +0 -22
  410. data/lib/graphql/types/relay/base_interface.rb +0 -29
  411. data/lib/graphql/types/relay/base_object.rb +0 -26
  412. data/lib/graphql/types/relay/node_field.rb +0 -43
  413. data/lib/graphql/types/relay/nodes_field.rb +0 -45
  414. data/lib/graphql/union_type.rb +0 -128
  415. data/lib/graphql/upgrader/member.rb +0 -936
  416. data/lib/graphql/upgrader/schema.rb +0 -37
@@ -1,1466 +1,220 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module GraphQL
4
- module Language
5
- module Lexer
6
- def self.tokenize(query_string)
7
- run_lexer(query_string)
8
- end
9
-
10
- # Replace any escaped unicode or whitespace with the _actual_ characters
11
- # To avoid allocating more strings, this modifies the string passed into it
12
- def self.replace_escaped_characters_in_place(raw_string)
13
- raw_string.gsub!(ESCAPES, ESCAPES_REPLACE)
14
- raw_string.gsub!(UTF_8, &UTF_8_REPLACE)
15
- nil
16
- end
17
-
18
- private
19
-
20
- class << self
21
- attr_accessor :_graphql_lexer_trans_keys
22
- private :_graphql_lexer_trans_keys, :_graphql_lexer_trans_keys=
23
- end
24
- self._graphql_lexer_trans_keys = [
25
- 1, 0, 4, 22, 4, 43, 14, 46, 14, 46, 14, 46, 14, 46, 4, 22, 4, 4, 4, 4, 4, 22, 4, 4, 4, 4, 14, 15, 14, 15, 10, 15, 12, 12, 4, 22, 4, 43, 14, 46, 14, 46, 14, 46, 14, 46, 0, 49, 0, 0, 4, 22, 4, 4, 4, 4, 4, 4, 4, 22, 4, 4, 4, 4, 1, 1, 14, 15, 10, 29, 14, 15, 10, 29, 10, 29, 12, 12, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 14, 46, 4, 4, 0 ,
26
- ]
27
-
28
- class << self
29
- attr_accessor :_graphql_lexer_char_class
30
- private :_graphql_lexer_char_class, :_graphql_lexer_char_class=
31
- end
32
- self._graphql_lexer_char_class = [
33
- 0, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 3, 4, 5, 6, 2, 7, 2, 8, 9, 2, 10, 0, 11, 12, 13, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 2, 2, 17, 2, 2, 18, 19, 19, 19, 19, 20, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 21, 22, 23, 2, 24, 2, 25, 26, 27, 28, 29, 30, 31, 32, 33, 19, 19, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 19, 45, 46, 19, 47, 48, 49, 0 ,
34
- ]
35
-
36
- class << self
37
- attr_accessor :_graphql_lexer_index_offsets
38
- private :_graphql_lexer_index_offsets, :_graphql_lexer_index_offsets=
39
- end
40
- self._graphql_lexer_index_offsets = [
41
- 0, 0, 19, 59, 92, 125, 158, 191, 210, 211, 212, 231, 232, 233, 235, 237, 243, 244, 263, 303, 336, 369, 402, 435, 485, 486, 505, 506, 507, 508, 527, 528, 529, 530, 532, 552, 554, 574, 594, 595, 628, 661, 694, 727, 760, 793, 826, 859, 892, 925, 958, 991, 1024, 1057, 1090, 1123, 1156, 1189, 1222, 1255, 1288, 1321, 1354, 1387, 1420, 1453, 1486, 1519, 1552, 1585, 1618, 1651, 1684, 1717, 1750, 1783, 1816, 1849, 1882, 1915, 1948, 1981, 2014, 2047, 2080, 2113, 2146, 2179, 2212, 2245, 2278, 2311, 2344, 2377, 2410, 2443, 2476, 2509, 2542, 2575, 2608, 2641, 2674, 2707, 2740, 2773, 2806, 2839, 2872, 2905, 2938, 2971, 3004, 3037, 3070, 3103, 3136, 3169, 3202, 3235, 3268, 3301, 3334, 3367, 3400, 3433, 0 ,
42
- ]
43
-
44
- class << self
45
- attr_accessor :_graphql_lexer_indicies
46
- private :_graphql_lexer_indicies, :_graphql_lexer_indicies=
47
- end
48
- self._graphql_lexer_indicies = [
49
- 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 4, 5, 5, 0, 0, 0, 5, 5, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 0, 0, 0, 6, 6, 0, 0, 0, 0, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 0, 0, 0, 7, 7, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 12, 13, 14, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 15, 16, 17, 17, 19, 19, 20, 20, 8, 8, 17, 17, 21, 23, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 24, 22, 25, 25, 25, 25, 25, 25, 25, 25, 22, 25, 25, 25, 25, 25, 25, 25, 25, 22, 25, 25, 25, 22, 25, 25, 25, 22, 25, 25, 25, 25, 25, 22, 25, 25, 25, 22, 25, 22, 26, 27, 27, 25, 25, 25, 27, 27, 25, 25, 25, 25, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28, 28, 25, 25, 25, 28, 28, 25, 25, 25, 25, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 25, 25, 25, 29, 29, 25, 25, 25, 25, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 22, 22, 25, 25, 25, 22, 22, 25, 25, 25, 25, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 31, 32, 30, 33, 34, 35, 36, 37, 38, 39, 30, 40, 41, 30, 42, 43, 44, 45, 46, 47, 47, 48, 30, 49, 47, 47, 47, 47, 50, 51, 52, 47, 47, 53, 47, 54, 55, 56, 47, 57, 47, 58, 59, 60, 47, 47, 47, 61, 62, 63, 31, 66, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 9, 69, 70, 71, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 72, 13, 73, 42, 43, 20, 20, 75, 74, 17, 17, 74, 74, 74, 74, 76, 74, 74, 74, 74, 74, 74, 74, 74, 76, 17, 17, 20, 20, 77, 77, 19, 19, 77, 77, 77, 77, 76, 77, 77, 77, 77, 77, 77, 77, 77, 76, 20, 20, 75, 74, 43, 43, 74, 74, 74, 74, 76, 74, 74, 74, 74, 74, 74, 74, 74, 76, 78, 47, 47, 8, 8, 8, 47, 47, 8, 8, 8, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 80, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 81, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 82, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 83, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 84, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 85, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 86, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 87, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 88, 47, 47, 47, 47, 47, 47, 47, 47, 89, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 90, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 91, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 92, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 93, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 94, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 95, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 96, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 97, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 98, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 99, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 100, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 101, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 102, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 103, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 104, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 105, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 106, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 107, 108, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 109, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 110, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 111, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 112, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 113, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 114, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 115, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 116, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 117, 47, 47, 47, 118, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 119, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 120, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 121, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 122, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 123, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 124, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 125, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 126, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 127, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 128, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 129, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 130, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 131, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 132, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 133, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 134, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 135, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 136, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 137, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 138, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 139, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 140, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 141, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 142, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 143, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 144, 47, 47, 47, 47, 47, 47, 145, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 146, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 147, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 148, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 149, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 150, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 151, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 152, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 153, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 154, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 155, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 156, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 157, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 158, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 159, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 160, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 161, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 162, 47, 47, 47, 47, 47, 163, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 164, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 165, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 166, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 167, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 168, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 169, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 170, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 79, 79, 79, 47, 47, 79, 79, 79, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 171, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 22, 0 ,
50
- ]
51
-
52
- class << self
53
- attr_accessor :_graphql_lexer_index_defaults
54
- private :_graphql_lexer_index_defaults, :_graphql_lexer_index_defaults=
55
- end
56
- self._graphql_lexer_index_defaults = [
57
- 0, 1, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 8, 18, 8, 0, 22, 25, 25, 25, 25, 25, 30, 64, 1, 67, 68, 68, 9, 9, 9, 35, 65, 74, 77, 77, 74, 65, 8, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 25, 0 ,
58
- ]
59
-
60
- class << self
61
- attr_accessor :_graphql_lexer_trans_cond_spaces
62
- private :_graphql_lexer_trans_cond_spaces, :_graphql_lexer_trans_cond_spaces=
63
- end
64
- self._graphql_lexer_trans_cond_spaces = [
65
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0 ,
66
- ]
67
-
68
- class << self
69
- attr_accessor :_graphql_lexer_cond_targs
70
- private :_graphql_lexer_cond_targs, :_graphql_lexer_cond_targs=
71
- end
72
- self._graphql_lexer_cond_targs = [
73
- 23, 1, 23, 2, 3, 4, 5, 6, 23, 7, 8, 10, 9, 27, 11, 12, 29, 35, 23, 36, 13, 23, 17, 125, 18, 0, 19, 20, 21, 22, 23, 24, 23, 23, 25, 32, 23, 23, 23, 23, 33, 38, 34, 37, 23, 23, 23, 39, 23, 23, 40, 48, 55, 65, 83, 90, 93, 94, 98, 116, 121, 23, 23, 23, 23, 23, 26, 23, 23, 28, 23, 30, 31, 23, 23, 14, 15, 23, 16, 23, 41, 42, 43, 44, 45, 46, 47, 39, 49, 51, 50, 39, 52, 53, 54, 39, 56, 59, 57, 58, 39, 60, 61, 62, 63, 64, 39, 66, 74, 67, 68, 69, 70, 71, 72, 73, 39, 75, 77, 76, 39, 78, 79, 80, 81, 82, 39, 84, 85, 86, 87, 88, 89, 39, 91, 92, 39, 39, 95, 96, 97, 39, 99, 106, 100, 103, 101, 102, 39, 104, 105, 39, 107, 108, 109, 110, 111, 112, 113, 114, 115, 39, 117, 119, 118, 39, 120, 39, 122, 123, 124, 39, 0 ,
74
- ]
75
-
76
- class << self
77
- attr_accessor :_graphql_lexer_cond_actions
78
- private :_graphql_lexer_cond_actions, :_graphql_lexer_cond_actions=
79
- end
80
- self._graphql_lexer_cond_actions = [
81
- 1, 0, 2, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 4, 0, 5, 6, 0, 7, 0, 8, 0, 0, 0, 0, 0, 0, 11, 0, 12, 13, 14, 0, 15, 16, 17, 18, 0, 14, 19, 19, 20, 21, 22, 23, 24, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 27, 28, 29, 30, 31, 32, 33, 0, 34, 4, 4, 35, 36, 0, 0, 37, 0, 38, 0, 0, 0, 0, 0, 0, 0, 39, 0, 0, 0, 40, 0, 0, 0, 41, 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, 43, 0, 0, 0, 0, 0, 0, 0, 0, 0, 44, 0, 0, 0, 45, 0, 0, 0, 0, 0, 46, 0, 0, 0, 0, 0, 0, 47, 0, 0, 48, 49, 0, 0, 0, 50, 0, 0, 0, 0, 0, 0, 51, 0, 0, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 53, 0, 0, 0, 54, 0, 55, 0, 0, 0, 56, 0 ,
82
- ]
83
-
84
- class << self
85
- attr_accessor :_graphql_lexer_to_state_actions
86
- private :_graphql_lexer_to_state_actions, :_graphql_lexer_to_state_actions=
87
- end
88
- self._graphql_lexer_to_state_actions = [
89
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0 ,
90
- ]
91
-
92
- class << self
93
- attr_accessor :_graphql_lexer_from_state_actions
94
- private :_graphql_lexer_from_state_actions, :_graphql_lexer_from_state_actions=
95
- end
96
- self._graphql_lexer_from_state_actions = [
97
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0 ,
98
- ]
99
-
100
- class << self
101
- attr_accessor :_graphql_lexer_eof_trans
102
- private :_graphql_lexer_eof_trans, :_graphql_lexer_eof_trans=
103
- end
104
- self._graphql_lexer_eof_trans = [
105
- 0, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9, 9, 19, 9, 1, 0, 0, 0, 0, 0, 0, 0, 65, 66, 68, 69, 69, 69, 69, 69, 74, 66, 75, 78, 78, 75, 66, 9, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 0, 0 ,
106
- ]
107
-
108
- class << self
109
- attr_accessor :_graphql_lexer_nfa_targs
110
- private :_graphql_lexer_nfa_targs, :_graphql_lexer_nfa_targs=
111
- end
112
- self._graphql_lexer_nfa_targs = [
113
- 0, 0 ,
114
- ]
115
-
116
- class << self
117
- attr_accessor :_graphql_lexer_nfa_offsets
118
- private :_graphql_lexer_nfa_offsets, :_graphql_lexer_nfa_offsets=
119
- end
120
- self._graphql_lexer_nfa_offsets = [
121
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ,
122
- ]
123
-
124
- class << self
125
- attr_accessor :_graphql_lexer_nfa_push_actions
126
- private :_graphql_lexer_nfa_push_actions, :_graphql_lexer_nfa_push_actions=
127
- end
128
- self._graphql_lexer_nfa_push_actions = [
129
- 0, 0 ,
130
- ]
131
-
132
- class << self
133
- attr_accessor :_graphql_lexer_nfa_pop_trans
134
- private :_graphql_lexer_nfa_pop_trans, :_graphql_lexer_nfa_pop_trans=
135
- end
136
- self._graphql_lexer_nfa_pop_trans = [
137
- 0, 0 ,
138
- ]
139
-
140
- class << self
141
- attr_accessor :graphql_lexer_start
142
- end
143
- self.graphql_lexer_start = 23;
144
-
145
- class << self
146
- attr_accessor :graphql_lexer_first_final
147
- end
148
- self.graphql_lexer_first_final = 23;
149
-
150
- class << self
151
- attr_accessor :graphql_lexer_error
152
- end
153
- self.graphql_lexer_error = 0;
154
-
155
- class << self
156
- attr_accessor :graphql_lexer_en_str
157
- end
158
- self.graphql_lexer_en_str = 125;
159
-
160
- class << self
161
- attr_accessor :graphql_lexer_en_main
162
- end
163
- self.graphql_lexer_en_main = 23;
164
-
165
- def self.run_lexer(query_string)
166
- data = query_string.unpack("c*")
167
- eof = data.length
168
-
169
- # Since `Lexer` is a module, store all lexer state
170
- # in this local variable:
171
- meta = {
172
- line: 1,
173
- col: 1,
174
- data: data,
175
- tokens: [],
176
- previous_token: nil,
177
- }
178
-
179
- p ||= 0
180
- pe ||= data.length
181
-
182
- begin
183
- cs = graphql_lexer_start;
184
- ts = 0;
185
- te = 0;
186
- act = 0;
187
-
188
- end
189
- begin
190
- _trans = 0;
191
- _have = 0;
192
- _cont = 1;
193
- _keys = 0;
194
- _inds = 0;
195
- while ( _cont == 1 )
196
- begin
197
- if ( cs == 0 )
198
- _cont = 0;
199
-
200
- end
201
- _have = 0;
202
- if ( p == pe )
203
- begin
204
- if ( p == eof )
205
- begin
206
- if ( _graphql_lexer_eof_trans[cs] > 0 )
207
- begin
208
- _trans = _graphql_lexer_eof_trans[cs] - 1;
209
- _have = 1;
210
-
211
- end
212
-
213
- end
214
- if ( _have == 0 )
215
- begin
216
-
217
- end
218
-
219
- end
220
-
221
- end
222
-
223
- end
224
- if ( _have == 0 )
225
- _cont = 0;
226
-
227
- end
228
-
229
- end
230
-
231
- end
232
- if ( _cont == 1 )
233
- begin
234
- if ( _have == 0 )
235
- begin
236
- case _graphql_lexer_from_state_actions[cs]
237
- when -2 then
238
- begin
239
- end
240
- when 10 then
241
- begin
242
- begin
243
- begin
244
- ts = p;
245
-
246
- end
247
-
248
- end
249
-
250
-
251
- end
252
- end
253
- _keys = (cs<<1) ;
254
- _inds = _graphql_lexer_index_offsets[cs] ;
255
- if ( ( data[p ].ord) <= 125 && ( data[p ].ord) >= 9 )
256
- begin
257
- _ic = _graphql_lexer_char_class[( data[p ].ord) - 9];
258
- if ( _ic <= _graphql_lexer_trans_keys[_keys+1 ]&& _ic >= _graphql_lexer_trans_keys[_keys ] )
259
- _trans = _graphql_lexer_indicies[_inds + ( _ic - _graphql_lexer_trans_keys[_keys ]) ];
260
-
261
- else
262
- _trans = _graphql_lexer_index_defaults[cs];
263
-
264
- end
265
-
266
- end
267
-
268
- else
269
- begin
270
- _trans = _graphql_lexer_index_defaults[cs];
271
-
272
- end
273
-
274
- end
275
-
276
- end
277
-
278
- end
279
- if ( _cont == 1 )
280
- begin
281
- cs = _graphql_lexer_cond_targs[_trans];
282
- case _graphql_lexer_cond_actions[_trans]
283
- when -2 then
284
- begin
285
- end
286
- when 14 then
287
- begin
288
- begin
289
- begin
290
- te = p+1;
291
-
292
- end
293
-
294
- end
295
-
296
- end
297
- when 8 then
298
- begin
299
- begin
300
- begin
301
- te = p+1;
302
- begin
303
- emit_string(ts, te, meta, block: false)
304
- end
305
-
306
- end
307
-
308
- end
309
-
310
- end
311
- when 28 then
312
- begin
313
- begin
314
- begin
315
- te = p+1;
316
- begin
317
- emit(:RCURLY, ts, te, meta, "}")
318
- end
319
-
320
- end
321
-
322
- end
323
-
324
- end
325
- when 26 then
326
- begin
327
- begin
328
- begin
329
- te = p+1;
330
- begin
331
- emit(:LCURLY, ts, te, meta, "{")
332
- end
333
-
334
- end
335
-
336
- end
337
-
338
- end
339
- when 18 then
340
- begin
341
- begin
342
- begin
343
- te = p+1;
344
- begin
345
- emit(:RPAREN, ts, te, meta, ")")
346
- end
347
-
348
- end
349
-
350
- end
351
-
352
- end
353
- when 17 then
354
- begin
355
- begin
356
- begin
357
- te = p+1;
358
- begin
359
- emit(:LPAREN, ts, te, meta, "(")
360
- end
361
-
362
- end
363
-
364
- end
365
-
366
- end
367
- when 25 then
368
- begin
369
- begin
370
- begin
371
- te = p+1;
372
- begin
373
- emit(:RBRACKET, ts, te, meta, "]")
374
- end
375
-
376
- end
377
-
378
- end
379
-
380
- end
381
- when 24 then
382
- begin
383
- begin
384
- begin
385
- te = p+1;
386
- begin
387
- emit(:LBRACKET, ts, te, meta, "[")
388
- end
389
-
390
- end
391
-
392
- end
393
-
394
- end
395
- when 20 then
396
- begin
397
- begin
398
- begin
399
- te = p+1;
400
- begin
401
- emit(:COLON, ts, te, meta, ":")
402
- end
403
-
404
- end
405
-
406
- end
407
-
408
- end
409
- when 2 then
410
- begin
411
- begin
412
- begin
413
- te = p+1;
414
- begin
415
- emit_string(ts, te, meta, block: false)
416
- end
417
-
418
- end
419
-
420
- end
421
-
422
- end
423
- when 34 then
424
- begin
425
- begin
426
- begin
427
- te = p+1;
428
- begin
429
- emit_string(ts, te, meta, block: true)
430
- end
431
-
432
- end
433
-
434
- end
435
-
436
- end
437
- when 15 then
438
- begin
439
- begin
440
- begin
441
- te = p+1;
442
- begin
443
- emit(:VAR_SIGN, ts, te, meta, "$")
444
- end
445
-
446
- end
447
-
448
- end
449
-
450
- end
451
- when 22 then
452
- begin
453
- begin
454
- begin
455
- te = p+1;
456
- begin
457
- emit(:DIR_SIGN, ts, te, meta, "@")
458
- end
459
-
460
- end
461
-
462
- end
463
-
464
- end
465
- when 7 then
466
- begin
467
- begin
468
- begin
469
- te = p+1;
470
- begin
471
- emit(:ELLIPSIS, ts, te, meta, "...")
472
- end
473
-
474
- end
475
-
476
- end
477
-
478
- end
479
- when 21 then
480
- begin
481
- begin
482
- begin
483
- te = p+1;
484
- begin
485
- emit(:EQUALS, ts, te, meta, "=")
486
- end
487
-
488
- end
489
-
490
- end
491
-
492
- end
493
- when 13 then
494
- begin
495
- begin
496
- begin
497
- te = p+1;
498
- begin
499
- emit(:BANG, ts, te, meta, "!")
500
- end
501
-
502
- end
503
-
504
- end
505
-
506
- end
507
- when 27 then
508
- begin
509
- begin
510
- begin
511
- te = p+1;
512
- begin
513
- emit(:PIPE, ts, te, meta, "|")
514
- end
515
-
516
- end
517
-
518
- end
519
-
520
- end
521
- when 16 then
522
- begin
523
- begin
524
- begin
525
- te = p+1;
526
- begin
527
- emit(:AMP, ts, te, meta, "&")
528
- end
529
-
530
- end
531
-
532
- end
533
-
534
- end
535
- when 12 then
536
- begin
537
- begin
538
- begin
539
- te = p+1;
540
- begin
541
- meta[:line] += 1
542
- meta[:col] = 1
543
-
544
- end
545
-
546
- end
547
-
548
- end
549
-
550
- end
551
- when 11 then
552
- begin
553
- begin
554
- begin
555
- te = p+1;
556
- begin
557
- emit(:UNKNOWN_CHAR, ts, te, meta)
558
- end
559
-
560
- end
561
-
562
- end
563
-
564
- end
565
- when 36 then
566
- begin
567
- begin
568
- begin
569
- te = p;
570
- p = p - 1;
571
- begin
572
- emit(:INT, ts, te, meta)
573
- end
574
-
575
- end
576
-
577
- end
578
-
579
- end
580
- when 37 then
581
- begin
582
- begin
583
- begin
584
- te = p;
585
- p = p - 1;
586
- begin
587
- emit(:FLOAT, ts, te, meta)
588
- end
589
-
590
- end
591
-
592
- end
593
-
594
- end
595
- when 32 then
596
- begin
597
- begin
598
- begin
599
- te = p;
600
- p = p - 1;
601
- begin
602
- emit_string(ts, te, meta, block: false)
603
- end
604
-
605
- end
606
-
607
- end
608
-
609
- end
610
- when 33 then
611
- begin
612
- begin
613
- begin
614
- te = p;
615
- p = p - 1;
616
- begin
617
- emit_string(ts, te, meta, block: true)
618
- end
619
-
620
- end
621
-
622
- end
623
-
624
- end
625
- when 38 then
626
- begin
627
- begin
628
- begin
629
- te = p;
630
- p = p - 1;
631
- begin
632
- emit(:IDENTIFIER, ts, te, meta)
633
- end
634
-
635
- end
636
-
637
- end
638
-
639
- end
640
- when 35 then
641
- begin
642
- begin
643
- begin
644
- te = p;
645
- p = p - 1;
646
- begin
647
- record_comment(ts, te, meta)
648
- end
649
-
650
- end
651
-
652
- end
653
-
654
- end
655
- when 29 then
656
- begin
657
- begin
658
- begin
659
- te = p;
660
- p = p - 1;
661
- begin
662
- meta[:col] += te - ts
663
- end
664
-
665
- end
666
-
667
- end
668
-
669
- end
670
- when 30 then
671
- begin
672
- begin
673
- begin
674
- te = p;
675
- p = p - 1;
676
- begin
677
- emit(:UNKNOWN_CHAR, ts, te, meta)
678
- end
679
-
680
- end
681
-
682
- end
683
-
684
- end
685
- when 5 then
686
- begin
687
- begin
688
- begin
689
- p = ((te))-1;
690
- begin
691
- emit(:INT, ts, te, meta)
692
- end
693
-
694
- end
695
-
696
- end
697
-
698
- end
699
- when 1 then
700
- begin
701
- begin
702
- begin
703
- p = ((te))-1;
704
- begin
705
- emit(:UNKNOWN_CHAR, ts, te, meta)
706
- end
707
-
708
- end
709
-
710
- end
711
-
712
- end
713
- when 3 then
714
- begin
715
- begin
716
- begin
717
- case act
718
- when -2 then
719
- begin
720
- end
721
- when 2 then
722
- begin
723
- p = ((te))-1;
724
- begin
725
- emit(:INT, ts, te, meta)
726
- end
727
-
728
- end
729
- when 3 then
730
- begin
731
- p = ((te))-1;
732
- begin
733
- emit(:FLOAT, ts, te, meta)
734
- end
735
-
736
- end
737
- when 4 then
738
- begin
739
- p = ((te))-1;
740
- begin
741
- emit(:ON, ts, te, meta, "on")
742
- end
743
-
744
- end
745
- when 5 then
746
- begin
747
- p = ((te))-1;
748
- begin
749
- emit(:FRAGMENT, ts, te, meta, "fragment")
750
- end
751
-
752
- end
753
- when 6 then
754
- begin
755
- p = ((te))-1;
756
- begin
757
- emit(:TRUE, ts, te, meta, "true")
758
- end
759
-
760
- end
761
- when 7 then
762
- begin
763
- p = ((te))-1;
764
- begin
765
- emit(:FALSE, ts, te, meta, "false")
766
- end
767
-
768
- end
769
- when 8 then
770
- begin
771
- p = ((te))-1;
772
- begin
773
- emit(:NULL, ts, te, meta, "null")
774
- end
775
-
776
- end
777
- when 9 then
778
- begin
779
- p = ((te))-1;
780
- begin
781
- emit(:QUERY, ts, te, meta, "query")
782
- end
783
-
784
- end
785
- when 10 then
786
- begin
787
- p = ((te))-1;
788
- begin
789
- emit(:MUTATION, ts, te, meta, "mutation")
790
- end
791
-
792
- end
793
- when 11 then
794
- begin
795
- p = ((te))-1;
796
- begin
797
- emit(:SUBSCRIPTION, ts, te, meta, "subscription")
798
- end
799
-
800
- end
801
- when 12 then
802
- begin
803
- p = ((te))-1;
804
- begin
805
- emit(:SCHEMA, ts, te, meta)
806
- end
807
-
808
- end
809
- when 13 then
810
- begin
811
- p = ((te))-1;
812
- begin
813
- emit(:SCALAR, ts, te, meta)
814
- end
815
-
816
- end
817
- when 14 then
818
- begin
819
- p = ((te))-1;
820
- begin
821
- emit(:TYPE, ts, te, meta)
822
- end
823
-
824
- end
825
- when 15 then
826
- begin
827
- p = ((te))-1;
828
- begin
829
- emit(:EXTEND, ts, te, meta)
830
- end
831
-
832
- end
833
- when 16 then
834
- begin
835
- p = ((te))-1;
836
- begin
837
- emit(:IMPLEMENTS, ts, te, meta)
838
- end
839
-
840
- end
841
- when 17 then
842
- begin
843
- p = ((te))-1;
844
- begin
845
- emit(:INTERFACE, ts, te, meta)
846
- end
847
-
848
- end
849
- when 18 then
850
- begin
851
- p = ((te))-1;
852
- begin
853
- emit(:UNION, ts, te, meta)
854
- end
855
-
856
- end
857
- when 19 then
858
- begin
859
- p = ((te))-1;
860
- begin
861
- emit(:ENUM, ts, te, meta)
862
- end
863
-
864
- end
865
- when 20 then
866
- begin
867
- p = ((te))-1;
868
- begin
869
- emit(:INPUT, ts, te, meta)
870
- end
871
-
872
- end
873
- when 21 then
874
- begin
875
- p = ((te))-1;
876
- begin
877
- emit(:DIRECTIVE, ts, te, meta)
878
- end
879
-
880
- end
881
- when 29 then
882
- begin
883
- p = ((te))-1;
884
- begin
885
- emit_string(ts, te, meta, block: false)
886
- end
887
-
888
- end
889
- when 30 then
890
- begin
891
- p = ((te))-1;
892
- begin
893
- emit_string(ts, te, meta, block: true)
894
- end
895
-
896
- end
897
- when 38 then
898
- begin
899
- p = ((te))-1;
900
- begin
901
- emit(:IDENTIFIER, ts, te, meta)
902
- end
903
-
904
-
905
- end
906
- end
907
-
908
- end
909
-
910
-
911
- end
912
-
913
- end
914
- when 19 then
915
- begin
916
- begin
917
- begin
918
- te = p+1;
919
-
920
- end
921
-
922
- end
923
- begin
924
- begin
925
- act = 2;
926
-
927
- end
928
-
929
- end
930
-
931
- end
932
- when 6 then
933
- begin
934
- begin
935
- begin
936
- te = p+1;
937
-
938
- end
939
-
940
- end
941
- begin
942
- begin
943
- act = 3;
944
-
945
- end
946
-
947
- end
948
-
949
- end
950
- when 49 then
951
- begin
952
- begin
953
- begin
954
- te = p+1;
955
-
956
- end
957
-
958
- end
959
- begin
960
- begin
961
- act = 4;
962
-
963
- end
964
-
965
- end
966
-
967
- end
968
- when 43 then
969
- begin
970
- begin
971
- begin
972
- te = p+1;
973
-
974
- end
975
-
976
- end
977
- begin
978
- begin
979
- act = 5;
980
-
981
- end
982
-
983
- end
984
-
985
- end
986
- when 54 then
987
- begin
988
- begin
989
- begin
990
- te = p+1;
991
-
992
- end
993
-
994
- end
995
- begin
996
- begin
997
- act = 6;
998
-
999
- end
1000
-
1001
- end
1002
-
1003
- end
1004
- when 42 then
1005
- begin
1006
- begin
1007
- begin
1008
- te = p+1;
1009
-
1010
- end
1011
-
1012
- end
1013
- begin
1014
- begin
1015
- act = 7;
1016
-
1017
- end
1018
-
1019
- end
1020
-
1021
- end
1022
- when 48 then
1023
- begin
1024
- begin
1025
- begin
1026
- te = p+1;
1027
-
1028
- end
1029
-
1030
- end
1031
- begin
1032
- begin
1033
- act = 8;
1034
-
1035
- end
1036
-
1037
- end
1038
-
1039
- end
1040
- when 50 then
1041
- begin
1042
- begin
1043
- begin
1044
- te = p+1;
1045
-
1046
- end
1047
-
1048
- end
1049
- begin
1050
- begin
1051
- act = 9;
1052
-
1053
- end
1054
-
1055
- end
1056
-
1057
- end
1058
- when 47 then
1059
- begin
1060
- begin
1061
- begin
1062
- te = p+1;
1063
-
1064
- end
1065
-
1066
- end
1067
- begin
1068
- begin
1069
- act = 10;
1070
-
1071
- end
1072
-
1073
- end
1074
-
1075
- end
1076
- when 53 then
1077
- begin
1078
- begin
1079
- begin
1080
- te = p+1;
1081
-
1082
- end
1083
-
1084
- end
1085
- begin
1086
- begin
1087
- act = 11;
1088
-
1089
- end
1090
-
1091
- end
1092
-
1093
- end
1094
- when 52 then
1095
- begin
1096
- begin
1097
- begin
1098
- te = p+1;
1099
-
1100
- end
1101
-
1102
- end
1103
- begin
1104
- begin
1105
- act = 12;
1106
-
1107
- end
1108
-
1109
- end
1110
-
1111
- end
1112
- when 51 then
1113
- begin
1114
- begin
1115
- begin
1116
- te = p+1;
1117
-
1118
- end
1119
-
1120
- end
1121
- begin
1122
- begin
1123
- act = 13;
1124
-
1125
- end
1126
-
1127
- end
1128
-
1129
- end
1130
- when 55 then
1131
- begin
1132
- begin
1133
- begin
1134
- te = p+1;
1135
-
1136
- end
1137
-
1138
- end
1139
- begin
1140
- begin
1141
- act = 14;
1142
-
1143
- end
1144
-
1145
- end
1146
-
1147
- end
1148
- when 41 then
1149
- begin
1150
- begin
1151
- begin
1152
- te = p+1;
1153
-
1154
- end
1155
-
1156
- end
1157
- begin
1158
- begin
1159
- act = 15;
1160
-
1161
- end
1162
-
1163
- end
1164
-
1165
- end
1166
- when 44 then
1167
- begin
1168
- begin
1169
- begin
1170
- te = p+1;
1171
-
1172
- end
1173
-
1174
- end
1175
- begin
1176
- begin
1177
- act = 16;
1178
-
1179
- end
1180
-
1181
- end
1182
-
1183
- end
1184
- when 46 then
1185
- begin
1186
- begin
1187
- begin
1188
- te = p+1;
1189
-
1190
- end
1191
-
1192
- end
1193
- begin
1194
- begin
1195
- act = 17;
1196
-
1197
- end
1198
-
1199
- end
1200
-
1201
- end
1202
- when 56 then
1203
- begin
1204
- begin
1205
- begin
1206
- te = p+1;
1207
-
1208
- end
1209
-
1210
- end
1211
- begin
1212
- begin
1213
- act = 18;
1214
-
1215
- end
1216
-
1217
- end
1218
-
1219
- end
1220
- when 40 then
1221
- begin
1222
- begin
1223
- begin
1224
- te = p+1;
1225
-
1226
- end
1227
-
1228
- end
1229
- begin
1230
- begin
1231
- act = 19;
1232
-
1233
- end
1234
-
1235
- end
1236
-
1237
- end
1238
- when 45 then
1239
- begin
1240
- begin
1241
- begin
1242
- te = p+1;
1243
-
1244
- end
1245
-
1246
- end
1247
- begin
1248
- begin
1249
- act = 20;
1250
-
1251
- end
1252
-
1253
- end
1254
-
1255
- end
1256
- when 39 then
1257
- begin
1258
- begin
1259
- begin
1260
- te = p+1;
1261
-
1262
- end
1263
-
1264
- end
1265
- begin
1266
- begin
1267
- act = 21;
1268
-
1269
- end
1270
-
1271
- end
1272
-
1273
- end
1274
- when 31 then
1275
- begin
1276
- begin
1277
- begin
1278
- te = p+1;
1279
-
1280
- end
1281
-
1282
- end
1283
- begin
1284
- begin
1285
- act = 29;
1286
-
1287
- end
1288
-
1289
- end
1290
-
1291
- end
1292
- when 4 then
1293
- begin
1294
- begin
1295
- begin
1296
- te = p+1;
1297
-
1298
- end
1299
-
1300
- end
1301
- begin
1302
- begin
1303
- act = 30;
1304
-
1305
- end
1306
-
1307
- end
1308
-
1309
- end
1310
- when 23 then
1311
- begin
1312
- begin
1313
- begin
1314
- te = p+1;
1315
-
1316
- end
1317
-
1318
- end
1319
- begin
1320
- begin
1321
- act = 38;
1322
-
1323
- end
1324
-
1325
- end
1326
-
1327
-
1328
- end
1329
- end
1330
- case _graphql_lexer_to_state_actions[cs]
1331
- when -2 then
1332
- begin
1333
- end
1334
- when 9 then
1335
- begin
1336
- begin
1337
- begin
1338
- ts = 0;
1339
-
1340
- end
1341
-
1342
- end
1343
-
1344
-
1345
- end
1346
- end
1347
- if ( cs == 0 )
1348
- _cont = 0;
1349
-
1350
- end
1351
- if ( _cont == 1 )
1352
- p += 1;
1353
-
1354
- end
1355
-
1356
- end
1357
-
1358
- end
1359
-
1360
- end
1361
-
1362
- end
1363
-
1364
- end
1365
-
1366
- end
1367
-
1368
- end
1369
- meta[:tokens]
1370
- end
3
+ require "strscan"
1371
4
 
1372
- def self.record_comment(ts, te, meta)
1373
- token = GraphQL::Language::Token.new(
1374
- :COMMENT,
1375
- meta[:data][ts, te - ts].pack(PACK_DIRECTIVE).force_encoding(UTF_8_ENCODING),
1376
- meta[:line],
1377
- meta[:col],
1378
- meta[:previous_token],
1379
- )
1380
-
1381
- meta[:previous_token] = token
1382
-
1383
- meta[:col] += te - ts
1384
- end
1385
-
1386
- def self.emit(token_name, ts, te, meta, token_value = nil)
1387
- token_value ||= meta[:data][ts, te - ts].pack(PACK_DIRECTIVE).force_encoding(UTF_8_ENCODING)
1388
- meta[:tokens] << token = GraphQL::Language::Token.new(
1389
- token_name,
1390
- token_value,
1391
- meta[:line],
1392
- meta[:col],
1393
- meta[:previous_token],
1394
- )
1395
- meta[:previous_token] = token
1396
- # Bump the column counter for the next token
1397
- meta[:col] += te - ts
1398
- end
1399
-
1400
- ESCAPES = /\\["\\\/bfnrt]/
1401
- ESCAPES_REPLACE = {
1402
- '\\"' => '"',
1403
- "\\\\" => "\\",
1404
- "\\/" => '/',
1405
- "\\b" => "\b",
1406
- "\\f" => "\f",
1407
- "\\n" => "\n",
1408
- "\\r" => "\r",
1409
- "\\t" => "\t",
1410
- }
1411
-
1412
- UTF_8 = /\\u[\dAa-f]{4}/i
1413
- UTF_8_REPLACE = ->(m) { [m[-4..-1].to_i(16)].pack('U'.freeze) }
1414
-
1415
- VALID_STRING = /\A(?:[^\\]|#{ESCAPES}|#{UTF_8})*\z/o
1416
-
1417
- PACK_DIRECTIVE = "c*"
1418
- UTF_8_ENCODING = "UTF-8"
1419
-
1420
- def self.emit_string(ts, te, meta, block:)
1421
- quotes_length = block ? 3 : 1
1422
- value = meta[:data][ts + quotes_length, te - ts - 2 * quotes_length].pack(PACK_DIRECTIVE).force_encoding(UTF_8_ENCODING) || ''
1423
- line_incr = 0
1424
- if block && !value.length.zero?
1425
- line_incr = value.count("\n")
1426
- value = GraphQL::Language::BlockString.trim_whitespace(value)
1427
- end
1428
- # TODO: replace with `String#match?` when we support only Ruby 2.4+
1429
- # (It's faster: https://bugs.ruby-lang.org/issues/8110)
1430
- if !value.valid_encoding? || value !~ VALID_STRING
1431
- meta[:tokens] << token = GraphQL::Language::Token.new(
1432
- :BAD_UNICODE_ESCAPE,
1433
- value,
1434
- meta[:line],
1435
- meta[:col],
1436
- meta[:previous_token],
1437
- )
1438
- else
1439
- replace_escaped_characters_in_place(value)
1440
-
1441
- if !value.valid_encoding?
1442
- meta[:tokens] << token = GraphQL::Language::Token.new(
1443
- :BAD_UNICODE_ESCAPE,
1444
- value,
1445
- meta[:line],
1446
- meta[:col],
1447
- meta[:previous_token],
1448
- )
1449
- else
1450
- meta[:tokens] << token = GraphQL::Language::Token.new(
1451
- :STRING,
1452
- value,
1453
- meta[:line],
1454
- meta[:col],
1455
- meta[:previous_token],
1456
- )
1457
- end
1458
- end
1459
-
1460
- meta[:previous_token] = token
1461
- meta[:col] += te - ts
1462
- meta[:line] += line_incr
1463
- end
1464
- end
1465
- end
5
+ module GraphQL
6
+ module Language
7
+ module Lexer
8
+ IDENTIFIER = /[_A-Za-z][_0-9A-Za-z]*/
9
+ NEWLINE = /[\c\r\n]/
10
+ BLANK = /[, \t]+/
11
+ COMMENT = /#[^\n\r]*/
12
+ INT = /[-]?(?:[0]|[1-9][0-9]*)/
13
+ FLOAT_DECIMAL = /[.][0-9]+/
14
+ FLOAT_EXP = /[eE][+-]?[0-9]+/
15
+ FLOAT = /#{INT}(#{FLOAT_DECIMAL}#{FLOAT_EXP}|#{FLOAT_DECIMAL}|#{FLOAT_EXP})/
16
+
17
+ module Literals
18
+ ON = /on\b/
19
+ FRAGMENT = /fragment\b/
20
+ TRUE = /true\b/
21
+ FALSE = /false\b/
22
+ NULL = /null\b/
23
+ QUERY = /query\b/
24
+ MUTATION = /mutation\b/
25
+ SUBSCRIPTION = /subscription\b/
26
+ SCHEMA = /schema\b/
27
+ SCALAR = /scalar\b/
28
+ TYPE = /type\b/
29
+ EXTEND = /extend\b/
30
+ IMPLEMENTS = /implements\b/
31
+ INTERFACE = /interface\b/
32
+ UNION = /union\b/
33
+ ENUM = /enum\b/
34
+ INPUT = /input\b/
35
+ DIRECTIVE = /directive\b/
36
+ REPEATABLE = /repeatable\b/
37
+ LCURLY = '{'
38
+ RCURLY = '}'
39
+ LPAREN = '('
40
+ RPAREN = ')'
41
+ LBRACKET = '['
42
+ RBRACKET = ']'
43
+ COLON = ':'
44
+ VAR_SIGN = '$'
45
+ DIR_SIGN = '@'
46
+ ELLIPSIS = '...'
47
+ EQUALS = '='
48
+ BANG = '!'
49
+ PIPE = '|'
50
+ AMP = '&'
51
+ end
52
+
53
+ include Literals
54
+
55
+ QUOTE = '"'
56
+ UNICODE_DIGIT = /[0-9A-Za-z]/
57
+ FOUR_DIGIT_UNICODE = /#{UNICODE_DIGIT}{4}/
58
+ N_DIGIT_UNICODE = %r{#{LCURLY}#{UNICODE_DIGIT}{4,}#{RCURLY}}x
59
+ UNICODE_ESCAPE = %r{\\u(?:#{FOUR_DIGIT_UNICODE}|#{N_DIGIT_UNICODE})}
60
+ # # https://graphql.github.io/graphql-spec/June2018/#sec-String-Value
61
+ STRING_ESCAPE = %r{[\\][\\/bfnrt]}
62
+ BLOCK_QUOTE = '"""'
63
+ ESCAPED_QUOTE = /\\"/;
64
+ STRING_CHAR = /#{ESCAPED_QUOTE}|[^"\\]|#{UNICODE_ESCAPE}|#{STRING_ESCAPE}/
65
+
66
+ LIT_NAME_LUT = Literals.constants.each_with_object({}) { |n, o|
67
+ key = Literals.const_get(n)
68
+ key = key.is_a?(Regexp) ? key.source.gsub(/(\\b|\\)/, '') : key
69
+ o[key] = n
70
+ }
71
+
72
+ LIT = Regexp.union(Literals.constants.map { |n| Literals.const_get(n) })
73
+
74
+ QUOTED_STRING = %r{#{QUOTE} (?:#{STRING_CHAR})* #{QUOTE}}x
75
+ BLOCK_STRING = %r{
76
+ #{BLOCK_QUOTE}
77
+ (?: [^"\\] | # Any characters that aren't a quote or slash
78
+ (?<!") ["]{1,2} (?!") | # Any quotes that don't have quotes next to them
79
+ \\"{0,3}(?!") | # A slash followed by <= 3 quotes that aren't followed by a quote
80
+ \\ | # A slash
81
+ "{1,2}(?!") # 1 or 2 " followed by something that isn't a quote
82
+ )*
83
+ (?:"")?
84
+ #{BLOCK_QUOTE}
85
+ }xm
86
+
87
+ # # catch-all for anything else. must be at the bottom for precedence.
88
+ UNKNOWN_CHAR = /./
89
+
90
+ def self.tokenize string
91
+ meta = {
92
+ line: 1,
93
+ col: 1,
94
+ tokens: [],
95
+ previous_token: nil,
96
+ }
97
+
98
+ unless string.valid_encoding?
99
+ emit(:BAD_UNICODE_ESCAPE, 0, 0, meta, string)
100
+ return meta[:tokens]
101
+ end
102
+
103
+ scan = StringScanner.new string
104
+
105
+ while !scan.eos?
106
+ pos = scan.pos
107
+
108
+ case
109
+ when str = scan.scan(FLOAT) then emit(:FLOAT, pos, scan.pos, meta, str)
110
+ when str = scan.scan(INT) then emit(:INT, pos, scan.pos, meta, str)
111
+ when str = scan.scan(LIT) then emit(LIT_NAME_LUT[str], pos, scan.pos, meta, -str)
112
+ when str = scan.scan(IDENTIFIER) then emit(:IDENTIFIER, pos, scan.pos, meta, str)
113
+ when str = scan.scan(BLOCK_STRING) then emit_block(pos, scan.pos, meta, str.gsub(/^#{BLOCK_QUOTE}|#{BLOCK_QUOTE}$/, ''))
114
+ when str = scan.scan(QUOTED_STRING) then emit_string(pos, scan.pos, meta, str.gsub(/^"|"$/, ''))
115
+ when str = scan.scan(COMMENT) then record_comment(pos, scan.pos, meta, str)
116
+ when str = scan.scan(NEWLINE)
117
+ meta[:line] += 1
118
+ meta[:col] = 1
119
+ when scan.scan(BLANK)
120
+ meta[:col] += scan.pos - pos
121
+ when str = scan.scan(UNKNOWN_CHAR) then emit(:UNKNOWN_CHAR, pos, scan.pos, meta, str)
122
+ else
123
+ # This should never happen since `UNKNOWN_CHAR` ensures we make progress
124
+ raise "Unknown string?"
125
+ end
126
+ end
127
+
128
+ meta[:tokens]
129
+ end
130
+
131
+ def self.emit(token_name, ts, te, meta, token_value)
132
+ meta[:tokens] << token = [
133
+ token_name,
134
+ meta[:line],
135
+ meta[:col],
136
+ token_value,
137
+ meta[:previous_token],
138
+ ]
139
+ meta[:previous_token] = token
140
+ # Bump the column counter for the next token
141
+ meta[:col] += te - ts
142
+ end
143
+
144
+ # Replace any escaped unicode or whitespace with the _actual_ characters
145
+ # To avoid allocating more strings, this modifies the string passed into it
146
+ def self.replace_escaped_characters_in_place(raw_string)
147
+ raw_string.gsub!(ESCAPES, ESCAPES_REPLACE)
148
+ raw_string.gsub!(UTF_8) do |_matched_str|
149
+ codepoint_1 = ($1 || $2).to_i(16)
150
+ codepoint_2 = $3
151
+
152
+ if codepoint_2
153
+ codepoint_2 = codepoint_2.to_i(16)
154
+ if (codepoint_1 >= 0xD800 && codepoint_1 <= 0xDBFF) && # leading surrogate
155
+ (codepoint_2 >= 0xDC00 && codepoint_2 <= 0xDFFF) # trailing surrogate
156
+ # A surrogate pair
157
+ combined = ((codepoint_1 - 0xD800) * 0x400) + (codepoint_2 - 0xDC00) + 0x10000
158
+ [combined].pack('U'.freeze)
159
+ else
160
+ # Two separate code points
161
+ [codepoint_1].pack('U'.freeze) + [codepoint_2].pack('U'.freeze)
162
+ end
163
+ else
164
+ [codepoint_1].pack('U'.freeze)
165
+ end
166
+ end
167
+ nil
168
+ end
169
+
170
+ def self.record_comment(ts, te, meta, str)
171
+ token = [
172
+ :COMMENT,
173
+ meta[:line],
174
+ meta[:col],
175
+ str,
176
+ meta[:previous_token],
177
+ ]
178
+
179
+ meta[:previous_token] = token
180
+
181
+ meta[:col] += te - ts
182
+ end
183
+
184
+ ESCAPES = /\\["\\\/bfnrt]/
185
+ ESCAPES_REPLACE = {
186
+ '\\"' => '"',
187
+ "\\\\" => "\\",
188
+ "\\/" => '/',
189
+ "\\b" => "\b",
190
+ "\\f" => "\f",
191
+ "\\n" => "\n",
192
+ "\\r" => "\r",
193
+ "\\t" => "\t",
194
+ }
195
+ UTF_8 = /\\u(?:([\dAa-f]{4})|\{([\da-f]{4,})\})(?:\\u([\dAa-f]{4}))?/i
196
+ VALID_STRING = /\A(?:[^\\]|#{ESCAPES}|#{UTF_8})*\z/o
197
+
198
+ def self.emit_block(ts, te, meta, value)
199
+ line_incr = value.count("\n")
200
+ value = GraphQL::Language::BlockString.trim_whitespace(value)
201
+ emit_string(ts, te, meta, value)
202
+ meta[:line] += line_incr
203
+ end
204
+
205
+ def self.emit_string(ts, te, meta, value)
206
+ if !value.valid_encoding? || !value.match?(VALID_STRING)
207
+ emit(:BAD_UNICODE_ESCAPE, ts, te, meta, value)
208
+ else
209
+ replace_escaped_characters_in_place(value)
210
+
211
+ if !value.valid_encoding?
212
+ emit(:BAD_UNICODE_ESCAPE, ts, te, meta, value)
213
+ else
214
+ emit(:STRING, ts, te, meta, value)
215
+ end
216
+ end
217
+ end
218
+ end
219
+ end
1466
220
  end