Dispensa Ep.3 - Getting to MVP - Hasura Hackathon

Mar 18, 2022ยท

2 min read

Dispensa Ep.3 - Getting to MVP - Hasura Hackathon
Play this article

Introduction ๐Ÿ‘‹

After the authentication system and the preparation for the connection to Hasura (previous episode), we can now move to implementing the actual functionality of the application.

GraphQL Queries ๐Ÿ”Ž

With the codegen in place, creating new GraphQL requests is just a matter of writing new operations as .graphql files.

For example, this is the operation that fetches the products for a user:

query Products {
  products(order_by: { name: asc }) {

Notice how there is no mention of the user's id? This is because Hasura is able to extract this information from the signed JWT token and enforces all defined authentication rules.

For example, the access on the products table is defined in a yaml file as follows:

  name: products
  schema: public
- permission:
    - code
    - created_at
    - id
    - name
    - user_id
        _eq: X-Hasura-User-Id
  role: user

Generated hooks ๐Ÿช

Running the generation script, we receive new objects that can be used with urql hooks:

const [{ fetching, error, data }] = useQuery({ query: ProductsDocument });

// ...

return (
    {error ? (
    ) : fetching || !data ? (
      <ActivityIndicator />
    ) : (
      <SomeList data={data} />

The result โœ…

Through a combination of new GraphQL operations and the related screens and components I was able to have a fully functional MVP up and running in relatively little time. [start, end]

Next steps โญ๏ธ

Now that the basic implementation is completed, I want to focus on creating a decent UI and then move on to releasing a first versions on the App Store and Google Play.


"Dispensa" is the Italian word for "Pantry" and my idea is to make an application to track what food is available in your home to make the experience of buying groceries a bit easier.

As always, you can find me on Twitter and GitHub. The code for this project can be found on its GitHub repository