
A principled approach to GraphQL query cost analysis - davisjam314
https://medium.com/dev-genius/a-principled-approach-to-graphql-query-cost-analysis-8c7243de42c1
======
tunesmith
I'm finding GraphQL very difficult to manage for a team of developers that is
learning it as they go. Generally it seems that if we do what GraphQL wants us
to do with the ability of deeply nested queries, the complexity increases so
much that we have the dual pain of weird corner case performance bugs and
highly complex QA scenarios. And if we start tearing apart the queries to
force the frontend to make more numerous smaller queries, then we lose much of
the benefit. I'm suspecting that the team is too focused on a false choice of
a spectrum and that there's an entirely different philosophy we should be
following to get the best of both worlds (predictability and flexibility) but
we haven't been able to put our finger on it yet.

~~~
freeopinion
In my experience, GraphQL tempts one to ask for more information than
necessary at the moment. That might be useful in just another click or two,
but then again, might not.

As you say, smaller, simpler queries are more performant. They also tend to be
more relevant. It's kinda like the argument for 2 dozen eggs at $1.60 instead
of a dozen eggs for $1. Buying 2 dozen at a time optimizes the cost per egg.
But if you only ever eat 10 eggs before you throw the rest away, cost per egg
is not the most important factor.

I prefer to pull data on demand in smaller chunks. At which point, GraphQL
makes less sense for my use case. But I think it's cool that somebody thought
it up and I'm sure it's very helpful in lots of situations.

~~~
slifin
Fulcro in the CLJS world solved this by generating the graph query based on
what's currently in the component tree, if you take react components out of
your view your query automatically adjusts to remove the components
requirements from the graph call

I imagine most js frameworks are greedy because it's extra work to be lean
here

------
davisjam314
Why you should measure the cost of your GraphQL queries, and how you should do
it.

This is a summary of a research paper.

