title: How to use the names in a GraphQLEnumType as the defaultValue of a GraphQL query argument?
body: <p>When defining a query in a schema, how do I refer to a value of an GraphQLEnumType declared previously, to use it as the default value of an argument?</p>
  
  <p>Let's say I've defined following <code>ObservationPeriod</code> GraphQLEnumType:</p>
  
  <pre><code>observationPeriodEnum = new GraphQLEnumType {
    name: "ObservationPeriod"
    description: "One of the performance metrics observation periods"
    values:
      Daily:
        value: '1D'
        description: "Daily"
      […]
  }
  </code></pre>
  
  <p>and use it as the type of query argument <code>period</code>:</p>
  
  <pre><code>queryRootType = new GraphQLObjectType {
    name: "QueryRoot"
    description: "Query entry points to the DWH."
    fields:
      performance:
        type: performanceType
        description: "Given a portfolio EID, an observation period (defaults to YTD)
                      and as-of date, as well as the source performance engine,
                      return the matching performance metrics."
        args:
          period:
            type: observationPeriodEnum 
            defaultValue: observationPeriodEnum.Daily ← how to achieve this?
        […]
  }
  </code></pre>
  
  <p>Currently I'm using the actual <code>'1D'</code> string value as the default value; this works:</p>
  
  <pre><code>        period:
            type: observationPeriodEnum 
            defaultValue: '1D'
  </code></pre>
  
  <p>But is there a way I could use the <code>Daily</code> symbolic name instead? I couldn't find a way to use the names within the schema itself. Is there something I overlooked?</p>
  
  <p>I'm asking, because I was expecting an enum type to behave as a set of constants also, and to be able to use them like this in the schema definition:</p>
  
  <pre><code>        period:
            type: observationPeriodEnum 
            defaultValue: observationPeriodEnum.Daily
  </code></pre>
  
  <hr>
  
  <p>Naïve workaround:</p>
  
  <pre><code>##
  # Given a GraphQLEnumType instance, this macro function injects the names 
  # of its enum values as keys the instance itself and returns the modified
  # GraphQLEnumType instance.
  #
  modifiedWithNameKeys = (enumType) -&gt;
    for ev in enumType.getValues()
      unless enumType[ ev.name]?
        enumType[ ev.name] = ev.value
      else
        console.warn "SCHEMA&gt; Enum name #{ev.name} conflicts with key of same
          name on GraphQLEnumType object; it won't be injected for value lookup"
    enumType
  
  observationPeriodEnum = modifiedWithNameKeys new GraphQLEnumType {
    name: "description: "Daily""
    values:
      […]
  </code></pre>
  
  <p>which allows to use it as desired in schema definition:</p>
  
  <pre><code>        period:
            type: observationPeriodEnum 
            defaultValue: observationPeriodEnum.Daily
  </code></pre>
  
  <p>Of course, this modifier fullfils its promise, only as long as the enum names do not interfere with GraphQLEnumType existing method and variable names (which are currently: <code>name</code>, <code>description</code>, <code>_values</code>, <code>_enumConfig</code>, <code>_valueLookup</code>, <code>_nameLookup</code>, <code>getValues</code>, <code>serialize</code>, <code>parseValue</code>, <code>_getValueLookup</code>, <code>_getNameLookup</code> and <code>toString</code> — see definition of <code>GraphQLEnumType</code> class around line 687 in <a href="https://github.com/graphql/graphql-js/blob/master/src/type/definition.js#L687" rel="noreferrer">https://github.com/graphql/graphql-js/blob/master/src/type/definition.js#L687</a>)</p>