tags

Game on! Building a Unity Leaderboard with GraphQL & Hasura

09 April, 2020 | 2 min read

📹 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:


Sezgi Ulucam

Sezgi Ulucam

Developer Advocate 🥑 @ Hasura | Front-End Dev | Baker | Dancer | Massage Therapist | WFR

Read More

Subscribe IlluSubscribe Illu

Monthly product updates in your inbox. No spam.

Loading...