Fork me on GitHub
#graphql
<
2019-04-08
>
donaldball14:04:27

I have a schema design question. My object graph is a DAG with a few potential root types. I have been exposing those root objects as queries, but I find myself now replicating the same set of args on the object and the corresponding query, e.g. for queries by indexed fields, and it feels redundant. I almost want to introduce a single synthetic root query and have all of the root object types available off of it to eliminate this redundancy. Has anyone else experienced this dissonance? I can’t tell if I’m using graphql poorly or if this is just a typical redundancy.

orestis15:04:30

Do you mean you can query your objects by any and all their fields?

orestis15:04:11

You aren’t able to share attributes between input objects (your query arguments) and the returned objects - but you could easily write some Clojure code to do it for you.

orestis15:04:24

That is, construct the schema programmatically

donaldball17:04:39

There are a subset of fields which are both arguments for filtering objects as well as arguments for filtering their corresponding queries… so these queries are just pure projections of their corresponding objects.

orestis19:04:25

Yeah if you get annoyed by repetition I’d just write some code that patches up the schema Lacinia expects with the repetitive stuff. Not sure if there are any hooks for this, but you don’t exactly need them.

orestis19:04:37

Sorry if I’m being vague, typing on a phone :)