Interface
- Description
-
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.
- Absinthe Macro
-
interface
Examples
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â, â |
Get Craft GraphQL APIs in Elixir with Absinthe now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.