How do I set Headers for each individual subscriptions?
anonimitoraf opened this issue · comments
Rafael Nicdao commented
Gist of my problem is:
- Some of my subscriptions need
X-Hasura-Role: public
, others needX-Hasura-Role: user
- I've tried:
:dispatch-n [[::rg/re-init {:ws {:impl {:headers {"X-Hasura-Role" "public"}}}}]
[::rg/subscribe ...] ;; Subscription that needs "public"
;; Then I change it back to "user" (which is the default)
[::rg/re-init {:ws {:impl {:headers {"X-Hasura-Role" "user"}}}}]]
Doesn't work :(
Oliver Hine commented
Hi,
I'm surprised that doesn't work, but as the headers are sent when the websocket is connected and the websocket is designed for longer durations I would suggest you open two connections, one for public and one for user - see the Multiple instances section in the readme.
Let me know if you need any more help
Cheers
Rafael Nicdao commented
Hey @oliyh
Thank you for the library by the way! So much simpler than the convoluted clients out there (apollo, etc).
I see, I'll try that out, thanks
Rafael Nicdao commented
Works perfectly. Thanks!