What is GraphQL and why you should care?

Hello dear reader!

First of all I would like to apologise for not having been able to post in the last few weeks, I have been swamped with work. Before continuing, I’d like to wish you all a very happy new year (better late than never), and I couldn’t think of a better post for the start of this year than this one.

graphqlAs you all know, most Apps depend on a backend system. This backend is responsible for communicating and serving data among the different users.This involves having an API (Application Programming Interface) to access the data. Most APIs are REST (Representational State Transfer) APIs. However, good old Facebook started to see some limitations and thought they could come up with a better and more efficient system. In this post we will do a bird’s eye of how it works and what advantages it brings to the table.

In a nutshell, GraphQL is a syntax that describes how to ask for data, and is generally used to load data from a server to a client. GraphQL has three main characteristics:

  • It lets the client specify exactly what data it needs.
  • It makes it easier to aggregate data from multiple sources.
  • It uses a type system to describe data.

So how did this come to be?

For example, imagine you need to display a list of posts, and under each post a list of likes, including user names and avatars. So, you tweak you like array to contain avatars. Such as shown below.

gql1

But now, it’s time to work on your mobile app, and it turns out loading all that extra data is slowing things down. This translates in the fact that you need two endpoints, one with the likes and one without them.

Furthermoire, imagine if the “likes” and the “avatar” where to be stored on different storage types (MySQL for Avatar and MongoDB for likes for instance). Well now, we are in a bit of a mess. Extrapolate this scenario to however many data sources and API clients Facebook has to manage, and you can imagine why good old REST APIs were starting to show their limits.

The Solution

The solution Facebook came up with is conceptually very simple: instead of having multiple “dumb” endpoints, have a single “smart” endpoint that can take in complex queries, and then massage the data output into whatever shape the client requires.

What this means, is that there is a layer between the client and multiple data sources that is in charge of receiving requests and deciding how to serve them. Let’s have a quick metaphor example: The old REST model is like ordering pizza, then getting groceries delivered, then calling your dry cleaner to get your clothes. Three shops, three phone calls.

gql2

GraphQL on the other hand is like having a personal assistant: once you’ve given them the addresses to all three places, you can simply ask for what you want (“get me my dry cleaning, a large pizza, and two dozen eggs”) and wait for them to return.

gql3

In other words, GraphQL establishes a standard language for talking to this magical personal assistant. Why Facebook decided not to call it Siri is beyond me ;).

The best way to understand more about GraphQL and its possibilities is by practical examples. Let me know if you are interested and what you would like to see in the next post.

Thanks for reading!

Until next time!

Advertisements

Location sharing is “The next big thing”

Hello dear reader,

5b6b45f022a45f0d1b2e05a8c35f85c4It has been a busy last few weeks for many companies, it seems that they have decided that our vision for the last four years was correct and have decided to roll out location sharing in a variety of Apps. Curiously they all have understood that constant location is totally absurd, and that what users really want is a timed experience that respects privacy (Please, our dear friends at Zenly take note, constant location sharing is off the plate for most users)

The first announcement was a rumour that WhatApp was rolling this out for groups. It came out as a post on Reddit and sparked a massive privacy outrage. This is no surprise, since it was the same day they announced targeted ads. You can read more about it here: https://techcrunch.com/2017/02/03/whatsapp-tests-real-time-location-sharing-in-its-app/

The second came from Google Maps, they have decided your hangouts contacts could use a little sprucing from knowing your location, although it only works in a unidirectional paradigm (unless you both send a request). They made a funky video in a Google-style that illustrates the approach.

Last, but not least, in an attempt to copy everything that works, Facebook (or pseudo Snapchat as some people say) decided to join the party too. You can now share your live location with your messenger contacts. https://9to5mac.com/2017/03/27/facebook-messenger-live-location/

It is clear why all these big names are pursuing this, and it is clear that it is time for a leader to take the market. However, I personally wouldn’t trust those big names with my location data. After all, we have seen what and how they use it for. There is a reason why we at Wave have had this approach from the beginning, we are completely focused on being the best-most private location App. So, do yourself a favour and stay with who will never save or use your data, always use the best technology, and, why not, the cooler App ;).

giphy_7

There is a reason we have been so quiet lately, so keep your eyes peeled, because we are about to make location sharing go from red hot, to absolutely scorching ;)!

Feel free to drop a line in the comments!

Until next time!

Parse closes down: Is Backend as a Service profitable?

Parse starting sending messages last week that it would be winding down it’s services. This came as a shock for many people who have come to rely on their services as a way to reduce the complexity of having to maintain, deploy and scale your own backend solution. For those of you who haven’t seen it, you can take a look at the announcement below.

Parse closes

It is clear that Facebook is not joking around and not keeping services and tools that are not as profitable as they need. This is a shock for companies and developers as it demonstrates that in the end trusting your backend to an external system can have nefarious consequences for you. From the moment you don’t control all the variables, the risk of this type of problems always exists.

Parse are going a give a full year until the sun sets on the platform, they are even open sourcing the Parse server (which is build on node.js and requires a Mongo Database). But mind you, self hosting a Parse server is by no means easy and never substitutes the ease of the original Parse panel, so other alternatives like setting up your own APIs and creating your own infrastructure, or another Backend as a Service should be considered.

A few years ago, I published a post named “Is Backend as a Service the new Gold rush?”. In this post I analysed if systems like Parse that made developing Apps with a server side were the new money making scheme of the tech world companies. However, after the Parse announcement, one can’t but help thinking that perhaps it is not such a profitable endeavour.

If you stop to think about it, big companies usually create their own Backends and host them on systems like Amazon Web Services, and those are the ones that pay the big bills. Small developers that use Parse, tend to have the free version (which has a ridiculously high limit usage before it starts charging) or pay very little money.

So, is backend as a service really profitable? Will it become an open source self hosted alternative? Or will companies use this as a launch pad for their new and reinforced Parse alternatives?

Let me know your thoughts!

Where to find me

Hi!

I’ve prepared a slideshow showing you the different places where you can find me. Hope to hear from you soon:

The links to the different places are:

Google+:

https://plus.google.com/u/0/116621169637448747006/posts

YouTube:

http://www.youtube.com/user/NightUky

Facebook:

https://www.facebook.com/pablo.clementeperez

Twitter:

https://twitter.com/pclemnte

WordPress:

https://pabloclementeperez.wordpress.com/about/

Linkedin:

http://www.linkedin.com/profile/view?id=255996601

Xing:

https://www.xing.com/profile/Pablo_ClementePerez

Slideshare:

http://www.slideshare.net/pabloclementeperez

Hope to hear from you soon!

Pablo