突变对 GraphQL、Prisma、Yoga 不起作用

Mutation doesn't work GraphQL, Prisma, Yoga

本例如何添加用户?我尝试以各种方式使用突变,但没有用。

type User {
  masterId: Int
  name: String
  surname: String
  address: Address 
}

type Address {
  street: String
  flat: Int
  city: String
  country: String
}

我尝试这样的事情:

type Mutation {
  user(
    masterId: Int
    name: String
    surname: String
    address: Address
  ): User
}

接下来

mutation {
  user(
    masterId: 4,
      name: "Kevin",
      surname: "Key",
        address: {
        street: "Clark Street",
        flat: 19,
        city: "Brentwood",
        country: "United Kingdom"
      }
  ) 
}

我尝试了不同的版本,但我实在找不到解决办法

在 prisma 中创建数据模型后在操场上试试这个

mutation {
  createUser(
    data: {
      name: "Kevin",
      surname: "Key"
      address: {
        create: {
          street: "Clark Street",
          flat: 19,
          city: "Brentwood",
          country: "United Kingdom"
        }
      }
    }
  ) {
    id
    name
  }
}

备注 如果已经创建了地址对象,您也可以使用连接,对于连接,只需传递地址 id(Primary Key/ObjectId)