Heavy Lifting: My Commit Hackathon Onboarding Project
For my hackathon onboarding project, I decided to try out new technologies I’ve been interested in for a while (but never had the opportunity to use in my professional career) while developing an app that I could use in my hobbies. You can see all results on both my Github repos, frontend and backend.
Deciding what to do
Deciding what to do for my onboarding project was a tough decision. I wanted to check out game development using GoLang, libraries such as Pixel, where you can start developing a new game from scratch, or even create a Chess engine with Go and try different search algorithms (hello machine learning). I had to demo my project in a week, so choosing a technology where I had little to no familiarity was totally out of the question. I decided to take a safer path and do a simple mobile app, with a backend, that would benefit me by being usable for one of my regular everyday activities: going to the gym.
The project
My project is relatively simple. It involves a frontend project, specifically a mobile app written in React Native, and a CRUD backend project with NodeJS, Prisma and GraphQL.
The idea behind the app is to create a way to track my daily powerlifting workouts. Many of the weightlifting apps available today are geared towards bodybuilding. Concepts that I want, such as reps in reserve, perceived exertion and AMRAP (as many reps as possible), are rarely available. So taking into consideration the lack of apps available for this kind of activity, I took the opportunity to create one that would fit my needs.
The stack
On the frontend, I used React Native, react-native-paper for styling, Urql for GraphQL frontend integration, and graphql-codegen to generate my custom hooks by writing queries and mutations.
On the backend, I used Apollo Server Express to spin up my GraphQL server, TypeGrahQL, and Prisma—and here's where it gets interesting.
As everybody knows, to work with Prisma, you first need to write down your schema. It will be your source of truth for all database relationships and tables, and the library will generate all code necessary for your project to have database access. At the same time, there's another library out there that produces your GraphQL schema based on your Prisma schema and all relationships you defined in that file, generating all resolvers for all your CRUD operations.
With all that set up, development is straightforward, and voilá, instead of dealing with two different schemas, Prisma and GraphQL, you have a single source of truth that works on both ends: the database and API.
Here's my entire backend:
Just select the resolvers you're going to use.
The result
Here's how the app works.
Open the app and create workouts.
Then create an exercise list for each workout. Start your workout by clicking the button at the bottom.
After finishing your workout, it will be saved in the database. On your next workout, you will have access to your last session, to remember how good or bad it was, by checking "Last Session."
Conclusion
I want to address a couple of issues and add many features, that’s for sure. The project is ongoing, so I'll be working on it from time to time, especially if I feel like my React or React Native skills are getting rusty, since I want to focus more on backend work professionally.
It was terrific to see how easy it was to spin up a backend project using Prisma and TypegraphQL and not worry about database connection, ORM, GraphQL schema or GraphQL server. Will I use it in any professional projects? Most likely not. Here’s why:
1) Lack of cascade delete. While working on the app, I realized that I couldn't delete workouts or exercises that already had any kind of relationship. Prisma doesn't have an easy solution for cascading delete, so the user will have to delete each relationship manually. They would be able to delete a workout or exercise, which is annoying. Their documentation explains how to set it up, but it's not trivial.
2) Often, in production, you will face situations where you need to take care of database transactions yourself or sometimes fine-tune SQL queries. Prisma is not a good candidate for those tasks.
Those are two situations where I find it challenging to use Prisma in an actual professional project. Still, it was fun to work on it, and the fact that it allowed me to focus on the frontend and build an app in just a couple of days was a tremendous experience. So what's next for me to try, you say? Knex.js—and bench press.
We hire Software Engineers to build their careers with promising early-stage startups. Join the waitlist today!
Daniel Yang is a full-stack engineer who loves learning new technologies and new coding patterns, especially if it has to do with TypeScript. When not coding, you will probably find him making bundlers on some chess games, exploring new trails, biking or at the gym (obviously).