title: How can I write nested GraphQL mutations in graphene?
body: <p>I am trying to write nested mutations in graphene, but run into trouble passing the output of one mutation to another. I would like the <code>WriteImage</code> resolver to able to accept its input image from the <code>ReadImage</code> resolver. Ultimately, <code>WriteImage</code> should able to accept an image from other resolvers as well, so that the user can script a pipeline.</p>
  
  <p>The schema looks like this:</p>
  
  <pre><code>import SimpleITK as sitk
  import graphene
  from graphql.execution.executors.asyncio import AsyncioExecutor
  
  class Image(graphene.Scalar):
      '''SimpleITK Image Type'''
  
      @staticmethod
      def serialize(Image):
          return Image
  
      @staticmethod
      def parse_literal(node):
          if isinstance(node, sitk.Image):
              return node
  
      @staticmethod
      def parse_value(value):
          return value
  
  class ReadImage(graphene.Mutation):
      class Input:
          path = graphene.String()
  
      image = Image()
  
      @staticmethod
      async def mutate(cls, args, context, info):
          image = sitk.ReadImage(args.get('path'))
          return ReadImage(image=image)
  
  
  class WriteImage(graphene.Mutation):
      class Input:
          image = Image()
          path = graphene.String()
  
      image = Image()
  
      @staticmethod
      async def mutate(cls, args, context, info):
          image = args.get('image')
          sitk.WriteImage(image, args.get('path'))
          return WriteImage(image=image)
  
  
  class Mutation(graphene.ObjectType):
      readImage = ReadImage.Field()
      writeImage = WriteImage.Field()
  
  
  schema = graphene.Schema(
      query=Query,
      mutation=Mutation,
  )
  
  executed = schema.execute(
      """
          mutation {
              writeImage(
                  image: {
                      readImage(
                          path: "/path/to/image.nii"
                      ) {
                          image
                      }
                  },
                  path: "/Users/kasper/Desktop"
              ) {
                  image
              }
          }
      """, executor=AsyncioExecutor())
  
  print(executed.data)
  print(executed.errors)
  </code></pre>
  
  <p>This outputs </p>
  
  <pre><code>&gt;&gt;&gt; None
  &gt;&gt;&gt; [GraphQLError('Argument "image" has invalid value ReadImageInput.\nExpected "ReadImageInput", found not an object.',)]
  </code></pre>
  
  <p>What does this error message mean? Why is it <code>not an object</code>? How should the schema be structured so that I may use output from one resolver as input to another?</p>
  
  <p>Additional info: Executing the <code>ReadImage</code> produces the following output and allows you to see the image type:</p>
  
  <pre><code>executed = schema.execute(
      """
          mutation {
              readImage(
                  path: "/path/to/image.nii"
              ) {
                  image
              }
          }
      """, executor=AsyncioExecutor())
  
  print(executed.data)
  print(executed.errors)
  
  &gt;&gt;&gt; OrderedDict([('readImage', OrderedDict([('image', &lt;SimpleITK.SimpleITK.Image; proxy of &lt;Swig Object of type 'std::vector&lt; itk::simple::Image &gt;::value_type *' at 0x1087b5030&gt; &gt;)]))])
  &gt;&gt;&gt; None
  </code></pre>