Union

Description

Represents an object that could be one of a list of GraphQL object types, but provides for no guaranteed fields between those types. They also differ from interfaces in that object types declare what interfaces they implement, but are not aware of what unions contain them.

Absinthe Macro

union

Examples

In an Absinthe schema, defining the union and mapping results to the associated GraphQL type:

 @desc ​"​​A search result"
 union ​:search_result​ ​do
  types [​:person​, ​:business​]
  resolve_type ​fn
  %Person{}, _ ->
 :person
  %Business{}, _ ->
 :business
  _, _ ->
  nil
 end
 end
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.7.240