[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

原文地址:https://www.cnblogs.com/Answer1215/p/8803843.html