Back to blog

Why You Should Start Your Subsequent API Project With GraphQL?

If you want to start a mobile single page application it would probably be best for you to have one API for each of following products, such as website or other app. GraphQL is often presented as a new groundbreaking way of thinking of API, as compared to the REST model. Below you’ll find couple of arguments on why it could be a good idea to consider using GraphQL for a mobile application.

author: Weronika Nużyńska

.22 November 2017

GraphQL is a query language for APIs that has been powering Facebook mobile apps since 2012. Its spec became open sourced in 2015 and is now available in various environments. Thanks to a revolutionary way of accessing data, GraphQL is very often used for building mobile applications. In the REST model you would send two separate requests to download the entire user data and then display the necessary parts of it. It takes a certain amount of time and time is something that really matters in mobile applications, where we’d like to get the data as quick as possible. With GraphQL, instead of working with fixed servers-defined endpoints, you can define the amount of data you need for the moment and send queries to get these files in one request. 

GraphQL for mobile applications

Why you should consider using GraphQL for mobile applications?

Predictable results

As mentioned before, GraphQL queries sent to your API always return predictable results. The amount of data to be downloaded is defined by the app developer himself, not by the server. You get the exact data you asked for – not more, not less. And this makes your application stable and run much faster.

Single request

Another reason that speaks for using GraphQL for mobile applications to boost performance is a possibility to limit to a single request. GraphQL APIs can get all the data in only one request instead of loading from multiple URLs. All you need is just one defined endpoint.

Versioning

GraphQL’s API schemes provide the possibility of constant improvement. In most APIs, adding a feature or changing the data structure is a massive change that recquires preparing a new version. This makes the apps maintenance more difficult. Since GraphQL returns only the data that were specifically requested, new features can be added with new types and fields so there’s no need to spend much time on developing a new version.

Independent database

GraphQL itself is database independent – it is a specification for queries and responses between the client and server. Your GraphQL server connects with any database of your choice – either MySQL, NoSQL, Mongo, text files etc. – which creates a great number of possibilities.

GraphQL for mobile applications

To sum up, a big reason for using GraphQL for mobile applications is the app’s increased performance, which creates a major business value. If your project involves many applications and channels that would use one database you should really consider building a GraphQL API.

Visit the GraphQL website for more information or drop us a line!

Weronika Nużyńska

author

You might also like