Understanding Abstract Types

Up to this point, we’ve focused on building concrete types that closely model the underlying data, matching up with the Ecto schemas we’ve built for our PlateSlate application.

To support an easy-to-use, flexible API for your users, you’ll need to go beyond this type of modeling and learn how to use abstract types as well.

Let’s look at a quick example. A standard feature for a user interface (and the APIs that support them) is a search function. If we were going to implement a search function for our PlateSlate application, allowing users to retrieve both menu items and menu item categories (a grouping of menu items) that match a search term, how would we do it?

With only our concrete types in place, we’re stuck ...

Get Craft GraphQL APIs in Elixir with Absinthe now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.