Skip to content

Instantly share code, notes, and snippets.

View tamlyn's full-sized avatar

Tamlyn Rhodes tamlyn

View GitHub Profile

How the Apollo Client cache works

Queries

A query is only served from cache if the same query path, with the same variables, was previously requested.

For example if you fetch all Fund objects:

@tamlyn
tamlyn / README.md
Last active January 24, 2024 16:44
The case against ORMs

The case against ORMs

My experience of ORMs goes mostly as follows:

  • you have to write your queries in the proprietary DSL but that's OK because there's lots of documentation you can read to learn how to do the things that you already know how to do in SQL
  • inevitably some queries are not possible in the DSL but that's OK because you can also run raw SQL queries through the ORM
  • when running raw SQL queries you lose type safety and the 'mapper' part of the ORM is no longer automatic but that's OK because there's an API to let you specify the types and the mapping yourself
  • lazily loading associated entities is too slow but that's OK because you can specify up front which related objects should be fetched from the database
  • when dealing with large amounts of data all the instantiated classes take up too much memory and kill performance but it's OK because you can specify that you want data-only objects (without methods)