InterfacesΒΆ

GraphQL supports the notion of interfaces, collections of fields and their arguments.

To keep things simple, interfaces can not extend other interfaces. Likewise, objects can implement multiple interfaces, but can not extend other objects.

Interfaces are valid types, they can be specified as the return type of a query, mutation, or as the type of a field.

{:interfaces
 {:named
  {:fields {:name {:type String}}}}

 :objects
 {:person
  {:implements [:named]
   :fields {:name {:type String}
            :age {:type Int}}}

  :business
  {:implements [:named]
   :fields {:name {:type String}
            :employee_count {:type Int}}}}}

An interface definition may include a :description key; the value is a string exposed through Introspection.

The description on an interface field, or on an argument of an interface field, will be inherited by the object field (or argument) unless overriden. This helps to elimiate duplication of documentation between an interface and the object implementing the interface.

The object definition must include all the fields of all extended interfaces.

Tip

When a field or operation type is an interface, the field resolver may return any of a number of different concrete object types, and Lacinia has no way to determine which; this information must be explicitly provided.