graphql subscription triggered by association

I have this subscription on the user resource
subscriptions do
pubsub __.Endpoint

subscribe :current_user do
read_action :self

action_types [:update]
end
end
subscriptions do
pubsub __.Endpoint

subscribe :current_user do
read_action :self

action_types [:update]
end
end
User has one-to-one association with Preference resource, I would like to publish to that subscription when I update the associated too, can I do that via DSL or creating a change on the targets actions in that resource?
Solution:
At the moment I think the only way would be to have a change that updates the user resource as well to trigger the subscription or have 2 separate subscriptions on the client.
Jump to solution
3 Replies
Rick
RickOP2mo ago
Another way that I tried was creating 2 subscriptions, one for each resource, but I got an error when trying to subscribe to both at the same time:
subscription {
currentUser {
updated {
id
}
}
currentUserPreference {
updated {
id
}
}
}
subscription {
currentUser {
updated {
id
}
}
currentUserPreference {
updated {
id
}
}
}
And I got the error Only one field is permitted on the root object when subscribing
Solution
barnabasj
barnabasj2mo ago
At the moment I think the only way would be to have a change that updates the user resource as well to trigger the subscription or have 2 separate subscriptions on the client.
barnabasj
barnabasj2mo ago
You can create a feature request on GitHub, we might be able to add something to the dsl

Did you find this page helpful?