Fork me on GitHub
#graphql
<
2018-01-15
>
hiredman18:01:12

I am thinking about using lacinia for graphql support in an app that makes heavy use of core.async internally, all database operations run on a threadpool and return results over channels, etc. I am trying to figure out if that model works with lacinia. It looks like I define some kind of crud sort of functions for some types, and lacina uses a scheme to figure out how to execute those functions to satisfy a query. Is there some way to have those crud functions return a result channel instead of the actual result?

hlship18:01:44

I'm building the same thing, and absolutely yes.

hlship18:01:19

You might find that there's a better way to accomplish this, specific to your application, but it's largely trivial to convert a core.async channel into a ResolverResult.

hlship18:01:50

Mostly it's a question of how to handle exceptions, and how to handle large results sets.

hiredman18:01:59

but in that case executing the query will really block a thread instead of doing the light weight park thing, so executing the query will need to be on a threadpool anyway

hlship18:01:55

No that's not true. Lacinia is actually fully asynchronous internally (but doesn't use core.async). It's all based on callbacks (just like core.async under the covers). There's also support for controlling the threadpool used when invoking those callbacks.

hlship18:01:44

ResolverResult is pretty much a Promise (in the JavaScript sense).

hiredman18:01:00

but it won't yield control of the thread that calls execute so that thread can do other things while waiting for some operation

hlship18:01:24

It will if you pass the :async true option to lacinia-pedestal's service-map.

hiredman18:01:34

how would I do that without using lacinia-pedestal?

hiredman19:01:09

interesting, thanks

MegaMatt20:01:00

i made a small lucinia project in .17 and been on something else for a while. has a lot changed since then?

MegaMatt21:01:47

trying to follow the pedistal instructions and it seems to fail with resources\graphiql system cannot find the file specified any suggestions on what to do? the proj file has :shell {:dir "resources/graphicql"} in it.

hlship22:01:48

What version are you building against? Have you checked out the release notes?

hlship22:01:58

There's been some minor course corrections.

hlship22:01:49

Straightening out the graphiql paths is the most troublesome stuff; if you were "coloring outside the lines" there, it'll likely hurt a bit.

MegaMatt22:01:49

I wasn't very far in my clojure implementation so i'm just starting over. I think i figured out that the lacinia-pedistal isn't a starter app it is a dep i need to pull in, still working on the start up yet though.

hlship22:01:44

Have you seen the Lacinia tutorial? It gets you going with baby steps, and covers lacinia-pedestal as well. http://lacinia.readthedocs.io/en/latest/tutorial/index.html

MegaMatt22:01:19

ah, cool. i was on this one

hlship22:01:38

That's the lacinia-pedestal manual, more of a reference.