Are there any disadvantages to GraphQL?

Dr.Nemo picture Dr.Nemo · Nov 19, 2016 · Viewed 22.6k times · Source

All the articles about GraphQL will tell you how wonderful it is, but are there any disadvantages or shortcomings to it? Thank you.

Answer

w00t picture w00t · Nov 19, 2016

Disadvantages:

  • You need to learn how to set up GraphQL. The ecosystem is still rapidly evolving so you have to keep up.
  • You need to send the queries from the client, you can just send strings but if you want more comfort and caching you'll use a client library -> extra code in your client
  • You need to define the schema beforehand => extra work before you get results
  • You need to have a graphql endpoint on your server => new libraries that you don't know yet
  • Graphql queries are more bytes than simply going to a REST endpoint
  • The server needs to do more processing to parse the query and verify the parameters

But, those are more than countered by these:

  • GraphQL is not that hard to learn
  • The extra code is only a few KB
  • By defining a schema, you will prevent much more work afterwards fixing bugs and enduring hairy upgrades
  • There are a lot of people switching to GraphQL so there is a rich ecosystem developing, with excellent tooling
  • When using persistent queries in production (replacing GraphQL queries with simply an ID and parameters), you actually send less bytes than with REST
  • The extra processing for incoming queries is negligible
  • Providing a clean decoupling of API and backend allows for much faster iteration on backend improvenments