# Reimaging Building Web Services
RESTful API, GraphQL and tRPC
---
## Who am I?

- your TA
- wrote many of your refernce projects
- 2-space indentation
- neovim > VSCode
- do not like Windows
---
## How would you build a service?
---
<!-- .slide: style="text-align: left" -->
## What do you need to build a service?
- Frontend?
- Backend?
- Database?
---
<!-- .slide: style="text-align: left" -->
## Which tech should you use?
- Frontend?
- React
- tailwindcss
- Backend?
- RESTful API
- authorization service
- Database?
- MongoDB
- PostgreSQL
---
## What's next?
---
<!-- .slide: style="text-align: left" -->
- Decide how would you store your data
- Decide how would you access your data
- Build your bussiness logic
---
## RESTful API

---
## What are the problems?
- tedious to standardize (OpenAPI specification)
- no guarantee the server follows the spec
- no type safety on both ends
- clients may get unnecessary data
- difficult to model some services (e.g. calculator)
---
## GraphQL

example: [GitHub GraphQL API](https://docs.github.com/en/graphql/overview/explorer)
---
## GraphQL: problems solved
- [x] * tedious to standardize
- [x] no guarantee the server follows the spec
- [x] * no type safety on both ends
- [x] clients may get unnecessary data
- [ ] difficult to model some services (e.g. calculator)
---
## GraphQL: other benefits
- only fetch what you need
---
## GraphQL caveats
- more difficult to test
- more complicated to set up
- relies heavily on code-gen
---
## tRPC

example: [Next.js tRPC example project](https://github.com/trpc/trpc/tree/main/examples/next-prisma-todomvc)
---
## tRPC: problems solved
- [x] tedious to standardize
- [x] no guarantee the server follows the spec
- [x] no type safety on both ends
- [x] * clients may get unnecessary data
- [x] difficult to model some services (e.g. calculator)
---
## tRPC caveats
- slighly complicated to setup
- have to use typecript for backend in the same project
- more complicated to call from outside the project
---
## A great starting point for your new projects: `create-t3-app`
{"breaks":true,"description":"slide: https://hackmd.io/p/template-Talk-slide","title":"Reimagine Building Web Services","contributors":"[{\"id\":\"647c5228-6699-4868-8f60-001a5307610c\",\"add\":3075,\"del\":3023}]"}