title: GraphQL how to avoid duplicate code between input and output types
body: <p>I'am new to GraphQL but I really like it. Now that I'am playing with interfaces and unions, I'am facing a problem with mutations.</p>
  
  <p>Suppose that I have this schema :</p>
  
  <pre><code>interface FoodType {
      id: String
      type: String
      composition: [Ingredient]
    }
  
    type Pizza implements FoodType {
      id: String
      type: String
      pizzaType: String
      toppings: [String]
      size: String
      composition: [Ingredient]
    }
  
    type Salad implements FoodType {
      id: String
      type: String
      vegetarian: Boolean
      dressing: Boolean
      composition: [Ingredient]
    }
  
    type BasicFood implements FoodType {
      id: String
      type: String
      composition: [Ingredient]
    }
  
    type Ingredient {
        name: String
        qty: Float
        units: String
    }
  </code></pre>
  
  <p>Now, I'd like to create new food items, so I started doing something like this :</p>
  
  <pre><code>type Mutation {
      addPizza(input:Pizza):FoodType
      addSalad(input:Salad):FoodType
      addBasic(input:BasicFood):FoodType
  }
  </code></pre>
  
  <p>This did not work for 2 reasons :</p>
  
  <ol>
  <li>If I want to pass an object as parameter, this one must be an "input" type. But "Pizza", "Salad" and "BasicFood" are just "type".</li>
  <li>An input type cannot implement an interface.</li>
  </ol>
  
  <p>So, I need to modify my previous schema like this :</p>
  
  <pre><code>interface FoodType {
      id: String
      type: String
      composition: [Ingredient]
  }
  
  type Pizza implements FoodType {
      id: String
      type: String
      pizzaType: String
      toppings: [String]
      size: String
      composition: [Ingredient]
  }
  
  type Salad implements FoodType {
      id: String
      type: String
      vegetarian: Boolean
      dressing: Boolean
      composition: [Ingredient]
  }
  
  type BasicFood implements FoodType {
      id: String
      type: String
      composition: [Ingredient]
  }
  
  type Ingredient {
          name: String
          qty: Float
          units: String
  }
  
  type Mutation {
      addPizza(input: PizzaInput): FoodType
      addSalad(input: SaladInput): FoodType
      addBasic(input: BasicInput): FoodType    
  }
  
  input PizzaInput {
      type: String
      pizzaType: String
      toppings: [String]
      size: String
      composition: [IngredientInput]
  }
  
  input SaladInput {
      type: String
      vegetarian: Boolean
      dressing: Boolean
      composition: [IngredientInput]
  }
  
  input BasicFoodInput {
      type: String
      composition: [IngredientInput]
  }
  
  input IngredientInput {
          name: String
          qty: Float
          units: String
  }
  </code></pre>
  
  <p>So, here I defined my 3 creation methods for Pizza, Salad and Basic food.
  I need to define 3 input types (one for each food)
  And I also need to define a new input type for Ingredients.</p>
  
  <p>It makes lot of duplication. Are you ok with that? Or there is a better way to deal with this?</p>
  
  <p>Thank you</p>