3 ms·
> Each time you need to have a new highly specialized query you create REST resource. I love it how you meander. First you where complaining about ORM creating
by dmitriid 8y ago
> Each time you need to have a new highly specialized query you create REST resource.
I love it how you meander. First you where complaining about ORM creating complex queries. When I countered with the simple fact that you don't need ORM, and "complex queries" are highly specialised efficient queries that take full advantage of DB capabilities, you immediately go off on a tangent talking about RPCs.
:-\
> That fine, because easy cache invalidation is worth it.
No it's not fine. Because instead of retrieving a simple single highly optimised dataset in one go you do multiple inefficient roundtrips to the database.
> I said data access, not data.
access. /ˈaksɛs/ 2. obtain or retrieve (computer data or a file).
All data access happens on the server through inefficient database queries and in-memory juggling of data. Clients have no access to data, they send queries.
> Whole point dataloader is to cache between requests.
Dataloader (in it's original form and specification) doesn't cache between requests.
DataLoader provides a memoization cache for all loads which occur in a single request to your application.
DataLoader caching does not replace Redis, Memcache, or any other shared application-level cache. DataLoader is first and foremost a data loading mechanism, and its cache only serves the purpose of not repeatedly loading the same data in the context of a single request to your Application.
If any other Dataloader implementation implements caching between requests, they are just reinvent the wheel.
> No, they are query interface. They expose DSL for accessing data.
ORM is a DSL at it's core. And that's what "dataloaders" and "resolvers" in essence are: ORMs.
To quote from Apollo:
In order to respond to queries, a schema needs to have resolve functions for all fields.
const resolverMap = {
Query: {
author(obj, args, context, info) {
return find(authors, { id: args.id });
},
},
Author: {
posts(author) {
return filter(posts, { authorId: author.id });
},
},
};
Oh look. A wild ORM appears! Oh look how it quickly devolves into multiple DB roundtrips for any non-trivial query.