oliyh / re-graph

A graphql client for clojurescript and clojure

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How do I set Headers for each individual subscriptions?

anonimitoraf opened this issue · comments

Gist of my problem is:

  • Some of my subscriptions need X-Hasura-Role: public, others need X-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 :(

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

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

Works perfectly. Thanks!