Add a graphQL field that's the sum total of another set of fields? #30265
Unanswered
adamavenir
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I’m trying to figure out how to return a graphql field that does math across a full dataset. Basically I just want to total one specific field of all of the objects in one query.
Think: leaderboard that totals cumulative results and ranks participants by that. Imagine the following:
Dataset 1:
Dataset 2:
With the goal being something like:
What is the best way to do this in Gatsby?
I could ship all the data to the react component and do the math there, but something about that approach feels off. Maybe it's fine though?
I imagine there's a way to do this with the createResolver API but it's really not clear to me from the docs how I might do that. I'm actually kind of surprised that this use case is not a common enough one to have some obvious way of doing it.
Beta Was this translation helpful? Give feedback.
All reactions