Why We Chose GraphQL for Rubrik Polaris
NOV 2, 2020 | BLOG POST
In this post, I’m going to discuss why we chose GraphQL for Rubrik Polaris, our SaaS platform, and the benefits it offers our users.
First off, let’s introduce what GraphQL is and its main functionalities. GraphQL is a query language for APIs that allows extensive queries to return the specific subset of data upon request. This allows for a very efficient, single service to query against and retrieve the relevant information or invoke an action (also called a mutation). GraphQL is a relative newcomer to the API world, as it has only been open-sourced since 2015.
The challenge with GraphQL versus RESTful APIs is that REST is an established standard that many are familiar with. GraphQL is not as widely adopted yet, but we believe it is the best way to interact with Rubrik Polaris due to efficiency, agility, and performance benefits.
The Benefits of GraphQL
The biggest benefit of using GraphQL in Polaris is that by using a specific query, a request will only return the exact data queried for. This is a big departure from RESTful APIs, which always return the same type of object and all of the associated data.
Below is an example of GraphQL in action. Suppose you want to return information regarding workloads protected by Rubrik. In this scenario, you would only like to know the IDs and the protection status. To do this, you can then construct this query:
This will return only the object ID and configured SLA ID instead of all properties of the object. When comparing a similar query in REST, the returned dataset would be significantly bigger. For a single query, this does not have to be not an important consideration, but at scale, the efficiency of an API is pivotal.
An example of that can be seen by performing a comparable query using both GraphQL and REST endpoints. We will be using the following endpoints:
The difference between these two queries is almost twenty-fold when looking at the amount of data returned. This is a significant improvement in particular for frequently occurring queries and queries that return a considerable amount of data.
If you would like to learn more about GraphQL, here are a number of resources:
- GraphQL vs REST: What You Need to Know
- Introducing Rubrik API Code Capture Chrome Extension
- Diving Deeper into the Rubrik PowerShell Module
- An Introduction to GraphQL and Rubrik
Sponsored by Rubrik