Search⌘ K
AI Features

Abstract Type Interfaces

Explore how to implement GraphQL interfaces in Absinthe to create flexible and organized schemas. Understand enforcing common fields among types for clearer queries and improved API design.

We'll cover the following...

Using interfaces

GraphQL interfaces are similar to unions, with the key difference that any member type must define a set of included fields. This may remind you of interfaces in other languages.

For search results, we know that we want to access the name field easily. It’s fair to say that a search result should always include a name. It’s a simple constraint and doesn’t require us to add any fields to our :menu_item and :category types. We need to convert our :search_result to an interface and indicate that our types ...