GQLEnum
GQLEnum
new GQLEnum()
GraphQL Enum types can be a bit picky when it comes to how scalar types
equate to enum values. Lattice makes this easier by allowing you to specify
a value or the key when your enum has a value other than the key; GraphQL
does not allow this by default.
Further more, when instantiating a GQLEnum type, you can pass a string or
value matching the enum key or value or you can pass an object with key of
value and the value being either the enum key or value. If any of those
things match, then your instance.value
will equate to the enum's key. If,
on the other hand, your supplied values do not match then instance.value
will be null
.
- Source:
- GQLEnum.js, line 80
Methods
(static) valueFor(value, deprecationReason, description) → {Object}
Shorthand method to generate a GraphQLEnumValueDefinition implementation
object. Use this for building and customizing your values
key/value
object in your child classes.
Parameters:
Name | Type | Description |
---|---|---|
value |
mixed | any nonstandard value you wish your enum to have |
deprecationReason |
String | an optional reason to deprecate an enum |
description |
String | a non Lattice standard way to write a comment |
Returns:
(
Object
)
an object that conforms to the GraphQLEnumValueDefinition
defined here http://graphql.org/graphql-js/type/#graphqlenumtype
- Source:
- GQLEnum.js, line 191
GenerateEnumsProxyHandler(map) → {Object}
Due to the complexity of being able to access both the keys and values
properly for an enum type, a Map is used as the backing store. The handler
returned by this method is to be passed to a Proxy.
Parameters:
Name | Type | Description |
---|---|---|
map |
Map | the map containing the key<->value and |
Returns:
(
Object
)
- Source:
- GQLEnum.js, line 237
(inner) get()
- Source:
- GQLEnum.js, line 251
~set(obj, key, value)
Set handler for the Map backed Array Proxy.
Parameters:
Name | Type | Description |
---|---|---|
obj |
mixed | the object the Proxy is targeting |
key |
string | a string |
value |
mixed | the |
- Source:
- GQLEnum.js, line 261