[GraphQL] Mutations and Input Types

Sometimes, you want to resues object type when doing mutation, you can use 'input' type to help:

input MessageInput {
  content: String
  author: String
}

type Message {
  id: ID!
  content: String
  author: String
}

type Query {
  getMessage(id: ID!): Message
}

type Mutation {
  createMessage(input: MessageInput): Message
  updateMessage(id: ID!, input: MessageInput): Message
}

 

Doc

posted @ 2018-04-12 02:52  Zhentiw  阅读(179)  评论(0)    收藏  举报