我有以下带有选项字段的案例类:
case class BusinessUserRow(id: String, firstName: Option[String], lastName: Option[String], email: Option[String])
我正在尝试为业务用户对象创建一个 inputType 对象
val BusinessUserInputType =
deriveInputObjectType[BusinessUserRow](
InputObjectTypeName("input"),
InputObjectTypeDescription("A Business user")
)
我想将此 BusinessInputObject 作为参数传递给 addBusinessUser 突变
val businessUserInputArg = Argument("input", BusinessUserInputType)
val Mutation = ObjectType("Mutation", fields[RepoContext, Unit](
Field("addBusinessUser", BusinessUserType,
arguments = businessUserInputArg :: Nil,
resolve = c ⇒ c.ctx.BusinessUserRepo.create(c.arg(businessUserInputArg)))))
但我收到以下编译错误:
Type dao.Tables.BusinessUserRow @@ sangria.marshalling.FromInput.InputObjectResult cannot be used as an input. Please consider defining an implicit instance of `FromInput` for it.
[error] val businessUserInputArg = Argument("input", BusinessUserInputType)
但是 BusinessRow 中的所有字段都是标量值。我不明白是什么导致了这个问题。有什么我没有看到的吗?