You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
module Subscriptions
class SubscribeToBullshit < Mutations::BaseMutation
description 'yes'
field :id, String, null: true
field :first_name, String, null: true
field :last_name, String, null: true
def resolve
return unless current_identity
{
id: current_identity.id,
first_name: current_identity.first_name,
last_name: current_identity.last_name
}
end
end
end
Which's plugged on my schema this way
module Types
class SubscriptionType < GraphQL::Schema::Object
field :subscribeToBullshit, resolver: Subscriptions::SubscribeToBullshit
end
end
And finally the schema declaration as so
class MySchema < GraphQL::Schema
mutation Types::MutationType
query Types::QueryType
subscription Types::SubscriptionType
end
On my front-end I subscribe to subscribeToBullshit successfully through a command which is like that
subscription SubscribeToBullshit {
subscribeToBullshit {
id
firstName
lastName
}
}
The subscription from my front-end is successful. I now want to trigger the update from my server, inside a mutation, to be sent to the different clients listening to subscribeToBullshit
module Mutations
class StoreIdentityName < Mutations::BaseMutation
def resolve
# some logic around
MySchema.subscriptions.trigger('subscribeToBullshit', {}, {
id: current_identity.id,
first_name: current_identity.first_name,
last_name: current_identity.last_name
})
end
end
end
I don't think the detail of the mutation matters. when I check MySchema.subscriptions it returns nil and will systematically cause an error. Is the documentation up-to-date on this matter?
undefined method `trigger' for nil:NilClass
What am I doing wrong here?
The text was updated successfully, but these errors were encountered:
I've got a subscription such as
Which's plugged on my schema this way
And finally the schema declaration as so
On my front-end I subscribe to
subscribeToBullshit
successfully through a command which is like thatThe subscription from my front-end is successful. I now want to trigger the update from my server, inside a mutation, to be sent to the different clients listening to
subscribeToBullshit
I don't think the detail of the mutation matters. when I check
MySchema.subscriptions
it returnsnil
and will systematically cause an error. Is the documentation up-to-date on this matter?What am I doing wrong here?
The text was updated successfully, but these errors were encountered: