title: Document all potential errors on GraphQL server?
body: <p>For a mutation <code>addVoucher</code> there are a limited list of potential errors that can occur.</p>
  
  <ul>
  <li>Voucher code invalid</li>
  <li>Voucher has expired</li>
  <li>Voucher has already been redeemed</li>
  </ul>
  
  <p>At the moment I'm throwing a custom error when one of these occurs.</p>
  
  <pre><code>// On the server:
  const addVoucherResolver = () =&gt; {
      if(checkIfInvalid) {
          throw new Error('Voucher code invalid')
      }
      return {
          // data
      }
  }
  </code></pre>
  
  <p>Then on the client I search the message description so I can alert the user. However this feels brittle and also the GraphQL API doesn't automatically document the potential errors. Is there a way to define the potential errors in the GraphQL schema? </p>
  
  <p>Currently my schema looks like this: </p>
  
  <pre><code>type Mutation {
      addVoucherResolver(id: ID!): Order
  }
  
  type Order {
      cost: Int!
  }
  </code></pre>
  
  <p>It would be nice to be able to do something like this:</p>
  
  <pre><code>type Mutation {
      addVoucherResolver(id: ID!): Order || VoucherError
  }
  
  type Order {
      cost: Int!
  }
  
  enum ErrorType {
      INVALID
      EXPIRED
      REDEEMED
  }
  
  type VoucherError {
      status: ErrorType!
  }
  </code></pre>
  
  <p>Then anyone consuming the API would know all the potential errors. This feels like a standard requirement to me but from reading up there doesn't seem to be a standardises GraphQL approach. </p>