Class: GraphQL::Schema::Middleware
- Inherits:
-
Object
- Object
- GraphQL::Schema::Middleware
- Defined in:
- lib/graphql/schema/middleware.rb
Overview
-
query_initialize
-
query_finalize
-
field_resolve
Constant Summary collapse
- EVENTS =
[:before_query, :after_query, :before_field, :after_field]
Class Attribute Summary collapse
-
.handlers ⇒ Object
readonly
Returns the value of attribute handlers.
Class Method Summary collapse
Instance Method Summary collapse
Class Attribute Details
.handlers ⇒ Object (readonly)
Returns the value of attribute handlers.
56 57 58 |
# File 'lib/graphql/schema/middleware.rb', line 56 def handlers @handlers end |
Class Method Details
.on(event_name, &handler) ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/graphql/schema/middleware.rb', line 61 def on(event_name, &handler) if EVENTS.include?(event_name) handlers[event_name] = handler else raise("Can't attach handler to #{event_name} (must be one of: #{EVENTS})") end end |
Instance Method Details
#trigger(event_name, *args) ⇒ Object
70 71 72 |
# File 'lib/graphql/schema/middleware.rb', line 70 def trigger(event_name, *args) self.class.handlers[event_name].call(*args) end |