Monday, February 18, 2019



What is GraphQL

It is a specification laid out by Facebook which proposed an alternative way to query and modify data. Think of it is an as a complimentary of REST/RPC.

Now head here and read the original graphQL documentation. It will take 2-3 hours tops but is a worthy read. This will help you build some impressions on it and help contrast against mine below:

Why use GraphQL

Core advantage

  • Instead of defining custom backend rpc/rest endpoints for every data-shape, graphql allows you to build a more general endpoint which give frontend/mobile engineers freedom and query and play with the data. It might be less efficient, add a bit more complexity (need for things like data-loader), harder to standardize and control client-contracts for. What it looses in complexity and control, it gains in flexibility and freedom - provided your data model is worth of a graphql-ish query
  •  How to tell if my data-model graphql-ish?
    • Are there complex relationships between your models? Is there a need for client to traverse multiple relationships in a single call?

      For eg, if you are yelp, think about the following queries you might need:
      • get the reviews left by all the folks who live in my town
      • get the top 3 rated reviewers from the places that I've reviewed recently
    • In a traditional world, these would need 2 separate backend endpoints. With GraphQL on the server side, you can implement a schema that abstract your business-domain and allows the client to interact (query/write) directly.
Other Advantages
  • The GraphIQL (ide for graphql) enables callers to play around, explore and just request what they need. The shape of the response matches the shape of the calls. This removes building special endpoints per use case.
  • Might be a natural way to query data models which resemble a graph
  • No versioning or anything (I feel this is also a con)

Now the downsides:
  • FB released just the GraphQL spec. The implementations are community driven. Reading reddits, seems like the docs may not be of the highest standards. 
    • Again, this might improve over time.
  • Opening up backends to unhealthy query patterns that might increase load on the system. Generally, if a feature requires an an bad-query (say multiple joins, costly queries, etc.) that gets factored into the cost  of the feature. But with GraphQL abstracting all this, it might be hard to capture this in planning stages. 
    • An opposing thought is that APIs should be client driven and clients know best what they want. Backends can monitor call patterns and optimize those expensive calls.
My overall impressions is that GraphQL is not a magic pill for all scenarios. It fits some use cases very well: if your model is heavy AND involves complex relationships AND clients are dynamic and want flexibility in how the query this data - then GraphQL might be worth giving a try.


  • Hello-World GraphQL Client/Server in Go - link

Backend - Tech refresher 2019

Hello there

As a software engineer, it is important to keep updating your skillsets by learning the latest programming-elements (includes paradigms, patterns, languages, tools and frameworks). This becomes a bit easy if you already working on the cutting edge of something. Even then, it is possible to go too deep and loose breadth.

I've taken upon myself to do a tech refresher every year. The intent is to read, experiment and understand these elements by spending anywhere between 4 days to 4 weeks. The ultimate goal is: "do I know most that I need to know to build a planet-scale backend tech-stack ground up"

I'll write up my learnings in posts to help myself (and maybe others) refer it.

Here is the initial list I'm thinking about:

  • Redis
  • MySQL, GraphQL
  • Aurora, Mesos, Kubernetes
  • Cadence, SWS
  • Cassandra, MangoDB, NoSQL, MySQL, Spanner, S<, DynDB
  • ELK
  • Flink, Storm, Samza, Spark
  • Hadoop HDFS, Yarn, MapReduce
  • Hive, HBase
  • Kafka, Zookeeper
  • NW: http, Tcp, thrift, grpc, yarpc, 
  • Terraform, uCapacity
  • Vertica
  • Linux kernal

They are no particular order although there might be some meaning in their grouping.
I'll keep expanding / contracting this as we go ahead.

Tuesday, December 25, 2018

Import a list into Wunderlist - MacOS

I was bored on Christmas day and thought I ll read the wiki pages of all the 195 countries in the world. To keep track of the progress, I wanted to create a list of them in my favorite task-app Wunderlist.

A simple search got me the list, but now the problem is to import them into Wunderlist. Being on MacOS, it took me sometime to understand how apple-script + automator work, but at the end, it was trivial.
1. Goto Automator - New - Workflow 2. Add an AppleScript and paste the following
set U to {"Algeria", ... "Zimbabwe"}

repeat with i from 1 to number of items in U
    set X to (item i of U) as text

    tell application "Wunderlist"
        tell application "System Events"
            delay 0.25
            keystroke "N" using command down
            delay 0.25
            keystroke (X)
            keystroke return
        end tell
    end tell

end repeat
The above script in Automator types out the list into the Wunderlist application. Quick and dirty but does the job.

Saturday, September 16, 2017

About me


I'm currently working as a software developer in the logistics industry in San Francisco. 
My aim is to impact billions of people's live for the better and make the world a better place.


Monday, September 11, 2017

Go lang: Return True specified Pct% of time

When writing test for state machines, I came across a need for a helper that would all call flow into a path some percentage% of times.

func TestSelfDrivingCar_BasicRun(t *testing.T) {
car := NewMockCar(t)
if (/* 50% probability that this will happen */) {
} else if /* 25% probability that this will happen */ {
} else {
/* 25% probability that this will happen*/

You can write a small Go helper like this:
package testutils

import (

// Odds returns True to pct% number of Check() calls
type Odds interface {
Check() bool

// odds returns `true` pct% of times
type odds struct {
randgen *rand.Rand
pct int

// NewOdds returns a odds instance with the given percent vaule
func NewOdds(pct int) Odds {
src := rand.NewSource(time.Now().UnixNano())
return &odds{
randgen: rand.New(src),
pct: pct,

// Check returns True to pct% of Check() calls
func (o *odds) Check() bool {
return o.randgen.Intn(100) < o.pct

func TestSelfDrivingCar_BasicRun(t *testing.T) {
odds50pct, odds25pct := NewOdds(50), NewOdds(25)
car := NewMockCar(t)
if odds50pct.Check() {
} else if odds25pct.Check() {
} else {
/* 25% probability that this will happen*/

ps: No, I don't work on self-driving cars - this is just a code sample :)

Wednesday, May 18, 2016

[BackTracking] [C++] Permutations of given string

void swap(char &a, char &b)
a = a^b;
b = a^b;
a = a^b;
void _strPermute(char *s, int n, int pos)
if (pos == n-1)
cout << s << endl;
for (int i = pos + 1; i < n; i++)
swap(s[pos], s[i]);
_strPermute(s, n, pos + 1);
swap(s[pos], s[i]);
void printStringPermutations(char *s, int n)
if (n < 2) return;
_strPermute(s, n, 0);

Thursday, June 11, 2015

[TIP] How to unselect all items in Wunderlist

I've been using Wunderlist for some time. It is a great tool especially when it comes to group shopping. I've seen a lot of people posting questions on how to "group unselect" items on wunderlist. It was even on  the "most requested feature-list".

I found a way to do this in 3 super quick steps- so sharing it below:

  1. Press CTRL+A to select all items (Ensure the completed items are hidden - this should be default) and then Press CTRL+D to mark them as completed.

  2. Now all items should be hidden since they are marked as complete. Now click 'Show marked items' to show them all.

  3. CTRL+A to select all and CTRL+D to mark them incomplete.

This has really helped me with my grocery lists since I would need to reset it before the next purchase.


GraphQL What is GraphQL It is a specification laid out by Facebook which proposed an alternative way to query and modify data. Think o...