Today I Learned - Rocky Kev

TIL ELI5 for GraphQL

POSTED ON:

TAGS:

This is a really good ELI5 for GraphQL, from Ben Halpern:

NOTE: I modified it a bit to make it easier for me.

It's lunchtime at school and they're serving your favorite meal: Meatloaf and mashed potatoes.

You really like the meatloaf and mashed potatoes part the most, but you're a good kid so you know you need to eat your peas and carrots. You are excited about the corn and of course, the gravy.

The current setup (REST APIs), you have to go to each cook, who each will give you a single plate. So to get a full plate of mash potatoes, meatloaf, corn, peas & carrots... you'll need to make 4 trips, one to each cook.

But you don't want 4 single plates! You're not going to eat all those veggies! So you need to be specific about what you ask for. You need two scoops of mashed potatoes, a big slice of meatloaf, half an ear of corn, and about a fistful of peas and carrots. But communicating all this to the cafeteria chef is a mouthful.

That's why you use one of these:

It's a GraphQL tray. Instead of dealing with four chefs, you can just go over to a single food window. Inside the kitchen, the cooks scoop out the portions from their big Mongo vats of meat, potatoes and the rest. Some chefs use Postgres tubs. Maria and Cassandra brand tubs are also popular in some school districts. But none of that really matters to you. It might matter if you had to give the chef specific instructions, but it's his job to figure out how to scoop out the mashed potatoes and fit the into the shape of your tray.

via Jean-Michel Fayard's Best of #explainlikeimfive


Related TILs

Tagged:

TIL minimal responsive image component

So when I saw that JS frameworks made image wrapper components (like Nuxt was with nuxt-img), I was blown away and wanted this power at work.

TIL why google recommends you avoid document.write()

By injecting it with code, it bypasses the preload scanner. This means that the browser can’t request this file until it’s actually run the '<script>' block that inserts it, which is very much just-in-time (and too late).

TIL the history of fonts and COLRv1

COLRv1 fonts, have a smaller footprint, vector-scalable, reposition-able, gradient-featuring, and blend-mode powered fonts that accept parameters to customize the font per use case or to match a brand.