Pseudo Random Nonsense Generator

3 ways to write to a database

· note

taken from How To GraphQL

Typically, when implementing resolvers and connecting to the database, you have two options - both of which are not very compelling:

- Access the database directly (by writing SQL or using another NoSQL database API)
- Use an ORM that provides an abstraction for your database and lets you access it directly from your programming language

Writing raw SQL from your backend

  • dealing with SQL in resolvers (GraphQL resolvers, or normal REST resolvers) is complex and quickly gets out-of-hand
  • SQL queries are submitted to the database as plain strings. strings have no structure, so tooling won’t be able to help find any issues / perform autocomplete

therefore this option is tedious and error-prone

ORMs

  • basically predefined raw SQL queries wrapped up as function calls
  • ORMs typically only implement rather simple solutions for databse access
  • doesn’t actually work when using GraphQL

Prisma (ORM+)

  • provides a data access layer
  • your resolvers are basically forwarding incoming queries to the Prisma engine
  • maybe works because the Prisma client is good?