lib/graphql/subscriptions.rb in graphql-1.7.3 vs lib/graphql/subscriptions.rb in graphql-1.7.4

- old
+ new

@@ -1,8 +1,9 @@ # frozen_string_literal: true require "graphql/subscriptions/event" require "graphql/subscriptions/instrumentation" +require "graphql/subscriptions/serialize" if defined?(ActionCable) require "graphql/subscriptions/action_cable_subscriptions" end module GraphQL @@ -22,17 +23,24 @@ end # Fetch subscriptions matching this field + arguments pair # And pass them off to the queue. # @param event_name [String] - # @param args [Hash] + # @param args [Hash<String, Symbol => Object] # @param object [Object] # @param scope [Symbol, String] # @return [void] def trigger(event_name, args, object, scope: nil) field = @schema.get_field("Subscription", event_name) if !field raise "No subscription matching trigger: #{event_name}" + end + + # Normalize symbol-keyed args to strings + if args.any? + stringified_args = {} + args.each { |k, v| stringified_args[k.to_s] = v } + args = stringified_args end event = Subscriptions::Event.new( name: event_name, arguments: args,