Monorepo
Monorepo copied to clipboard
Results data-fetching overview
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.jsonfile 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
surveysrepo 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.