具有输入类型的 GraphQL Apollo 突变

GraphQL Apollo Mutation with Input Type

我想将任务类型添加到我的里程碑,但我无法弄清楚查询的语法:

这是我的架构:

type Milestone {
  _id: String!
  title: String!
  task: [Task]
}

type Task {
  _id: String
  name: String
}

input TaskInput {
  _id: ID!
  name: String!
}

type Mutation {
  createMilestone(title: String!, task: TaskInput!): Milestone
}

在没有任务的情况下创建里程碑确实适用于以下查询:

mutation {
  createMilestone(title: "TestMilestone") {
    _id
    title
  }
}

要添加 Task 输入,将突变写为

mutation {
        createMilestone(
            title: "TestMilestone",
            task: {
                _id: "YouId",
                name: "Lorem"
            }) {
          _id
          title
          task {
               _id
               name
           }
        }
      }