Hacker News new | ask | show | jobs
by wehadfun 3379 days ago
How does GraphQL compare to OData?
2 comments

Interesting, I don't think I've ever used OData. It looks like OData is similar to JSONAPI? GraphQL is strictly a specification and query language for making queries against your API in the same way that your backend makes queries against your database. You can grab as much data as you want in a single request, as you can with certain RESTful protocols like JSONAPI. However, with GraphQL, you don't really have to roll your own protocol implementation. You simply define functions that handle certain portions of your operations by making calls to your model layer or service layer. I would choose GraphQL over JSONAPI any day.
They're similar with a few key differences. First, in OData, the URI is still a big part of the API, whereas the URI is unimportant in GraphQL, which allows GraphQL clients to simplify routing logic. Second, GraphQL lets you specify arguments on any field within the selection set. OData's parameters are far less flexible. Finally, and less objectively, I feel OData's query filters on collections is too burdensome and, in practice, ends up tightly coupled to a SQL-like backend.
Simplify routing logic unless you want to route based on URL, which e.g. AWS ALBs or nginx or haproxy can do, but they don't understand GraphQL. What's the alternative?
I'm not sure I understand your use case. Can you give me an example of the problem you're dealing with?