Integrating nested mongodb objects into an graphql schema


#1

I faced some problems during rewriting my methods to the apollo-graphql stack. For example, imagine that I had that kind of schema in mongo:

{
  _id: ...
  image: {
    width: ...
    height: ...
  }
  thumb: {
    width: ...
    height: ...  
  }
}

How do I need to perform a mutation to insert it? It seems that graphql should be a flat object?
Is there any way to send variables something like this?

gql`mutation insertImage(
          $image.width: Int!
          $image.height: Int!
          $thumb.width: Int!
          $thumb.height: Int!
        ) 

And overall, how to define all this in schema? Or it better to rewrite this mongo table to a plain structure?


#2

And one more question. Is there anyway to execute a mutation with 16 vars somehow without all these boilerplates? Because right now, for me it seems as:

client.mutate({
  mutation: gql`mutation insert(
    $id: String!
    ...another 15 vars
  ) {
    insertImage(
      id: $id
      ...another 15 vars
    ) {
      _id
    }
  }`,
  variables: {
    id: ...
    ...another 15 vars
  }
})

and it makes my mutation a really long and unmaintainable.