How to set up a project with Ruby on Rails, PostgreSQL and GraphQL
Setting up a project with Ruby on Rails, PostgreSQL and GraphQL is actually pretty straightforward. But first, some prerequisites. For this tutorial (tested on versions 2.7.3, 220.127.116.11 and 11.0 respectively), you must have all three, Ruby on Rails, PostgreSQL and GraphQL installed on your development machine. Some general knowledge of Ruby and Rails is also recommended. Before we begin, however, you might be wondering why anyone would want to replace the perfectly fine experience provided by the traditional REST API with one offered by GraphQL. Well, one obvious reason is that GraphQL deals quite elegantly with resources over- and under-fetching. With GraphQL you are given the exact information you request - nothing more, nothing less. Moreover, it is almost self-documenting, making that one less item on your list of things to worry about. And there are other pros to GraphQL, such as it being both strongly typed and language and database independent. But in the meantime, I'll leave those for you to explore on your own. So, without further ado, let’s set up our first GraphQL API on Ruby on Rails.