In this video, Emmanuel Henri explores when it makes sense to migrate to GraphQL, such as use of multiple DBs, simple query syntax, and to get only what you need from queries.
- [Instructor] GraphQL has a lot going for it. But I'll focus on the main advantages of moving your REST API to GraphQL. First of all, you get types which guarantees that the data you get will be of the type expected and prevents many of the common errors with REST. So if that's been an annoyance for you, you're a good candidate. Also, when you have multiple databases or even different databases serving the same application, GraphQL is a much better approach to this disjointed architecture. As it serves a single point to do all your queries versus multiple separate entities.
The other advantage of going to GraphQL is the flexibility of the queries. You can query for a very specific type of data, say only one property of the query like only the first name and not all the properties an object may return when you query a list of contacts for example. So just these small points may already prove to you GraphQL is a much better approach than a simple REST API. However, GraphQL isn't the best solution in all cases. If you're building a small application or API, REST could be a much better approach.
Consider the cost of developing the GraphQL tool versus the value it may provide. If you're going to scale an application beyond the simple queries or already have a big implementation, then yes, GraphQL may make sense. My advice to you is start small with REST and as you'll see in this course, implementing GraphQL isn't that big of a deal. And when you're ready, go for it.
- Setting up GraphQL
- Creating the initial schema and type
- Setting up simple queries
- Leveraging arguments and aliases
- Reading, updating, adding, and deleting items with GraphQL
- Posting data with mutations