quantified-uncertainty/metaforecast

Add history to the graphql API

Closed this issue · 2 comments

Right now, history isn't yet added to the graphql API. But it seems like a natural next step.

Done: https://metaforecast.org/api/graphql?query=fragment+Question+on+Question+%7B%0A++id%0A++url%0A++title%0A++description%0A++timestamp%0A++options+%7B%0A++++name%0A++++probability%0A++%7D%0A++platform+%7B%0A++++id%0A++++label%0A++%7D%0A++qualityIndicators+%7B%0A++++stars%0A++++numForecasts%0A++%7D%0A++visualization%0A++history+%7B%0A++++timestamp%0A++++options+%7B%0A++++++name%0A++++++probability%0A++++%7D%0A++%7D%0A%7D%0A%0Aquery+Frontpage+%7B%0A++result%3A+frontpage+%7B%0A++++...Question%0A++%7D%0A%7D

I'm not sure if this is the best approach in terms of API design & implementation, but it's the easiest one for now. Probably going to be too slow if we'll want to serve history graphs for a page full of different questions, but good enough for a single question's page. I haven't tried to benchmark it yet.

Other notes:

  • #50 should be possible to implement without changing the external graphql API
  • we may also try alternative approaches to the API, e.g. { snapshot(timestamp: "2022-01-01") {...} } or { history(since: "2022-01-01") { ... } }, or { history(period: "7d") {...} } (this can be done with or without #50)
  • if we implement #50 then I can also imagine there being fields with event-based changes for each question's field

Beautiful!