graphql

donaldball 2019-04-08T14:11:27.039200Z

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.

orestis 2019-04-08T15:34:30.040200Z

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

orestis 2019-04-08T15:36:11.042Z

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.

orestis 2019-04-08T15:36:24.042400Z

That is, construct the schema programmatically

donaldball 2019-04-08T17:22:39.044400Z

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.

orestis 2019-04-08T19:59:25.046300Z

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.

orestis 2019-04-08T19:59:37.046800Z

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