Fork me on GitHub
#graphql
<
2019-03-26
>
urzds18:03:49

@oliy @hiredman @lennart.buit: Regarding authentication of GraphQL requests: I have the Pedestal interceptor set up to add an :authorization field to the context, but in Lacinia's context I cannot find that field. Any idea what I need to do?

urzds19:03:38

Figured it out by reading the inject-app-context-interceptor: https://github.com/walmartlabs/lacinia-pedestal/blob/master/src/com/walmartlabs/lacinia/pedestal.clj#L315 I need to (assoc-in [:request :lacinia-app-context :authorization] data)) into the Pedestal context in an interceptor. Lacinia will apparently put everything in the :request :lacinia-app-context key in the Lacinia resolver context.

souenzzo19:03:40

there is some lacinia function that turns the query string into a clojure datastructure? (lacinicia/parse-query schema "{hello}") => {:op :query :key :hello ...} SOLVED: com.walmartlabs.lacinia.parser.query/parse-query tnks

urzds19:03:56

@hiredman @oliy @lennart.buit: Again regarding authentication: How does this work for WebSockets? I understand I should send an "initial payload" to the server that contains the authentication token. But where would I receive that? I assume it is not the same regular Pedestal interceptor that I use to check the token in the HTTP header for GraphQL-over-HTTP queries? Where do I need to look for that initial payload in my server code?

Lennart Buit19:03:48

Also, you can just ask your questions in this channel in general. There are plenty of people here willing to help! No need to mention specific people

urzds20:03:06

OK! Just thought because y'all gave the initial suggestion regarding interceptors for HTTP / initial payloads for WebSockets.

Lennart Buit20:03:06

no worries! Totally willing to help, but some people may be more “annoyed” by being mentioned so to say

Lennart Buit19:03:32

I must admit that a coworker of mine did something with that, but I haven’t

Lennart Buit19:03:58

So, I wouldn’t be able to tell you

hiredman19:03:15

I am not using pedestal, so I don't know. I start a stateful go loop that consumes messages from a socket io socket, and until it gets an authentication message it ignores graphql messages

oliy19:03:43

@urzds I can't remember right now, but I can have a look in the codebase at work and let you know tomorrow

urzds19:03:08

@hiredman So you wrote a replacement for "lacinia-pedestal" that builds solely on http://socket.io? Is that available somewhere?

urzds20:03:30

@oliy Thanks! That would be very helpful.

urzds20:03:28

OK... Turns out one needs to read the correct documentation. There is nothing about this in the Lacinia docs, but the Lacinia Pedestal docs have reasonable hints on how to achieve this: • https://lacinia-pedestal.readthedocs.io/en/latest/subscriptions.html (regarding the general concepts) • https://walmartlabs.github.io/apidocs/lacinia-pedestal/com.walmartlabs.lacinia.pedestal.subscriptions.html (shows me that there are default-subscription-interceptors - similar to the HTTP case - which contain a ::inject-app-context interceptor, which I should overwrite / extend)

urzds20:03:12

I'll try that tomorrow. 🙂