graphql

2022-06-30T00:21:17.314119Z

I'm sending request headers through graphiql subscriptions

2022-06-30T00:21:30.230929Z

I can't get those variables here through backend

2022-06-30T00:21:36.014489Z

using lacinia-pedestal 1.1

2022-06-30T00:22:37.361869Z

my :request inside :context only comes with: :id, :query, :response-data-ch, :shutdown-ch, :variables

2022-06-30T00:23:01.301599Z

anyone knows how can I assoc headers through a request through graphiql??

souenzzo 2022-06-30T14:21:31.182789Z

@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

🤔 1
2022-07-01T07:54:40.966379Z

^ this is most probably your answer @d.ian.b I was trying to find it yesterday and couldn't, thanks @souenzzo

2022-07-01T13:49:20.195119Z

this was not the answer, btw he opened a PR

souenzzo 2022-06-30T14:24:09.924789Z

I already handled that in pedestal once. I digging lacinia-pedstal to see how I can do it

souenzzo 2022-06-30T14:43:05.525529Z

@d.ian.b

(lp/default-service schema {:init-context (fn [ctx req res]
                                            ;; original:
                                            #_ctx
                                            ;; with request/headers:
                                            (merge ctx req {:check-if-init-context-works 42}))})

🤔 1
2022-06-30T15:28:08.771709Z

in default-service there is a call only for :app-context not for :init-context is this right?

souenzzo 2022-06-30T15:31:05.718209Z

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

1
2022-06-30T15:31:57.094209Z

sure

2022-06-30T15:31:58.815399Z

Thanks

2022-06-30T15:32:08.045569Z

trying it right now

2022-06-30T15:54:58.298839Z

req and res do not come here

souenzzo 2022-07-01T01:02:17.572359Z

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))))})

2022-06-30T17:09:43.961309Z

The thing is that I can't capture the headers in a request when I do subscriptions on Lacinia...

2022-06-30T17:09:52.878049Z

Anyone here got this working?

isak 2022-06-30T22:55:09.459819Z

@d.ian.b did you try passing anything for the context in lacinia/execute?

souenzzo 2022-07-01T00:00:50.026009Z

he is using lacinia-pedestal, so he didn't call lacinia/execute directly

👌🏻 1
souenzzo 2022-07-01T00:01:05.345499Z

but yes, do not use lacinia-pedestal is a possible solution