Skip to content

A simple trivia app in React with a GraphQL backend, deployed to Azure Static Web Apps

License

Notifications You must be signed in to change notification settings

aaronpowell/aswa-trivia-app

Repository files navigation

Trivia App Demo

This repo contains a demo application for Azure Static Web Apps (Preview) which consists of a Trivia Game, backed by Open Trivia DB.

You can find a deployed version of the application at https://trivia-app.aaron-powell.com/.

How to play

To play to game, click "Start new game", enter your name, answer the questions and see how well you did. Each question will have 30 seconds until it times out and moved on to the next one. The questions are in the "hard" category of "Science and Technology" from Open Trivia DB.

Anatomy of the app

The application consists ofr two components, a web front end and a serverless backend. All components are within this repo so you can run it all together.

Web Front End

The web front end is written using Create React App using the TypeScript template.

You'll find the code starting in the root of the git repo, with the code then residing within /src with each of the difference pages in the pages folder.

To communicate with the backend, Apollo Client for React is used, leveraging the React Hooks.

Serverless Backend

The backend is written using Azure Functions, using the TypeScript template, and exposes the data via GraphQL using Apollo Server for Azure Functions. Presently, there's no database backend, the data is stored temporarily in memory.

Learn how to build it

I did a live stream where we built the whole thing from scratch, you can watch it on YouTube

Live Stream banner

Additional Exercises

If you want to look at wats to expand the application, there's a few opportunities:

  • Improve the UI
  • Add a proper database backend, such as Cosmos DB's free tier
  • Make the game multi-player. The data structures are designed for multi-player, but the application doesn't support it presently

About

A simple trivia app in React with a GraphQL backend, deployed to Azure Static Web Apps

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •