Fork me on GitHub
#graphql
<
2017-06-03
>
MegaMatt11:06:17

I'm having difficulty implementing a scalar in lacinia. I'm cannibalizing the leaderboard app for testing and I've added this to my schema file on the same level as :queries

MegaMatt11:06:28

and changed the schema compiler to look like this

MegaMatt12:06:25

however, all i get back on the client is whatever my resolver sends. so resolve device sends "red" and i get red for this field even though my scalar serializer is called

lilactown13:06:13

what does the rest of your schema look like?

MegaMatt13:06:52

i feel like i'm so close but I just don't really know what to try next

lilactown13:06:26

I'm wondering if you need to add a resolver to the :created field

MegaMatt13:06:19

in the docs, i assumed that was just to resolve it with a today date to show it being parsed as a scalar but I can try that. My :scalar-date-serializer is getting called which is odd

MegaMatt13:06:35

i wonder if i need to include that spec stuff

lilactown13:06:06

you could try adding the conform-stuff

lilactown13:06:02

I know in libraries in other languages (e.g. elixir using absinthe), enforcing types on nested data has never really worked

lilactown13:06:19

I remember running into a very similar problem there

MegaMatt13:06:56

adding a resolver for the date field doesn't help. I tried to add the conform stuff but as soon as i depend on clojure 1.9 it breaks the app unfortunately

MegaMatt13:06:55

I'm trying to convert an apollo project to clojure so i can learn clojure and this is the last bit before I can start converting it all

MegaMatt13:06:19

and the scalars work fine in my node graphql instance

lilactown13:06:42

conform should work without clojure 1.9?

MegaMatt13:06:36

when i do (clojure.pprint/pprint (keys (ns-publics 'com.walmartlabs.lacinia.schema))) there is no as-conformer method

MegaMatt13:06:44

thanks for you help btw

MegaMatt13:06:38

ah, i think the docs might be wrong

MegaMatt13:06:47

should it be s/as-conformer?

lilactown13:06:09

which version of lacinia are you using?

lilactown13:06:20

try updating to 0.17.0

lilactown13:06:30

it might break some other parts of the app but I wouldn't trust the docs to be correct for anything but the current version

MegaMatt13:06:31

upgraded to 17, wrapped in the conformer and it is working

MegaMatt13:06:39

thanks a bunch

MegaMatt13:06:15

did you get io.aviso/pretty working?

MegaMatt13:06:24

is all that you have to do is add it to project.clj under deps and plugins?

MegaMatt13:06:33

or am i missing a step

lilactown13:06:36

that was all I had to do

MegaMatt13:06:58

okay, maybe i'll try one of the alternate methods

lilactown13:06:32

is it erroring, or just not doing anything?

MegaMatt13:06:43

doing nothing differently

MegaMatt13:06:02

the leaderboard is setup as a ring server so i start it with lein ring server

MegaMatt13:06:11

not sure if that is related

MegaMatt13:06:35

it is much niecer than the pedestal example provided for testing since it recompiles everything each request

lilactown13:06:51

and you're triggering an exception in your code?

MegaMatt13:06:08

i've had plenty while trying to get this working

lilactown13:06:19

yeah, reloading code is a bit of an annoyance with pedestal I'm finding -_-

lilactown13:06:38

sometimes I just restart my repl just to make sure

MegaMatt13:06:37

and i have no clue the differences between pedestal and ring so for now it is just whatever is easiest

lilactown13:06:09

I have to run, but if you're here in a few hours when I get back I'll try and set up aviso again and see if we can figure it out

MegaMatt13:06:24

no worries. thanks for all the help