API / GraphQL Interview Questions
Disadvantages of GraphQL.
Error Handling Complexity: The GraphQL queries always return a HTTP status code of 200, regardless of whether or not that query was successful. If your query is unsuccessful, your response JSON will have a top-level "errors" key with associated error messages and stacktrace. This can make it much more difficult to do error handling. This limitation also makes redirects(301) difficult to implemented compare to traditional REST redirects.
Lack of built-in caching support: It is complicated to implement a cache with GraphQL than implementing it in REST. In REST API, we access resources with URLs, so we can cache on a resource level because we have the resource URL as an identifier. However, In GraphQL, its complex because each query can be different, even though it operates on the same entity. But most of the libraries built on top of GraphQL offer an efficient caching mechanism.
Complexity: If you have a simple REST API and deal with data that is relatively consistent over time, you would better stick with your REST API.
Rate Limiting Complexity: In REST API, you can simply specify that we allow only this amount of requests in one day, but in GraphQL, it is difficult to specify because it doesn't have different endpoints/varied JSON request structure.
More Related questions...