rails-graphql 0.2.1 → 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (315) hide show
  1. checksums.yaml +4 -4
  2. data/ext/console.rb +18 -0
  3. data/ext/extconf.h +3 -0
  4. data/ext/extconf.rb +1 -54
  5. data/ext/gql_parser.c +631 -0
  6. data/ext/gql_parser.h +21 -0
  7. data/ext/shared.c +477 -0
  8. data/ext/shared.h +177 -0
  9. data/lib/generators/graphql/channel_generator.rb +27 -0
  10. data/lib/generators/graphql/controller_generator.rb +9 -4
  11. data/lib/generators/graphql/install_generator.rb +49 -0
  12. data/lib/generators/graphql/schema_generator.rb +9 -4
  13. data/lib/generators/graphql/templates/channel.erb +7 -0
  14. data/lib/generators/graphql/templates/config.rb +97 -0
  15. data/lib/generators/graphql/templates/controller.erb +2 -0
  16. data/lib/generators/graphql/templates/schema.erb +5 -3
  17. data/lib/gql_parser.so +0 -0
  18. data/lib/rails/graphql/adapters/mysql_adapter.rb +59 -0
  19. data/lib/rails/graphql/adapters/pg_adapter.rb +25 -22
  20. data/lib/rails/graphql/adapters/sqlite_adapter.rb +17 -14
  21. data/lib/rails/graphql/alternative/field_set.rb +48 -0
  22. data/lib/rails/graphql/alternative/mutation.rb +17 -0
  23. data/lib/rails/graphql/alternative/query.rb +98 -0
  24. data/lib/rails/graphql/alternative/subscription.rb +18 -0
  25. data/lib/rails/graphql/alternative.rb +20 -0
  26. data/lib/rails/graphql/argument.rb +25 -26
  27. data/lib/rails/graphql/callback.rb +30 -14
  28. data/lib/rails/graphql/collectors/hash_collector.rb +26 -7
  29. data/lib/rails/graphql/collectors/idented_collector.rb +10 -7
  30. data/lib/rails/graphql/collectors/json_collector.rb +43 -17
  31. data/lib/rails/graphql/collectors.rb +4 -4
  32. data/lib/rails/graphql/config.rb +154 -23
  33. data/lib/rails/graphql/directive/cached_directive.rb +33 -0
  34. data/lib/rails/graphql/directive/deprecated_directive.rb +10 -10
  35. data/lib/rails/graphql/directive/include_directive.rb +4 -4
  36. data/lib/rails/graphql/directive/skip_directive.rb +4 -4
  37. data/lib/rails/graphql/directive/specified_by_directive.rb +24 -0
  38. data/lib/rails/graphql/directive.rb +134 -73
  39. data/lib/rails/graphql/errors.rb +33 -4
  40. data/lib/rails/graphql/event.rb +21 -9
  41. data/lib/rails/graphql/field/authorized_field.rb +17 -6
  42. data/lib/rails/graphql/field/input_field.rb +8 -12
  43. data/lib/rails/graphql/field/mutation_field.rb +43 -9
  44. data/lib/rails/graphql/field/output_field.rb +112 -12
  45. data/lib/rails/graphql/field/proxied_field.rb +35 -26
  46. data/lib/rails/graphql/field/resolved_field.rb +27 -25
  47. data/lib/rails/graphql/field/scoped_config.rb +10 -4
  48. data/lib/rails/graphql/field/subscription_field.rb +123 -0
  49. data/lib/rails/graphql/field/typed_field.rb +69 -24
  50. data/lib/rails/graphql/field.rb +89 -74
  51. data/lib/rails/graphql/global_id.rb +89 -0
  52. data/lib/rails/graphql/helpers/attribute_delegator.rb +5 -5
  53. data/lib/rails/graphql/helpers/inherited_collection/array.rb +51 -0
  54. data/lib/rails/graphql/helpers/inherited_collection/base.rb +45 -0
  55. data/lib/rails/graphql/helpers/inherited_collection/hash.rb +88 -0
  56. data/lib/rails/graphql/helpers/inherited_collection.rb +25 -76
  57. data/lib/rails/graphql/helpers/instantiable.rb +15 -0
  58. data/lib/rails/graphql/helpers/leaf_from_ar.rb +7 -7
  59. data/lib/rails/graphql/helpers/registerable.rb +44 -62
  60. data/lib/rails/graphql/helpers/unregisterable.rb +16 -0
  61. data/lib/rails/graphql/helpers/with_arguments.rb +33 -28
  62. data/lib/rails/graphql/helpers/with_assignment.rb +6 -6
  63. data/lib/rails/graphql/helpers/with_callbacks.rb +28 -11
  64. data/lib/rails/graphql/helpers/with_description.rb +73 -0
  65. data/lib/rails/graphql/helpers/with_directives.rb +58 -30
  66. data/lib/rails/graphql/helpers/with_events.rb +22 -23
  67. data/lib/rails/graphql/helpers/with_fields.rb +86 -26
  68. data/lib/rails/graphql/helpers/with_global_id.rb +22 -0
  69. data/lib/rails/graphql/helpers/with_name.rb +44 -0
  70. data/lib/rails/graphql/helpers/with_namespace.rb +7 -4
  71. data/lib/rails/graphql/helpers/with_owner.rb +8 -7
  72. data/lib/rails/graphql/helpers/with_schema_fields.rb +162 -56
  73. data/lib/rails/graphql/helpers/with_validator.rb +9 -9
  74. data/lib/rails/graphql/helpers.rb +10 -3
  75. data/lib/rails/graphql/introspection.rb +43 -36
  76. data/lib/rails/graphql/railtie.rb +89 -33
  77. data/lib/rails/graphql/railties/app/base_channel.rb +10 -0
  78. data/lib/rails/graphql/railties/app/base_controller.rb +12 -0
  79. data/lib/rails/graphql/railties/app/views/_cable.js.erb +56 -0
  80. data/lib/rails/graphql/railties/app/views/_fetch.js.erb +20 -0
  81. data/lib/rails/graphql/railties/app/views/graphiql.html.erb +101 -0
  82. data/lib/rails/graphql/railties/base_generator.rb +5 -17
  83. data/lib/rails/graphql/railties/channel.rb +157 -0
  84. data/lib/rails/graphql/railties/controller.rb +91 -25
  85. data/lib/rails/graphql/railties/controller_runtime.rb +5 -5
  86. data/lib/rails/graphql/railties/log_subscriber.rb +81 -14
  87. data/lib/rails/graphql/request/arguments.rb +26 -50
  88. data/lib/rails/graphql/request/backtrace.rb +212 -0
  89. data/lib/rails/graphql/request/component/field.rb +98 -70
  90. data/lib/rails/graphql/request/component/fragment.rb +80 -26
  91. data/lib/rails/graphql/request/component/operation/subscription.rb +162 -4
  92. data/lib/rails/graphql/request/component/operation.rb +73 -34
  93. data/lib/rails/graphql/request/component/spread.rb +79 -27
  94. data/lib/rails/graphql/request/component/typename.rb +28 -13
  95. data/lib/rails/graphql/request/component.rb +77 -36
  96. data/lib/rails/graphql/request/context.rb +19 -9
  97. data/lib/rails/graphql/request/errors.rb +16 -6
  98. data/lib/rails/graphql/request/event.rb +23 -8
  99. data/lib/rails/graphql/request/helpers/directives.rb +69 -27
  100. data/lib/rails/graphql/request/helpers/selection_set.rb +57 -25
  101. data/lib/rails/graphql/request/helpers/value_writers.rb +24 -19
  102. data/lib/rails/graphql/request/prepared_data.rb +100 -0
  103. data/lib/rails/graphql/request/steps/authorizable.rb +24 -14
  104. data/lib/rails/graphql/request/steps/organizable.rb +111 -49
  105. data/lib/rails/graphql/request/steps/{prepareable.rb → preparable.rb} +21 -8
  106. data/lib/rails/graphql/request/steps/{resolveable.rb → resolvable.rb} +16 -7
  107. data/lib/rails/graphql/request/strategy/cached_strategy.rb +64 -0
  108. data/lib/rails/graphql/request/strategy/dynamic_instance.rb +6 -6
  109. data/lib/rails/graphql/request/strategy/multi_query_strategy.rb +6 -13
  110. data/lib/rails/graphql/request/strategy/sequenced_strategy.rb +9 -9
  111. data/lib/rails/graphql/request/strategy.rb +147 -77
  112. data/lib/rails/graphql/request/subscription.rb +82 -0
  113. data/lib/rails/graphql/request.rb +353 -104
  114. data/lib/rails/graphql/schema.rb +251 -106
  115. data/lib/rails/graphql/shortcuts.rb +33 -8
  116. data/lib/rails/graphql/source/active_record/builders.rb +64 -51
  117. data/lib/rails/graphql/source/active_record_source.rb +158 -82
  118. data/lib/rails/graphql/source/base.rb +83 -0
  119. data/lib/rails/graphql/source/builder.rb +115 -0
  120. data/lib/rails/graphql/source/scoped_arguments.rb +39 -21
  121. data/lib/rails/graphql/source.rb +90 -228
  122. data/lib/rails/graphql/subscription/provider/action_cable.rb +113 -0
  123. data/lib/rails/graphql/subscription/provider/base.rb +192 -0
  124. data/lib/rails/graphql/subscription/provider.rb +18 -0
  125. data/lib/rails/graphql/subscription/store/base.rb +141 -0
  126. data/lib/rails/graphql/subscription/store/memory.rb +136 -0
  127. data/lib/rails/graphql/subscription/store.rb +19 -0
  128. data/lib/rails/graphql/subscription.rb +17 -0
  129. data/lib/rails/graphql/to_gql.rb +29 -32
  130. data/lib/rails/graphql/type/creator.rb +196 -0
  131. data/lib/rails/graphql/type/enum/directive_location_enum.rb +11 -11
  132. data/lib/rails/graphql/type/enum/type_kind_enum.rb +3 -3
  133. data/lib/rails/graphql/type/enum.rb +44 -50
  134. data/lib/rails/graphql/type/input.rb +92 -25
  135. data/lib/rails/graphql/type/interface.rb +29 -28
  136. data/lib/rails/graphql/type/object/directive_object.rb +10 -9
  137. data/lib/rails/graphql/type/object/enum_value_object.rb +3 -3
  138. data/lib/rails/graphql/type/object/field_object.rb +24 -6
  139. data/lib/rails/graphql/type/object/input_value_object.rb +6 -7
  140. data/lib/rails/graphql/type/object/schema_object.rb +5 -8
  141. data/lib/rails/graphql/type/object/type_object.rb +62 -25
  142. data/lib/rails/graphql/type/object.rb +34 -26
  143. data/lib/rails/graphql/type/scalar/any_scalar.rb +30 -0
  144. data/lib/rails/graphql/type/scalar/bigint_scalar.rb +5 -5
  145. data/lib/rails/graphql/type/scalar/binary_scalar.rb +5 -3
  146. data/lib/rails/graphql/type/scalar/boolean_scalar.rb +8 -8
  147. data/lib/rails/graphql/type/scalar/date_scalar.rb +5 -3
  148. data/lib/rails/graphql/type/scalar/date_time_scalar.rb +5 -3
  149. data/lib/rails/graphql/type/scalar/decimal_scalar.rb +5 -3
  150. data/lib/rails/graphql/type/scalar/float_scalar.rb +5 -5
  151. data/lib/rails/graphql/type/scalar/id_scalar.rb +6 -5
  152. data/lib/rails/graphql/type/scalar/int_scalar.rb +6 -5
  153. data/lib/rails/graphql/type/scalar/json_scalar.rb +41 -0
  154. data/lib/rails/graphql/type/scalar/string_scalar.rb +18 -4
  155. data/lib/rails/graphql/type/scalar/time_scalar.rb +8 -6
  156. data/lib/rails/graphql/type/scalar.rb +26 -23
  157. data/lib/rails/graphql/type/union.rb +21 -18
  158. data/lib/rails/graphql/type.rb +43 -26
  159. data/lib/rails/graphql/type_map.rb +268 -165
  160. data/lib/rails/graphql/uri.rb +167 -0
  161. data/lib/rails/graphql/version.rb +19 -3
  162. data/lib/rails/graphql.rake +3 -0
  163. data/lib/rails/graphql.rb +91 -56
  164. data/lib/rails-graphql.rb +1 -1
  165. data/test/assets/en.yml +29 -0
  166. data/test/assets/introspection-mem.txt +1 -1
  167. data/test/assets/introspection.gql +2 -0
  168. data/test/assets/mem.gql +86 -99
  169. data/test/assets/mysql.gql +406 -0
  170. data/test/assets/sqlite.gql +96 -73
  171. data/test/assets/translate.gql +346 -0
  172. data/test/config.rb +19 -8
  173. data/test/graphql/schema_test.rb +14 -50
  174. data/test/graphql/source_test.rb +8 -85
  175. data/test/graphql/type/enum_test.rb +207 -203
  176. data/test/graphql/type/input_test.rb +14 -9
  177. data/test/graphql/type/interface_test.rb +12 -9
  178. data/test/graphql/type/object_test.rb +8 -2
  179. data/test/graphql/type/scalar/any_scalar_test.rb +38 -0
  180. data/test/graphql/type/scalar/boolean_scalar_test.rb +6 -3
  181. data/test/graphql/type/scalar/json_scalar_test.rb +23 -0
  182. data/test/graphql/type_map_test.rb +63 -81
  183. data/test/graphql/type_test.rb +0 -19
  184. data/test/graphql_test.rb +1 -1
  185. data/test/integration/{authorization/authorization_test.rb → authorization_test.rb} +40 -14
  186. data/test/integration/config.rb +36 -3
  187. data/test/integration/customization_test.rb +39 -0
  188. data/test/integration/global_id_test.rb +99 -0
  189. data/test/integration/memory/star_wars_introspection_test.rb +24 -16
  190. data/test/integration/memory/star_wars_query_test.rb +54 -3
  191. data/test/integration/memory/star_wars_validation_test.rb +3 -3
  192. data/test/integration/mysql/star_wars_introspection_test.rb +25 -0
  193. data/test/integration/persisted_query_test.rb +87 -0
  194. data/test/integration/resolver_precedence_test.rb +154 -0
  195. data/test/integration/schemas/memory.rb +24 -10
  196. data/test/integration/schemas/mysql.rb +62 -0
  197. data/test/integration/schemas/sqlite.rb +21 -12
  198. data/test/integration/sqlite/star_wars_global_id_test.rb +89 -0
  199. data/test/integration/sqlite/star_wars_introspection_test.rb +10 -0
  200. data/test/integration/sqlite/star_wars_query_test.rb +14 -1
  201. data/test/integration/translate_test.rb +73 -0
  202. data/test/test_ext.rb +16 -13
  203. metadata +125 -161
  204. data/ext/depend +0 -3
  205. data/ext/graphqlparser/Ast.cpp +0 -346
  206. data/ext/graphqlparser/Ast.h +0 -1214
  207. data/ext/graphqlparser/AstNode.h +0 -36
  208. data/ext/graphqlparser/AstVisitor.h +0 -137
  209. data/ext/graphqlparser/GraphQLParser.cpp +0 -76
  210. data/ext/graphqlparser/GraphQLParser.h +0 -55
  211. data/ext/graphqlparser/JsonVisitor.cpp +0 -161
  212. data/ext/graphqlparser/JsonVisitor.cpp.inc +0 -456
  213. data/ext/graphqlparser/JsonVisitor.h +0 -121
  214. data/ext/graphqlparser/JsonVisitor.h.inc +0 -110
  215. data/ext/graphqlparser/VERSION +0 -1
  216. data/ext/graphqlparser/c/GraphQLAst.cpp +0 -324
  217. data/ext/graphqlparser/c/GraphQLAst.h +0 -180
  218. data/ext/graphqlparser/c/GraphQLAstForEachConcreteType.h +0 -44
  219. data/ext/graphqlparser/c/GraphQLAstNode.cpp +0 -25
  220. data/ext/graphqlparser/c/GraphQLAstNode.h +0 -33
  221. data/ext/graphqlparser/c/GraphQLAstToJSON.cpp +0 -21
  222. data/ext/graphqlparser/c/GraphQLAstToJSON.h +0 -24
  223. data/ext/graphqlparser/c/GraphQLAstVisitor.cpp +0 -55
  224. data/ext/graphqlparser/c/GraphQLAstVisitor.h +0 -53
  225. data/ext/graphqlparser/c/GraphQLParser.cpp +0 -35
  226. data/ext/graphqlparser/c/GraphQLParser.h +0 -54
  227. data/ext/graphqlparser/dump_json_ast.cpp +0 -48
  228. data/ext/graphqlparser/lexer.lpp +0 -324
  229. data/ext/graphqlparser/parser.ypp +0 -693
  230. data/ext/graphqlparser/parsergen/lexer.cpp +0 -2633
  231. data/ext/graphqlparser/parsergen/lexer.h +0 -528
  232. data/ext/graphqlparser/parsergen/location.hh +0 -189
  233. data/ext/graphqlparser/parsergen/parser.tab.cpp +0 -3300
  234. data/ext/graphqlparser/parsergen/parser.tab.hpp +0 -646
  235. data/ext/graphqlparser/parsergen/position.hh +0 -179
  236. data/ext/graphqlparser/parsergen/stack.hh +0 -156
  237. data/ext/graphqlparser/syntaxdefs.h +0 -19
  238. data/ext/libgraphqlparser/AstNode.h +0 -36
  239. data/ext/libgraphqlparser/CMakeLists.txt +0 -148
  240. data/ext/libgraphqlparser/CONTRIBUTING.md +0 -23
  241. data/ext/libgraphqlparser/GraphQLParser.cpp +0 -76
  242. data/ext/libgraphqlparser/GraphQLParser.h +0 -55
  243. data/ext/libgraphqlparser/JsonVisitor.cpp +0 -161
  244. data/ext/libgraphqlparser/JsonVisitor.h +0 -121
  245. data/ext/libgraphqlparser/LICENSE +0 -22
  246. data/ext/libgraphqlparser/README.clang-tidy +0 -7
  247. data/ext/libgraphqlparser/README.md +0 -84
  248. data/ext/libgraphqlparser/ast/ast.ast +0 -203
  249. data/ext/libgraphqlparser/ast/ast.py +0 -61
  250. data/ext/libgraphqlparser/ast/c.py +0 -100
  251. data/ext/libgraphqlparser/ast/c.pyc +0 -0
  252. data/ext/libgraphqlparser/ast/c_impl.py +0 -61
  253. data/ext/libgraphqlparser/ast/c_impl.pyc +0 -0
  254. data/ext/libgraphqlparser/ast/c_visitor_impl.py +0 -39
  255. data/ext/libgraphqlparser/ast/c_visitor_impl.pyc +0 -0
  256. data/ext/libgraphqlparser/ast/casing.py +0 -26
  257. data/ext/libgraphqlparser/ast/casing.pyc +0 -0
  258. data/ext/libgraphqlparser/ast/cxx.py +0 -197
  259. data/ext/libgraphqlparser/ast/cxx.pyc +0 -0
  260. data/ext/libgraphqlparser/ast/cxx_impl.py +0 -61
  261. data/ext/libgraphqlparser/ast/cxx_impl.pyc +0 -0
  262. data/ext/libgraphqlparser/ast/cxx_json_visitor_header.py +0 -42
  263. data/ext/libgraphqlparser/ast/cxx_json_visitor_header.pyc +0 -0
  264. data/ext/libgraphqlparser/ast/cxx_json_visitor_impl.py +0 -80
  265. data/ext/libgraphqlparser/ast/cxx_json_visitor_impl.pyc +0 -0
  266. data/ext/libgraphqlparser/ast/cxx_visitor.py +0 -64
  267. data/ext/libgraphqlparser/ast/cxx_visitor.pyc +0 -0
  268. data/ext/libgraphqlparser/ast/js.py +0 -65
  269. data/ext/libgraphqlparser/ast/license.py +0 -10
  270. data/ext/libgraphqlparser/ast/license.pyc +0 -0
  271. data/ext/libgraphqlparser/c/GraphQLAstNode.cpp +0 -25
  272. data/ext/libgraphqlparser/c/GraphQLAstNode.h +0 -33
  273. data/ext/libgraphqlparser/c/GraphQLAstToJSON.cpp +0 -21
  274. data/ext/libgraphqlparser/c/GraphQLAstToJSON.h +0 -24
  275. data/ext/libgraphqlparser/c/GraphQLAstVisitor.cpp +0 -55
  276. data/ext/libgraphqlparser/c/GraphQLAstVisitor.h +0 -53
  277. data/ext/libgraphqlparser/c/GraphQLParser.cpp +0 -35
  278. data/ext/libgraphqlparser/c/GraphQLParser.h +0 -54
  279. data/ext/libgraphqlparser/clang-tidy-all.sh +0 -3
  280. data/ext/libgraphqlparser/cmake/version.cmake +0 -16
  281. data/ext/libgraphqlparser/dump_json_ast.cpp +0 -48
  282. data/ext/libgraphqlparser/go/README.md +0 -20
  283. data/ext/libgraphqlparser/go/callbacks.go +0 -18
  284. data/ext/libgraphqlparser/go/gotest.go +0 -64
  285. data/ext/libgraphqlparser/lexer.lpp +0 -324
  286. data/ext/libgraphqlparser/libgraphqlparser.pc.in +0 -11
  287. data/ext/libgraphqlparser/parser.ypp +0 -693
  288. data/ext/libgraphqlparser/parsergen/lexer.cpp +0 -2633
  289. data/ext/libgraphqlparser/parsergen/lexer.h +0 -528
  290. data/ext/libgraphqlparser/parsergen/location.hh +0 -189
  291. data/ext/libgraphqlparser/parsergen/parser.tab.cpp +0 -3300
  292. data/ext/libgraphqlparser/parsergen/parser.tab.hpp +0 -646
  293. data/ext/libgraphqlparser/parsergen/position.hh +0 -179
  294. data/ext/libgraphqlparser/parsergen/stack.hh +0 -156
  295. data/ext/libgraphqlparser/python/CMakeLists.txt +0 -14
  296. data/ext/libgraphqlparser/python/README.md +0 -5
  297. data/ext/libgraphqlparser/python/example.py +0 -31
  298. data/ext/libgraphqlparser/syntaxdefs.h +0 -19
  299. data/ext/libgraphqlparser/test/BuildCAPI.c +0 -5
  300. data/ext/libgraphqlparser/test/CMakeLists.txt +0 -25
  301. data/ext/libgraphqlparser/test/JsonVisitorTests.cpp +0 -28
  302. data/ext/libgraphqlparser/test/ParserTests.cpp +0 -352
  303. data/ext/libgraphqlparser/test/kitchen-sink.graphql +0 -59
  304. data/ext/libgraphqlparser/test/kitchen-sink.json +0 -1
  305. data/ext/libgraphqlparser/test/schema-kitchen-sink.graphql +0 -78
  306. data/ext/libgraphqlparser/test/schema-kitchen-sink.json +0 -1
  307. data/ext/libgraphqlparser/test/valgrind.supp +0 -33
  308. data/ext/version.cpp +0 -21
  309. data/lib/graphqlparser.so +0 -0
  310. data/lib/rails/graphql/native/functions.rb +0 -38
  311. data/lib/rails/graphql/native/location.rb +0 -41
  312. data/lib/rails/graphql/native/pointers.rb +0 -23
  313. data/lib/rails/graphql/native/visitor.rb +0 -349
  314. data/lib/rails/graphql/native.rb +0 -56
  315. data/test/integration/schemas/authorization.rb +0 -12
@@ -0,0 +1,88 @@
1
+ module Rails
2
+ module GraphQL
3
+ module Helpers
4
+ # A inherited collection of Hash that can contain simple values, arrays,
5
+ # or sets
6
+ class InheritedCollection::Hash < InheritedCollection::Base
7
+ delegate :transform_values, :transform_keys, to: :to_hash
8
+ delegate :filter_map, :map, to: :eager
9
+
10
+ # Simply go over each definition and check for the given key
11
+ def key?(value)
12
+ each_definition.any? { |definition| definition.key?(value) }
13
+ end
14
+
15
+ # Collect all the keys of all the definitions
16
+ def keys
17
+ each_definition.reverse_each.flat_map(&:keys).uniq
18
+ end
19
+
20
+ # Go over each key and value
21
+ def each
22
+ Enumerator::Lazy.new(keys) do |yielder, key|
23
+ val = self[key]
24
+ yield(key, val) if block_given?
25
+ yielder.yield(key, val)
26
+ end
27
+ end
28
+
29
+ # Go over each value exclusively
30
+ def each_value(&block)
31
+ Enumerator::Lazy.new(keys) do |yielder, key|
32
+ val = self[key]
33
+ yield(val) if block_given?
34
+ yielder.yield(val)
35
+ end
36
+ end
37
+
38
+ # Go over each key exclusively
39
+ def each_key(&block)
40
+ keys.each(&block)
41
+ end
42
+
43
+ # Get all the values by lazy iterating over all the keys
44
+ def values
45
+ keys.lazy.map(&method(:[]))
46
+ end
47
+
48
+ # Basically returns the plain result value
49
+ def to_hash
50
+ each.to_h
51
+ end
52
+
53
+ # A simple way to get the result of one single key
54
+ def [](key)
55
+ lazy[key]
56
+ end
57
+
58
+ # Build a lazy hash
59
+ def lazy
60
+ @table ||= Hash.new(&method(_combine? ? :_combined_hash : :_simple_hash))
61
+ end
62
+
63
+ private
64
+
65
+ # Check if it has to combine the values
66
+ def _combine?
67
+ @type != :hash
68
+ end
69
+
70
+ # Builds a values for a combined hash
71
+ def _combined_hash(hash, key)
72
+ hash[key] = each_definition.reverse_each.inject(nil) do |result, definition|
73
+ next result unless definition.key?(key)
74
+ next definition[key] if result.nil?
75
+ result + definition[key]
76
+ end
77
+ end
78
+
79
+ # Builds a values for a simple hash
80
+ def _simple_hash(hash, key)
81
+ hash[key] = each_definition.reverse_each do |definition|
82
+ break definition[key] if definition.key?(key)
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end
@@ -1,15 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Rails # :nodoc:
4
- module GraphQL # :nodoc:
5
- module Helpers # :nodoc:
6
- module InheritedCollection # :nodoc:
3
+ module Rails
4
+ module GraphQL
5
+ module Helpers
6
+ # Helper module that allow classes to have specific type of attributes
7
+ # that are corretly delt when it is inherited by another class. It keeps
8
+ # track of its own value and allow access to all values of the property
9
+ # in the tree,
10
+ #
11
+ # TODO: Rewrite this!
12
+ module InheritedCollection
13
+ # All possible types of inheritable values
7
14
  DEFAULT_TYPES = {
8
15
  array: '[]',
9
16
  set: 'Set.new',
10
17
  hash: '{}',
11
- hash_array: 'Hash.new { |h, k| h[k] = [] }',
12
- hash_set: 'Hash.new { |h, k| h[k] = Set.new }',
18
+ hash_array: '::Hash.new { |h, k| h[k] = [] }',
19
+ hash_set: '::Hash.new { |h, k| h[k] = Set.new }',
13
20
  }.freeze
14
21
 
15
22
  # Declare a class-level attribute whose value is both isolated and also
@@ -60,20 +67,19 @@ module Rails # :nodoc:
60
67
  type: :set
61
68
  )
62
69
  attrs.each do |name|
63
- module_eval(<<~RUBY, __FILE__, __LINE__ + 1)
64
- def self.all_#{name}
65
- ::Rails::GraphQL::Helpers::AttributeDelegator.new do
66
- fetch_inherited_#{type}('@#{name}')
67
- end
70
+ instance_eval(<<~RUBY, __FILE__, __LINE__ + 1)
71
+ def all_#{name}
72
+ return superclass.try(:all_#{name}) unless defined?(@#{name})
73
+ InheritedCollection::Base.handle(self, :@#{name}, :#{type})
68
74
  end
69
75
 
70
- def self.#{name}
76
+ def #{name}
71
77
  @#{name} ||= #{DEFAULT_TYPES[type]}
72
78
  end
73
79
  RUBY
74
80
 
75
- module_eval(<<~RUBY, __FILE__, __LINE__ + 1) if instance_predicate
76
- def self.#{name}?
81
+ instance_eval(<<~RUBY, __FILE__, __LINE__ + 1) if instance_predicate
82
+ def #{name}?
77
83
  (defined?(@#{name}) && @#{name}.present?) || superclass.try(:#{name}?)
78
84
  end
79
85
  RUBY
@@ -84,69 +90,12 @@ module Rails # :nodoc:
84
90
  end
85
91
  end
86
92
  end
87
-
88
- protected
89
-
90
- # Combine an inherited list of arrays
91
- def fetch_inherited_array(ivar)
92
- inherited_ancestors.each_with_object([]) do |klass, result|
93
- next result unless klass.instance_variable_defined?(ivar)
94
- val = klass.instance_variable_get(ivar)
95
- result.merge(val) unless val.blank?
96
- end
97
- end
98
-
99
- # Combine an inherited list of set objects
100
- def fetch_inherited_set(ivar)
101
- inherited_ancestors.each_with_object(Set.new) do |klass, result|
102
- next result unless klass.instance_variable_defined?(ivar)
103
- val = klass.instance_variable_get(ivar)
104
- result.merge(val) unless val.blank?
105
- end
106
- end
107
-
108
- # Combine an inherited list of hashes but keeping only the most recent
109
- # value, which means that keys might be replaced
110
- def fetch_inherited_hash(ivar)
111
- inherited_ancestors.each_with_object({}) do |klass, result|
112
- next result unless klass.instance_variable_defined?(ivar)
113
- val = klass.instance_variable_get(ivar)
114
- result.merge!(val) unless val.blank?
115
- end
116
- end
117
-
118
- # Right now we can't use Hash with default proc for equivalency due to
119
- # a bug on Ruby https://bugs.ruby-lang.org/issues/17181
120
-
121
- # Combine an inherited list of hashes, which also will combine arrays,
122
- # ensuring that same key items will be combined
123
- def fetch_inherited_hash_array(ivar)
124
- inherited_ancestors.inject({}) do |result, klass|
125
- next result unless klass.instance_variable_defined?(ivar)
126
- val = klass.instance_variable_get(ivar)
127
- Helpers.merge_hash_array(result, val)
128
- end
129
- end
130
-
131
- # Combine an inherited list of hashes, which also will combine arrays,
132
- # ensuring that same key items will be combined
133
- def fetch_inherited_hash_set(ivar)
134
- inherited_ancestors.inject({}) do |result, klass|
135
- next result unless klass.instance_variable_defined?(ivar)
136
- val = klass.instance_variable_get(ivar)
137
- Helpers.merge_hash_array(result, val)
138
- end
139
- end
140
-
141
- private
142
-
143
- # Return a list of all the ancestor classes up until object
144
- def inherited_ancestors
145
- [self].tap do |list|
146
- list.unshift(list.first.superclass) until list.first.superclass === Object
147
- end
148
- end
149
93
  end
150
94
  end
151
95
  end
152
96
  end
97
+
98
+ require_relative 'inherited_collection/base'
99
+
100
+ require_relative 'inherited_collection/array'
101
+ require_relative 'inherited_collection/hash'
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rails
4
+ module GraphQL
5
+ module Helpers
6
+ # This marks an object as instantiable during a requesting, which means it
7
+ # will be associated with an event and most of it's information comes from
8
+ # the running event.
9
+ module Instantiable
10
+ delegate_missing_to :event
11
+ attr_reader :event
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Rails # :nodoc:
4
- module GraphQL # :nodoc:
5
- module Helpers # :nodoc:
3
+ module Rails
4
+ module GraphQL
5
+ module Helpers
6
6
  # Helper module allowing leaf values to be collected direct from
7
7
  # ActiveRecord. It also helps AR Adapters to define the necessary
8
8
  # methods and settings to operate with this extractor.
@@ -12,10 +12,10 @@ module Rails # :nodoc:
12
12
  def self.extended(other)
13
13
  # Defines which type exactly represents the scalar type on the
14
14
  # ActiveRecord adapter for casting purposes
15
- other.class_attribute :ar_adapter_type, instance_writer: false, default: {}
15
+ other.class_attribute :ar_adapter_type, instance_accessor: false, default: {}
16
16
 
17
17
  # A list of ActiveRecord aliases per adapter to skip casting
18
- other.class_attribute :ar_adapter_aliases, instance_writer: false,
18
+ other.class_attribute :ar_adapter_aliases, instance_accessor: false,
19
19
  default: (Hash.new { |h, k| h[k] = Set.new })
20
20
  end
21
21
 
@@ -87,7 +87,7 @@ module Rails # :nodoc:
87
87
  # equivalent
88
88
  def define_for(adapter, **settings)
89
89
  adapter = ar_adapters[adapter] if ar_adapters.key?(adapter)
90
- raise ArgumentError, <<~MSG.squish unless ar_adapters.values.include?(adapter)
90
+ raise ArgumentError, (+<<~MSG).squish unless ar_adapters.values.include?(adapter)
91
91
  The given #{adapter.inspect} adapter is not a valid option.
92
92
  The valid options are: #{ar_adapters.to_a.flatten.map(&:inspect).to_sentence}.
93
93
  MSG
@@ -99,7 +99,7 @@ module Rails # :nodoc:
99
99
  if settings.key?(:cast)
100
100
 
101
101
  ar_adapter_type[adapter] = settings[:type] if settings.key?(:type)
102
- ar_adapter_aliases[adapter] += Array.wrap(settings[:aliases]) \
102
+ ar_adapter_aliases[adapter] += ::Array.wrap(settings[:aliases]) \
103
103
  if settings.key?(:aliases)
104
104
  end
105
105
 
@@ -1,77 +1,52 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Rails # :nodoc:
4
- module GraphQL # :nodoc:
5
- module Helpers # :nodoc:
6
- # Helper module responsible for name stuff and also responsible for
7
- # registering the objects to the type map, which also checks for the
8
- # uniqueness of the name of things.
3
+ module Rails
4
+ module GraphQL
5
+ module Helpers
6
+ # Helper module responsible for registering the objects to the type map,
7
+ # which also checks for the uniqueness of the name of things.
9
8
  module Registerable
10
- NAME_EXP = /GraphQL::(?:Type::\w+::|Directive::)?([:\w]+?)([A-Z][a-z]+)?\z/.freeze
11
-
12
9
  # Here we define a couple of attributes used by registration
13
10
  def self.extended(other)
14
- other.extend(Registerable::ClassMethods)
11
+ other.extend(Helpers::Unregisterable)
15
12
  other.extend(Helpers::WithNamespace)
16
-
17
- # If a type is marked as abstract, it's then used as a base and it
18
- # won't appear in the introspection
19
- other.class_attribute :abstract, instance_writer: false, default: false
13
+ other.extend(Helpers::WithName)
14
+ other.extend(Helpers::WithDescription)
20
15
 
21
16
  # Marks if the object is one of those defined on the spec, which
22
17
  # marks the object as part of the introspection system
23
- other.class_attribute :spec_object, instance_writer: false, default: false
24
-
25
- # The given description of the type
26
- other.class_attribute :description, instance_writer: false
18
+ other.class_attribute :spec_object, instance_accessor: false, default: false
27
19
  end
28
20
 
29
- module ClassMethods # :nodoc: all
30
- # Here we wait for the class to be fully loaded so that we can
31
- # correctly trigger the registration
32
- def inherited(subclass)
33
- super if defined? super
34
- return if subclass.try(:abstract)
35
- GraphQL.type_map.postpone_registration(subclass)
36
- end
37
-
38
- # Check if the class is already registered in the typemap
39
- def registered?
40
- GraphQL.type_map.object_exist?(self, exclusive: true)
41
- end
42
-
43
- # The process to register a class and it's name on the index
44
- def register!
45
- return if abstract? || gql_name.blank?
46
-
47
- raise DuplicatedError, <<~MSG.squish if registered?
48
- The "#{gql_name}" is already defined, the only way to change its
49
- definition is by using extensions.
50
- MSG
51
-
52
- invalid_internal = !spec_object && gql_name.start_with?('__')
53
- raise NameError, <<~MSG.squish if invalid_internal
54
- The name "#{gql_name}" is invalid. Only internal objects from the
55
- spec can have a name starting with "__".
56
- MSG
57
-
58
- super if defined? super
59
- GraphQL.type_map.register(self).method(:validate!)
60
- end
21
+ # Here we wait for the class to be fully loaded so that we can
22
+ # correctly trigger the registration
23
+ def inherited(subclass)
24
+ super if defined? super
25
+ GraphQL.type_map.postpone_registration(subclass)
61
26
  end
62
27
 
63
- # Return the name of the object as a GraphQL name
64
- def gql_name
65
- @gql_name ||= begin
66
- name.match(NAME_EXP).try(:[], 1)&.tr(':', '')
67
- end unless anonymous?
28
+ # Check if the class is already registered in the type map
29
+ def registered?
30
+ GraphQL.type_map.object_exist?(self, exclusive: true)
68
31
  end
69
32
 
70
- alias graphql_name gql_name
33
+ # The process to register a class and it's name on the index
34
+ def register!
35
+ return if abstract? || gql_name.blank?
36
+
37
+ raise DuplicatedError, (+<<~MSG).squish if registered?
38
+ The "#{gql_name}" is already defined, the only way to change its
39
+ definition is by using extensions.
40
+ MSG
71
41
 
72
- # Return the name of the object as a symbol
73
- def to_sym
74
- @gql_key ||= gql_name&.underscore&.to_sym
42
+ invalid_internal = !spec_object && gql_name.start_with?('__')
43
+ raise NameError, (+<<~MSG).squish if invalid_internal
44
+ The name "#{gql_name}" is invalid. Only internal objects from the
45
+ spec can have a name starting with "__".
46
+ MSG
47
+
48
+ super if defined? super
49
+ GraphQL.type_map.register(self)
75
50
  end
76
51
 
77
52
  # Get or set a list of aliases for this object
@@ -85,17 +60,24 @@ module Rails # :nodoc:
85
60
  end
86
61
  end
87
62
 
63
+ # TODO: When an object is frozen, it was successfully validated
64
+ # alias valid? frozen?
65
+
88
66
  protected
89
67
 
90
68
  # An alias for +description = value.strip_heredoc.chomp+ that can be
91
69
  # used as method
92
70
  def desc(value)
93
- self.description = value.strip_heredoc.chomp
71
+ self.description = value
94
72
  end
95
73
 
96
- # Change the gql name of the object
97
- def rename!(name)
98
- @gql_name = name
74
+ def rename!(*)
75
+ GraphQL.logger.warn((+<<~MSG).squish) if registered?
76
+ \e[95m[GraphQL] Renaming #{name} after it has being registered
77
+ may cause unexpected behaviors.\e[0m
78
+ MSG
79
+
80
+ super
99
81
  end
100
82
  end
101
83
  end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rails
4
+ module GraphQL
5
+ module Helpers
6
+ # Helper that allows unregisterable objects to be both identified and
7
+ # removed from type map
8
+ module Unregisterable
9
+ # Simply remove itself from the type map
10
+ def unregister!
11
+ GraphQL.type_map.unregister(self)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Rails # :nodoc:
4
- module GraphQL # :nodoc:
5
- module Helpers # :nodoc:
3
+ module Rails
4
+ module GraphQL
5
+ module Helpers
6
6
  # Helper module that allows other objects to hold arguments
7
7
  module WithArguments
8
8
  def self.extended(other)
@@ -13,14 +13,22 @@ module Rails # :nodoc:
13
13
 
14
14
  def self.included(other)
15
15
  other.define_method(:arguments) do
16
- defined?(@arguments) ? @arguments : {}
16
+ @arguments ||= {}
17
+ end
18
+
19
+ other.define_method(:all_arguments) do
20
+ @arguments if defined?(@arguments)
21
+ end
22
+
23
+ other.define_method(:arguments?) do
24
+ defined?(@arguments) && @arguments.present?
17
25
  end
18
26
  end
19
27
 
20
- module ClassMethods # :nodoc: all
28
+ module ClassMethods
21
29
  def inherited(subclass)
22
30
  super if defined? super
23
- return if arguments.empty?
31
+ return if arguments.blank?
24
32
 
25
33
  new_arguments = Helpers.dup_all_with_owner(arguments.transform_values, subclass)
26
34
  subclass.instance_variable_set(:@arguments, new_arguments)
@@ -28,13 +36,13 @@ module Rails # :nodoc:
28
36
  end
29
37
 
30
38
  def initialize(*args, arguments: nil, **xargs, &block)
31
- @arguments = Array.wrap(arguments).map do |object|
32
- raise ArgumentError, <<~MSG.squish unless object.is_a?(Argument)
33
- The given "#{object.inspect}" is not a valid Argument object.
39
+ @arguments = GraphQL.enumerate(arguments).each_with_object({}) do |item, hash|
40
+ raise ArgumentError, (+<<~MSG).squish unless item.is_a?(Argument)
41
+ The given "#{item.inspect}" is not a valid Argument object.
34
42
  MSG
35
43
 
36
- [object.name, Helpers.dup_with_owner(object, self)]
37
- end.to_h unless arguments.nil?
44
+ hash[item.name] = Helpers.dup_with_owner(item, self)
45
+ end unless arguments.nil?
38
46
 
39
47
  super(*args, **xargs, &block)
40
48
  end
@@ -50,39 +58,34 @@ module Rails # :nodoc:
50
58
  super && other.respond_to?(:all_arguments) && match_arguments?(other)
51
59
  end
52
60
 
53
- # Mostly for correct inheritance on instances
54
- def all_arguments
55
- defined?(@arguments) ? @arguments : {}
56
- end
57
-
58
61
  # See {Argument}[rdoc-ref:Rails::GraphQL::Argument] class.
59
- def argument(name, base_type, **xargs)
60
- xargs[:owner] = self
61
- object = GraphQL::Argument.new(name, base_type, **xargs)
62
+ def argument(name, type = nil, **xargs)
63
+ object = GraphQL::Argument.new(name, type, **xargs, owner: self)
62
64
 
63
- raise DuplicatedError, <<~MSG.squish if has_argument?(object.name)
65
+ raise DuplicatedError, (+<<~MSG).squish if has_argument?(object.name)
64
66
  The #{name.inspect} argument is already defined and can't be redefined.
65
67
  MSG
66
68
 
67
- (@arguments ||= {})[object.name] = object
69
+ arguments[object.name] = object
70
+ self
68
71
  rescue DefinitionError => e
69
- raise e.class, e.message + "\n Defined at: #{caller(2)[0]}"
72
+ raise e.class, +"#{e.message}\n Defined at: #{caller(2)[0]}"
70
73
  end
71
74
 
72
75
  # Since arguments' owner are more flexible, their instances can be
73
76
  # directly associated to objects that have argument
74
77
  def ref_argument(object)
75
- raise ArgumentError, <<~MSG.squish unless object.is_a?(GraphQL::Argument)
78
+ raise ArgumentError, (+<<~MSG).squish unless object.is_a?(GraphQL::Argument)
76
79
  The given object #{object.inspect} is not a valid argument.
77
80
  MSG
78
81
 
79
- raise DuplicatedError, <<~MSG.squish if has_argument?(object.name)
82
+ raise DuplicatedError, (+<<~MSG).squish if has_argument?(object.name)
80
83
  The #{object.name.inspect} argument is already defined and can't be redefined.
81
84
  MSG
82
85
 
83
86
  (@arguments ||= {})[object.name] = object
84
87
  rescue DefinitionError => e
85
- raise e.class, e.message + "\n Defined at: #{caller(2)[0]}"
88
+ raise e.class, +"#{e.message}\n Defined at: #{caller(2)[0]}"
86
89
  end
87
90
 
88
91
  # A short cute for arguments named and typed as id
@@ -110,14 +113,16 @@ module Rails # :nodoc:
110
113
 
111
114
  # Show all the arguments as their inspect version
112
115
  def inspect_arguments
113
- args = all_arguments.each_value.map(&:inspect)
114
- args.presence && "(#{args.join(', ')})"
116
+ args = all_arguments&.each_value&.map(&:inspect)
117
+ args.presence && +"(#{args.join(', ')})"
115
118
  end
116
119
 
117
120
  # Check the equivalency of arguments
118
121
  def match_arguments?(other)
119
122
  l_args, r_args = all_arguments, other.all_arguments
120
- l_args.size <= r_args.size && l_args.all? { |key, arg| arg =~ r_args[key] }
123
+ l_args.class == r_args.class &&
124
+ l_args.size <= r_args.size &&
125
+ l_args.all? { |key, arg| arg =~ r_args[key] }
121
126
  end
122
127
  end
123
128
  end
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Rails # :nodoc:
4
- module GraphQL # :nodoc:
5
- module Helpers # :nodoc:
3
+ module Rails
4
+ module GraphQL
5
+ module Helpers
6
6
  # Helper module that allows other objects to hold an +assigned_to+ object
7
7
  module WithAssignment
8
8
  # Add extra instance based methods
@@ -11,7 +11,7 @@ module Rails # :nodoc:
11
11
  :assigned_class, to: :class
12
12
  end
13
13
 
14
- # Check if the class is assgined
14
+ # Check if the class is assigned
15
15
  def assigned?
16
16
  assigned_to.present?
17
17
  end
@@ -65,7 +65,7 @@ module Rails # :nodoc:
65
65
  return result unless (klass = safe_assigned_class)
66
66
  return result if GraphQL.type_map.exist?(klass, namespaces: namespaces)
67
67
 
68
- GraphQL.type_map.register_alias(klass, namespaces: namespaces, &method(:itself))
68
+ GraphQL.type_map.register_alias(klass, to_sym, namespaces: namespaces)
69
69
  result
70
70
  end
71
71
 
@@ -93,7 +93,7 @@ module Rails # :nodoc:
93
93
  klass = klass.superclass
94
94
  end
95
95
 
96
- message = !block.nil? ? block.call(klass) : <<~MSG.squish
96
+ message = !block.nil? ? block.call(klass) : (+<<~MSG).squish
97
97
  The "#{klass.name}" is not a subclass of #{base_class.name}.
98
98
  MSG
99
99
 
@@ -1,15 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Rails # :nodoc:
4
- module GraphQL # :nodoc:
5
- module Helpers # :nodoc:
3
+ module Rails
4
+ module GraphQL
5
+ module Helpers
6
6
  # Callbacks is an extension of the events which works with the
7
7
  # {Callback}[rdoc-ref:Rails::GraphQL::Callback] class, then having extra
8
- # powers when actually executing the event against procs or owner-based
9
- # symbolic methods
8
+ # powers when actually executing the event against Procs or owner-based
9
+ # methods, when provided a symbol
10
10
  module WithCallbacks
11
11
  DEFAULT_EVENT_TYPES = %i[query mutation subscription request attach
12
- authorize organized prepared finalize].freeze
12
+ authorize organized prepared finalize prepare subscribed].freeze
13
13
 
14
14
  def self.extended(other)
15
15
  other.extend(WithCallbacks::Setup)
@@ -17,7 +17,7 @@ module Rails # :nodoc:
17
17
 
18
18
  def self.included(other)
19
19
  other.extend(WithCallbacks::Setup)
20
- other.delegate(:event_filters, to: :class)
20
+ other.delegate(:event_filters, :default_exclusive?, to: :class)
21
21
  end
22
22
 
23
23
  # Add the ability to set up filters before the actual execution of the
@@ -31,15 +31,32 @@ module Rails # :nodoc:
31
31
  # Return the list of event filters hooks
32
32
  def event_filters
33
33
  return @event_filters if defined? @event_filters
34
- superclass.try(:event_filters) || {}
34
+ superclass.try(:event_filters) || EMPTY_HASH
35
+ end
36
+
37
+ # Set the default +exclusive+ value for the given +for+ event names
38
+ def default_exclusive(value, **xargs)
39
+ new_values = Array.wrap(xargs.fetch(:for)).map(&:to_sym).product([value]).to_h
40
+ @callback_exclusive ||= superclass.try(:callback_exclusive)&.dup || {}
41
+ @callback_exclusive.merge!(new_values)
42
+ end
43
+
44
+ # Check if the given +event_name+ should be thread as exclusive or
45
+ # non-exclusive by default
46
+ def default_exclusive?(event_name)
47
+ if defined?(@callback_exclusive)
48
+ @callback_exclusive[event_name]
49
+ else
50
+ superclass.try(:default_exclusive?, event_name)
51
+ end
35
52
  end
36
53
 
37
54
  protected
38
55
 
39
56
  # Attach a new key based event filter
40
- def event_filter(key, sanitizer = nil, &block)
57
+ def event_filter(key, &block)
41
58
  @event_filters ||= superclass.try(:event_filters)&.dup || {}
42
- @event_filters[key.to_sym] = { block: block, sanitizer: sanitizer }
59
+ @event_filters[key.to_sym] = block
43
60
  end
44
61
  end
45
62
 
@@ -47,7 +64,7 @@ module Rails # :nodoc:
47
64
  # {Callback}[rdoc-ref:Rails::GraphQL::Callback] object.
48
65
  def on(event_name, *args, unshift: false, **xargs, &block)
49
66
  block = Callback.new(self, event_name, *args, **xargs, &block)
50
- super(event_name, unshift: unshift, &block)
67
+ super(event_name, block, unshift: unshift)
51
68
  end
52
69
  end
53
70
  end