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
Suppose we want to create a subscription that would simply publish names of all mutations that were called:
# test/absinthe/execution/subscription_test.exsdefmoduleSchemadouseAbsinthe.Schemaobject:userdofield:id,:idfield:name,:stringendsubscriptiondofield:all_mutations,:stringdoconfigfn_,_->{:ok,topic: "*"}endtrigger[:update_user],topic: fn_->"*"end# None of the input arguments can carry `updateUser` stringresolvefn_mutation_result,_args,_resolution->{:ok,"updateUser"}endendendmutationdofield:update_user,:userdoarg:id,non_null(:id)resolvefn_,%{id: id},_->{:ok,%{id: id,name: "foo"}}endendendend@query""" subscription { allMutations } """test"can pass context from mutation to subscription"doid="1"assert{:ok,%{"subscribed"=>topic}}=run_subscription(@query,Schema,context: %{pubsub: PubSub})mutation=""" mutation ($userId: ID!) { updateUser(id: $userId) { id name } } """assert{:ok,%{data: _}}=run_subscription(mutation,Schema,variables: %{"userId"=>id},context: %{pubsub: PubSub})assert_receive({:broadcast,msg})assert%{event: "subscription:data",result: %{data: %{"allMutations"=>"updateUser"}},topic: topic}==msgend
If I'm reading the code right, it's not possible with just trigger macro right now. The only piece of information that is passed to a subscription's resolver from a mutation is the mutation's result.
Would it make sense to provide an avenue for passing some arbitrary context between two resolutions? I'm happy to take a stab at implementing this, but not quite sure what would be the best place to put this extra context.
The text was updated successfully, but these errors were encountered:
Suppose we want to create a subscription that would simply publish names of all mutations that were called:
If I'm reading the code right, it's not possible with just
trigger
macro right now. The only piece of information that is passed to a subscription's resolver from a mutation is the mutation's result.Would it make sense to provide an avenue for passing some arbitrary context between two resolutions? I'm happy to take a stab at implementing this, but not quite sure what would be the best place to put this extra context.
The text was updated successfully, but these errors were encountered: