Monorepo icon indicating copy to clipboard operation
Monorepo copied to clipboard

Results data-fetching overview

Open SachaG opened this issue 2 years ago • 0 comments

An overview of how results gets its data:

  • Gatsby goes through each chart one by one during its build process.
  • For each chart, it looks for an existing chartId.json file A) on the local disk or B) at a predefined URL.
  • If the file exists, it uses that.
  • If not, it generates a GraphQL query and runs it against the API.

If running locally in dev mode:

  • the build process also creates a JSON file containing the results of the API call
  • I then commit the updated data as part of the surveys repo and push it to GitHub.

Why

Two reasons why we rely on "static" files:

  • Loading a file is way faster than hitting an API, even if the result is cached.
  • In the event of the API going down or not running in the future or whatever reason, we can still rebuild the results site with nothing but the JSON files.

SachaG avatar Jul 19 '23 01:07 SachaG