How to Model A Schema with Multiple Types

I am designing a phoenix app that has an entity and each entity can have many properties. The issue I am having with Absinthe is that each property can be a different type. My first approach was to separate out the property types into their own schema so I ended up with a property that looks like this

name
type 
bool_value_type: [true, false]
range_value_type : {
 min: 
 max: 
}

Now the dilemma is that I only want to show boo_value_type if the type == “bool” and range_value_type if the type == “range”.

Any ideas, thoughts, suggestions would be appreciated.

GraphQL supports Union Types.

More Information can be found here: http://graphql.org/learn/schema/#union-types

You can define a field that is one of several different types and then code your queries to show the correct values depending on which union element is represented.

1 Like