
App Store Build Rejection : An Absolute Chaos
This article is based on my experience of iOS app submissions in Synclovis Systems from last 5-6 years.
We have been using Rest APIs from a long time which gives us a lot of flexibility in terms of Data Formats, better support to web clients,speed with lesser bandwidth and many more. Most of the servers for making APIs for Mobile, Webpages now-a-days are built on REST protocol.
If everything works as intended while using REST then Why we should now consider using GraphQL?
The answer to this question is pretty simple. GraphQL gives a better platform for data synthesizing,better speed,better memory graphing etc.The APIs developed on REST protocol become quite inflexible when it comes to some sudden client end requirements.
One of the major reasons where GraphQL dominates the REST protocol is Data Handling. Let’s take an example where we have developed two REST API which contains data such as:-
Now, whenever this API is called it will return all the data it contains, which is quite useful in some cases. Now let’s think of the case where we are using Books API. But instead of using all the 4 data, we only need 3 data i:e; Name, Author & genre.In such cases,while using REST API, we will all the five fields irrespective of the payload we pass and the actual requirement of the client, which can be called Over Fetching of data which will cause a delay in data processing & more memory allocation.
This is the place where GraphQL APIs comes into play. With the help of GraphQL, we can query for only that fields which is required by the client-end.
CASE OF REST API :-
API ENDPOINT:- ‘/fetchBooks’
Requirement:- Name & Author Name
Once this REST API is called, then we will get the data in the following way:
{
"id":"1",
"name":"Hamlet",
"author":"William Shakespeare",
"genre":"Drama",
},
{
"id":"2",
"name":"Odyssey",
"author":"Homer",
"genre":"Epic",
}
In the above case, the requirement was only Name & Author Name, but instead we got all the data some of which is completely useless.
CASE OF REST API :-
API ENDPOINT:- ‘/fetchBooks’
Requirement:- Name & Author Name
In case of GraphQL, we just need to pass the required fields name as arguments and then we will get a response in the following way:
{
"name":"Hamlet",
"author":"William Shakespeare",
},
{
"name":"Odyssey",
"author":"Homer",
}
In the above case, the response which we received is the exact fields which was the requirements.in this way we completely get rid of the useless which will further help in betterment memory allocation,data complexity.
In case of REST API the response code which we get on a successful API call is 200 OK. Similar way, in case of any kind of error we get responses such as 404,403,500,503 etc, which can be easily referenced to know which type of has occurred. Whereas in case of GraphQL APIs, On every API call, we get the status code of 200 OK and in case when any error occurs during the network call, a complete error message is sent from the server end to client side.
Example In Case of REST API:
{
"error":404
}
Example in Case of GraphQL API:
{
"errors": [
{
"message": "Field \"some field" must not have a selection since type \"String\" has no subfields.",
"locations": [
{
"line": 23,
"column": 45
}
]
}
]
}
From the above case, We can clearly see the difference between the Error Handling Methodologies.
At the end, Both REST & GraphQL are just different ways of calling the API with their own Pros & Cons. Moreover, if you have used REST and build you API’s on this protocol, you won’t feel a lot of challenges in implementing GraphQL also.
Some of the key benefits of GraphQL over REST are:-
This article is based on my experience of iOS app submissions in Synclovis Systems from last 5-6 years.