Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OData vs GraphQL [closed]

Tags:

graphql

odata

Is there a good comparison of GraphQL & OData in terms of performance, developers usability, community, etc.. All articles that I find in the Internet are very bias.

What would be the best way to return a big bulky JSON or binary data?

like image 433
Yar0myr Avatar asked Jun 04 '18 19:06

Yar0myr


People also ask

Is OData outdated?

I was assured by the company that "both within the standards organizations and the industry, OData is alive and growing." I didn't think much more about it, but suddenly I notice it being put to new uses in the age of Blazor and ASP.NET Core, championed at Microsoft by Hassan Habib, sofware engineer II.

Is GraphQL killing REST?

Will GraphQL Kill REST APIs? The answer to this question is a big “NO”. There won't be any issue with your already working REST API. They will not change after your migration to GraphQL.

Is OData an open API?

In computing, Open Data Protocol (OData) is an open protocol that allows the creation and consumption of queryable and interoperable REST APIs in a simple and standard way.

What is the difference between REST and OData?

REST stands for REpresentational State Transfer which is a resource based architectural style. Resource based means that data and functionalities are considered as resources. OData is a web based protocol that defines a set of best practices for building and consuming RESTful web services.


2 Answers

I have researched and also tried with Both GraphQL in Dot Net and Odata in DotNet Web API to create a working demo and What I found are

  1. Developer Usability Considering you have existing WebAPI(DotNet Framework) and want to migrate to GraphQL or OData compatible WebAPI then my answer is to choose OData because of its easy integration and Out of the Box Filter, OrderBy, Select, Expand, etc feature (Refer MSFT On DotNet OData). If you choose GraphQL then you have to do a lot of work like Create Type, Schema and Query and Implement Resolver for each query.
  2. Performance depends on your query logic. GraphQL and Odata Both have the capability to get what you request using $select in OData and in GraphQL you can request by their Query convention.
  3. API Development From Scratch, If you want only single endpoint for all API request and don't want to maintain versioning endpoint, Autosuggest field name and type of schema then GraphQL is the best option. But Availability of GraphQL Library for Each framework and Community varies for Technology stack(e.g. nodejs, C#, Ruby, Java etc)

Yes, I have reviewed and read article by Telerik which have described in detail. Comparision PDF For GraphQL and Odata I am attaching side by side comparison image only you can dig out detail in Reference link GraphQL vs OData.

Standard API

Standard API

Here, No in API Versioning/ maintenance is positive meaning single endpoint and get rid of two versioned API

Query Capability

Query Capability

Surface Capability

Surface Capability

Mainly OData service is used when you want to provide access to your database with minimal effort for CRUD Operation.

However if you aware about Sharepoint REST API and Office 365 REST API It is based on OData and provides a wide range of API. Now Microsoft is building universal API which is called Graph API or Microsoft Graph which by default enabled for CORS request and unified endpoints to Request from Office 365, dynamics 365, Outlook Exchange API, Onedrive API etc. Which are also supports OData.

like image 126
anomepani Avatar answered Oct 14 '22 06:10

anomepani


It also does not seem like a good idea to use the POST method to request data. And apparently the amount of data needed to make a request to the server is much greater. According to examples from the Sumit Sarkar article:

Example for OData

Example for GraphQL

The amount of data trafficked to make a request is much greater in GraphQL than in OData. Although, the result (response) is the same.

like image 45
Silvair L. Soares Avatar answered Oct 14 '22 05:10

Silvair L. Soares