Using GraphQL
There are more options to give clients flexibility when fetching data from your endpoints beyond sideloading. A very popular one is GraphQL.
GraphQL is a query language and runtime that was developed by Facebook in 2012. The idea behind its creation was to allow clients to request and retrieve the exact data they need. With GraphQL, clients have to specify exactly what fields they want for each object they retrieve.
The Ruby ecosystem has a popular and well-maintained GraphQL implementation that we’ll use for our example. You can find it on GitHub.[48] It has great documentation[49] that I strongly suggest you read. To install it, do the following:
-
Add gem "graphql" to your Gemfile.
-
Run bundle install from your terminal.
-
Execute ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access