What is GraphQL?

Introduction

GraphQL is developed by Facebook. They initially developed and used it for their own systems and eventually released it to the public for anyone to use.

Pros

A big pro is that you can use GraphQL to get ONLY the data that you need. You would not need to waste time and resources getting all the extra useless data. An example of this is if you have a huge database full of accounts that includes a username, password, email, phone number, and address but you only need to get an email, instead of the whole object. You can grab only the email from only the account you need with GraphQL, which may not seem like a big deal, but what if you need the emails of all the users? That could potentially save a huge amount of time depending on the amount of data.

Cons

One thing that may be a reason to focus on REST APIs over GraphQL is that REST APIs are way more common and if you’re in the professional world, over a personal project, it is a lot more likely that you will be using a REST API instead.

Conclusion

The decision is up to you, and this blog outlines the basic differences between GraphQL and REST, however, the way I see it is that GraphQL is better but has a greater barrier to entry. Whether that learning curve is worth it or not, is up to you, and may not be worth it if you need to constantly fetch a lot of data, don’t care about too much optimization, or even because your job doesn’t use it. Happy coding!!!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store