...

/

Submit the Subscriptions

Submit the Subscriptions

Learn how to submit subscriptions in GraphQL.

Basic subscription

Now that we can create orders, we’re at the perfect spot to introduce the first basic subscription. This subscription will support pushing these orders as they’re created out to subscribed clients. We’ll first need to define a subscription field in our schema, and then we’ll also need a way to trigger this subscription when the :place_order mutation runs:

Press + to interact
subscription do
field :new_order, :order do
config fn _args, _info ->
{:ok, topic: "*"}
end
end
end

For the most part, this is an ordinary-looking field. We’ve got another top-level object subscription to house our subscription fields, and then the :new_order, which returns the :order object we’re already ...