Game on! Building a Unity Leaderboard with GraphQL &amp; Hasura
Tags: unity3d, graphql, gamedev
Published: 2020-04-14 03:50:47

---
title: Game on! Building a Unity Leaderboard with GraphQL &amp; Hasura
published: true
date: 2020-04-09 18:09:42 UTC
tags: #Unity3D #GraphQL #Gamedev
canonical_url: https://hasura.io/blog/building-a-unity-leaderboard-with-hasura/
---

📹 In this three-part video series, we build a [Unity](https://unity.com/) leaderboard with Hasura!

Follow along as [Baris Tumerkan](https://twitter.com/BarisTumerkan), a Unity dev who is learning GraphQL, and [Sezgi Ulucam](https://twitter.com/sez), a GraphQL dev with no Unity experience, team up to solve this challenge together 💪

![](https://hasura.io/blog/content/images/2020/04/test-palette.gif)<figcaption>Sneak preview of Unity leaderboard built with Hasura</figcaption>

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](https://github.com/Gazuntype/graphQL-client-unity) by [Tade Ajiboye](https://twitter.com/gazuntype). 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](https://github.com/hasura/unity-hasura-leaderboard).

## Part 1: Queries & Mutations

In this video, we:

🎮 Set up our [Postgres database](https://hasura.io/learn/database/postgresql/what-is-postgresql/) with Hasura

🎮 Hook up our GraphQL client

🎮 Set up GraphQL queries and mutations for our leaderboard

<iframe width="480" height="270" src="https://www.youtube.com/embed/TPjleEhJyMk?feature=oembed" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

## Part 2: UI & Subscriptions

In this video, we:

🎮 Display top scores on our leaderboard UI

🎮 Show live scores on our leaderboard with GraphQL subscriptions

<iframe width="480" height="270" src="https://www.youtube.com/embed/SSmImVvDigc?feature=oembed" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

## 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.

<iframe width="480" height="270" src="https://www.youtube.com/embed/VamfnasKDxE?feature=oembed" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

* * *

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!

You can also join us on [Discord](discord.gg/hasura) for more discussions on Hasura & GraphQL! 

Sign up for our [newsletter](http://eepurl.com/dBUfJ5) to know when we publish new articles.