Expand JSON spec a bit to use update as well.
@@ -4,30 +4,50 @@ import org.scalatest.{FlatSpec, Matchers}
import util._
class JsonSpec extends FlatSpec with Matchers with ApiSpecBase {
- "Using a json field" should "work" ignore {
+ "Using a json field" should "work" in {
val project = ProjectDsl.fromString {
"""|model Model {
- | id String @id @default(cuid())
+ | id String @id
| field Json
|}"""
}
database.setup(project)
- val res = server.query(
+ var res = server.query(
s"""
|mutation {
- | createModel(
+ | createOneModel(
| data: {
+ | id: "A"
| field: "{\\"a\\": \\"b\\" }"
| }
| ) {
| field
| }
|}""".stripMargin,
- project
+ project,
+ legacy = false
)
- res.toString should be("""{"data":{"createModel":{"field":"{\"a\":\"b\"}"}}}""")
+ res.toString should be("""{"data":{"createOneModel":{"field":"{\"a\":\"b\"}"}}}""")
+
+ res = server.query(
+ s"""
+ |mutation {
+ | updateOneModel(
+ | where: { id: "A" }
+ | data: {
+ | id: { set: "1" }
+ | }
+ | ) {
+ | field
+ | }
+ |}""".stripMargin,
+ project,
+ legacy = false
+ )
+
+ res.toString should be("""{"data":{"updateOneModel":{"field":"{\"a\":\"b\"}"}}}""")
}
}
