GraphQL is seen by some as the beginning of the end for RESTful APIs. The Facebook-backed project lets you get all the data you want in the way you want from an API while only ever calling one endpoint. But where to get started? Scott Domes over at MuseFind will take you from zero to hero in only twenty minutes.
One of the big advantages of GraphQL over REST is that it allows an API call to be made to a single endpoint and have the response include all the desired information, structured in a specific way.
When working with GraphQL, one of the first steps you need to take is to author a schema that will define the data types your API will interact with as well as the relationships between them. As Domes states, “Schemas define what data is available, and what type it is. Types determine the structure of the data (what it looks like).” This schema includes data types for people and pets.
With the types defined Domes walks the reader through how to define the query type, how to define the schema and finally how to define the routes to send the queries to. The tutorial is wrapped up by testing two queries by using Postman.