Transforming a REST to-do list into GraphQL
Unlike the previous examples in this book, we won’t require a complicated schema here. Our goal is to create a basic to-do list using a public API. To start, we’ll build a simple proxy that mimics the functionality provided by REST, without getting into the nitty-gritty details.
You might be wondering what the benefit of doing this is. Well, with GraphQL, we gain the advantage of precisely defined return types and parameters. These will be utilized by our GraphQL resolvers to direct requests to the appropriate REST endpoints. This is where the true power of GraphQL shines in comparison to REST.
Alright, let’s begin with the list of available to-dos. This is the simplest example of how GraphQL enhances type safety in our to-do list project. Enter https://jsonplaceholder.typicode.com/todos in your browser to test the endpoint and you should receive the following response:
[ { ...