0

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?

Bergi
  • 630,263
  • 148
  • 957
  • 1,375
Anthony
  • 317
  • 1
  • 5
  • 23
  • I don't think that this is a question about `graphql` but rather about `GraphCMS`. – puelo May 01 '21 at 22:01
  • I was thinking that perhaps this is something that is done in a query, but I'll touch bases with GraphCMS to see what they say. – Anthony May 01 '21 at 22:29

1 Answers1

0

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.

Anthony
  • 317
  • 1
  • 5
  • 23