Is it possible to total a schema field?

153 views Asked by At

Apologies if this has come up before, but I couldn't find anything.

I am using GraphCMS (highly recommend it) and I have several fields that are floats. I am using them for prices. Each entry in the schema can either be a buy or sell in an enumeration field. I would like to total all the price fields where the entry is a buy, and total all the price fields where the entry is a sell.

I thought there would be something clear in the docs because totalling those fields would be very useful for something like calculating an average score etc. but I can only see docs about counting entries. Have I missed it somewhere?

Surely this is possible?

1

There are 1 answers

0
Anthony On BEST ANSWER

After speaking with the helpful guys at GraphCMS I have figured out how to do it. This is not a question about GraphCMS as @puelo suggested, but can be achieved by running a graphql query and then programatically running calculations with the data. It's a simple solution but wasn't immediately apparent to me at first. Hopefully that info will be useful to other newbies.