Fork me on GitHub
#graphql
<
2017-06-14
>
johnny.martin16:06:38

Hi. We are using Lacinia, Ring, and JDBC wrapped with a connection pool. Anyone have some suggestions for best practices to pass around the wrapped JDBC? Our current workaround is ugly: (def global (atom (c3po...jdbc init...)) and then doing @global inside a resolver fn.

domkm16:06:33

@johnny.martin Pass it in via resolver context.

johnny.martin17:06:57

Thank you--very helpful. We found the optional context argument in the docs, after reading your suggestion. Thanks again!

hlship18:06:10

johnny.martin: For clarification, the signature is (execute schema query variables context) or (execute schema query variables context options), so it's not optional. The context map you provide is augmented with additional keys and passed back to your field resolver functions.

johnny.martin22:06:19

Ah ha, i see that now checking the docs again. I think cut-copy-pasted some example that was missing the context args. Thanks for pointing this out. Context is rather useful, dunno how we did without. 🙂

domkm17:06:15

no problem

MegaMatt17:06:15

noob question: I am using boardgamegeek example with PR patch which calls (start-server) on lein run. Every change i make i need to ctrl+c and lein run again. What is the proper way to dev with this pedestal-server without a complete restart

hlship19:06:10

I'll be looking at what Pedestal offers to support that.

mpenet19:06:12

hlship: pedestal was not so good in that respect last time I checked (see issues), might have changed since

hlship19:06:21

Make it work. Make it right. Make it fast.

stijn20:06:01

@mpenet if your database is generating updates faster than clients can handle it, what other option do you have except for disconnecting the client or dropping updates?

stijn20:06:17

that's why i'm asking what'll be the interface in lacinia for disconnecting from a stream. we're using yada+aleph in front of lacinia

lilactown21:06:20

@matthewdaniel I'm not sure about the boardgamegeek example, but when you create a bare pedestal template with lein, it defines a run-dev function

lilactown21:06:06

my work flow usually involves starting a repl (`lein repl` or CIDER or what-have-you) and running (def serv (run-dev)), which starts the server, and can then be stopped: (server/stop serv)

MegaMatt11:06:04

lilactown: Thanks, this is so much better, and now i have a repl which i hadn't before

lilactown22:06:40

so you can do e.g.:

example.server=> (def serv (run-dev))
example.server=> ; make some changes to some files, e.g. example.schema
example.server=> (require example.schema :reload) ; reload the changed file
example.server=> (require example.server :reload)
example.server=> (server/stop serv)
example.server=> (def serv (run-dev))

lilactown22:06:11

I simple created a helper function to do all the reloading and restarting, so I can do (def serv (reload-schema serv))