Fork me on GitHub
#graphql
<
2019-02-22
>
orestis06:02:30

I was wondering if it would be possible to specify a conversion function on the graphql function, and then have Lacinia execute it on every resolver that returns it.

hlship23:02:25

In a much earlier Lacinia, there was the idea of a resolver-transformer, but that ended up being silly, as you can just wrap your existing functions however you like before passing them into Lacinia with the schema.

hlship23:02:06

One thing you can look into are scalars, since you would have the ability in the scalar's serialize function to do all kinds of interesting things.

hlship23:02:39

I've been pushing, on our team, to have additional scalars for things like Currency (an Int, as number of pennies), a CustomerId (a String, with a particular regexp pattern) etc. The parse/serialize would often be trivial, but it's another place to push some global input validations, and (importantly to me) a good place to put some documentation.

orestis06:02:27

But honestly it’s not that big a deal, since usually the conversion function is just a function, calling it manually is fine.

orestis06:02:22

Plus, having a graphql endpoint means basically you are building a graph-relational mapper. Best to hand roll one for your domain than rely on too much magic.

Lennart Buit10:02:08

yeah, so you would say that a big cond for implementation of that node interface is not so strange

hlship22:02:01

v0.33.0-alpha-1 is up on clojars; adds support for extend type in SDL, and reworks a lot of exceptions. More consistent use of the Object/field syntax.

👍 5