Wednesday, August 25, 2021

Thoughts After More Gqlgen

When working with gqlgen writing raw SQL and using the standard library is the way to query a DB. There is no ORM that easily fits into the way you need to shape your data when sending responses. The Go community also doesn't really seem to be keen on ORMs. I kind of get it.

The workflow that I've been using is to:

  1. Run migrations
  2. Add dummy data
  3. Use GUI to write out some test queries, see what works, been using TablePlus
  4. Add SQL as strings to endpoints

What I need to accept is gqlgen only really works if you write out the SQL and shape data the way you need. It's a lot more code that a traditional ORM but it's much more flexible in what you can do.

I'm working on a small project right now that uses the database/sql standard library and gqlgen to create the classic books and authors app. I think I have the setup of my models and database down now and happy to stick with this code structure.

The app is now deployed to here via render.com. I've found it a really enjoyable service to use thus far and living up to it's title of essentially being a "better" Heroku.

Next steps are to:

  1. Create client and hook up with Apollo
  2. Add authentication to GraphQL backend