March 2018
Intermediate to advanced
304 pages
6h 59m
English
Represents a list of named fields and their arguments. GraphQL objects can then implement an interface, which guarantees that they will contain the specified fields.
interface
In an Absinthe schema, defining the interface and mapping results to the associated GraphQL type:
| | @desc "A named object" |
| | interface :named do |
| | field :name, :string |
| | # Other fields to be implemented |
| | resolve_type fn |
| | %Item{}, _ -> |
| | :item |
| | _, _ -> |
| | nil |
| | end |
| | end |
An object type implementing the interface:
| | @desc "An item" |
| | object :item do |
| » | interfaces [:named] |
| | field :name, :string |
| | # Other fields |
| | end |
Read now
Unlock full access