Ruby is general purpose programming language optimized for programmer happiness. One of its most popular frameworks for building web applications is called Ruby on Rails.
The Ruby ecosystem was one of the first to adopt GraphQL. A couple of popular Ruby on Rails applications like Github and Shopify are using it in production already.
In this chapter you’ll learn how to build your very own GraphQL server using the following technologies:
A GraphQL server should be able to:
{ "query": "query { allLinks { url } }" }
{ "data": { "allLinks": { "url": "http://graphql.org/" } } }
{
"errors": [{
"message": "Cannot query field \"unknown\" on type \"Link\"."
}]
}
These are the basic features all GraphQL servers have, but of course, they can do much more as needed. You can read in more detail about the expected behavior of a GraphQL server in the official specification.
An important thing to note about building a GraphQL server is that the main development process will revolve around the schema definition. You’ll see in this chapter that the main steps we’ll follow will be something like this:
The schema is a contract agreed on between the frontend and backend, so keeping it at the center allows both sides of the development to evolve without going off the spec. This also makes it easier to parallelize the work, since the frontend can move on with full knowledge of the API from the start, using a simple mocking service which can later be easily replaced with the final server.