This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-06-30
Channels
- # announcements (40)
- # babashka (41)
- # beginners (32)
- # calva (15)
- # clara (8)
- # clj-kondo (14)
- # cljs-dev (30)
- # clojure (37)
- # clojure-dev (8)
- # clojure-europe (21)
- # clojure-norway (21)
- # clojure-uk (4)
- # clojured (3)
- # clojurescript (4)
- # community-development (10)
- # core-async (13)
- # cursive (23)
- # datomic (15)
- # emacs (9)
- # fulcro (3)
- # google-cloud (4)
- # graphql (24)
- # gratitude (2)
- # holy-lambda (4)
- # honeysql (5)
- # hyperfiddle (9)
- # keechma (1)
- # klipse (5)
- # lsp (23)
- # malli (4)
- # missionary (32)
- # pathom (28)
- # re-frame (2)
- # reagent (40)
- # reitit (17)
- # releases (2)
- # remote-jobs (1)
- # shadow-cljs (25)
- # specter (3)
- # vim (19)
- # xtdb (41)
I'm sending request headers through graphiql subscriptions
I can't get those variables here through backend
using lacinia-pedestal 1.1
my :request inside :context only comes with: :id, :query, :response-data-ch, :shutdown-ch, :variables
anyone knows how can I assoc headers through a request through graphiql??
@d.ian.b seems to be related with the fact that in pedestal websockets, there is no (or just a few) "context" from request on websocket handlers. https://github.com/pedestal/pedestal/blob/master/samples/jetty-web-sockets/src/jetty_web_sockets/service.clj#L58
I already handled that in pedestal once. I digging lacinia-pedstal to see how I can do it
(lp/default-service schema {:init-context (fn [ctx req res]
;; original:
#_ctx
;; with request/headers:
(merge ctx req {:check-if-init-context-works 42}))})
in default-service there is a call only for :app-context
not for :init-context
is this right?
options as second argument of enable subscriptions https://github.com/walmartlabs/lacinia-pedestal/blob/master/src/com/walmartlabs/lacinia/pedestal2.clj#L364 then as last in add-subscriptions support https://github.com/walmartlabs/lacinia-pedestal/blob/master/src/com/walmartlabs/lacinia/pedestal2.clj#L319 last in listener-fn-factory https://github.com/walmartlabs/lacinia-pedestal/blob/master/src/com/walmartlabs/lacinia/pedestal/internal.clj#L276 finally, init-context https://github.com/walmartlabs/lacinia-pedestal/blob/master/src/com/walmartlabs/lacinia/pedestal/subscriptions.clj#L543

anyway, should be easy to test if the :check-if-init-context-works
key show up in the context

Thanks
trying it right now
req and res do not come here
ServletUpgradeRequest
(lp/default-service schema {:init-context (fn [ctx ^org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest req res]
;; original:
#_ctx
;; with request/headers:
(assoc ctx
:headers (into {}
(map (fn [[k vs]]
[k (string/join "," vs)]))
(.getHeaders req))))})
^ this is most probably your answer @d.ian.b I was trying to find it yesterday and couldn't, thanks @U2J4FRT2T
this was not the answer, btw he opened a PR
The thing is that I can't capture the headers in a request when I do subscriptions on Lacinia...
Anyone here got this working?