Game on! Building a Unity Leaderboard with GraphQL & Hasura

๐Ÿ“น In this three-part video series, we build a Unity leaderboard with Hasura!

Follow along as Baris Tumerkan, a Unity dev who is learning GraphQL, and Sezgi Ulucam, a GraphQL dev with no Unity experience, team up to solve this challenge together ๐Ÿ’ช

Sneak preview of Unity leaderboard built with Hasura

We both learned a lot from this project (Sez about Unity, and Baris about GraphQL). The best parts were:

  • Discovering how easy it is to set up queries, mutations, and subscriptions with this Unity GraphQL client by Tade Ajiboye. Import the package, plug in your Hasura endpoint, and youโ€™re good to go!
  • Building and testing out our GraphQL operations in the Hasura console.
  • Running into bugs in our code and crushing them along the way โ€“ so you don't have to ๐Ÿ˜Ž
  • Seeing our project start to come together โ€“ especially the live scores!
  • Using Hasura Actions to customize business logic for high scores.
  • Naming our imaginary players after pets... who were named after foods. Because why not? ๐Ÿน๐Ÿฉ

If you'd like to code along at home, check out the repo here.

Part 1: Queries & Mutations

In this video, we:

๐ŸŽฎ Set up our Postgres database with Hasura

๐ŸŽฎ Hook up our GraphQL client

๐ŸŽฎ Set up GraphQL queries and mutations for our leaderboard

Part 2: UI & Subscriptions

In this video, we:

๐ŸŽฎ Display top scores on our leaderboard UI

๐ŸŽฎ Show live scores on our leaderboard with GraphQL subscriptions

Part 3: High Scores with Hasura Actions

In this video, we implement business logic for high scores using Hasura Actions! With this feature, scores are only updated when they increase.

Check constraints

Note that there's a simpler way to implement high scores, via Check Constraints under the "Modify" tab.

But when you need more complex business logic, Actions are the way to go!


We hope you had fun watching and coding along, and that you were inspired to build your own Unity projects using Hasura. And if you do, please share in the comments. We'd love to hear about them!

Additional Reading:

Blog
09 Apr, 2020
Email
Subscribe to stay up-to-date on all things Hasura. One newsletter, once a month.
Loading...
v3-pattern
Accelerate development and data access with radically reduced complexity.