|
1 | 1 | package com.prisma.api.queries |
2 | 2 |
|
3 | | -import com.prisma.{IgnoreMongo, IgnoreMySql, IgnorePostgres, IgnoreSQLite} |
4 | | -import com.prisma.api.ApiSpecBase |
| 3 | +import com.prisma.api.{ApiSpecBase, TestDataModels} |
5 | 4 | import com.prisma.shared.schema_dsl.SchemaDsl |
6 | 5 | import org.scalatest.{FlatSpec, Matchers} |
7 | 6 |
|
@@ -111,88 +110,55 @@ class MultiItemConnectionQuerySpec extends FlatSpec with Matchers with ApiSpecBa |
111 | 110 | .toString should equal("""{"data":{"todoesConnection":{"edges":[{"node":{"title":"Hello World!"}}]}}}""") |
112 | 111 | } |
113 | 112 |
|
114 | | - "the connection query" should "work when using cursors on Mongo" taggedAs (IgnoreMySql, IgnorePostgres, IgnoreSQLite) in { |
115 | | - |
116 | | - val project2 = SchemaDsl.fromStringV11() { |
117 | | - """type User { |
118 | | - | id: ID! @id |
119 | | - | name: String |
120 | | - | following: [User!]! @relation(name: "UserToFollow", link: INLINE) |
121 | | - | followers: [User!]! @relation(name: "UserToFollow") |
122 | | - |}""".stripMargin |
| 113 | + "the connection query" should "work when using cursors when not on Mongo" in { |
| 114 | + val datamodels = { |
| 115 | + val dm1 = |
| 116 | + """type User { |
| 117 | + id: ID! @id |
| 118 | + name: String |
| 119 | + following: [User!]! @relation(name: "UserToFollow", link: INLINE) |
| 120 | + followers: [User!]! @relation(name: "UserToFollow") |
| 121 | + }""" |
| 122 | + |
| 123 | + val dm2 = |
| 124 | + """type User { |
| 125 | + | id: ID! @id |
| 126 | + | name: String |
| 127 | + | following: [User!]! @relation(name: "UserToFollow", link: TABLE) |
| 128 | + | followers: [User!]! @relation(name: "UserToFollow") |
| 129 | + |}""" |
| 130 | + |
| 131 | + TestDataModels(mongo = Vector(dm1), sql = Vector(dm2)) |
123 | 132 | } |
| 133 | + datamodels.testV11 { project => |
| 134 | + val a = server.query(s"""mutation{createUser(data:{name: "a", followers:{create:[{name:"b"}, {name:"c"}, {name:"x"}]}}){id}}""", project) |
| 135 | + val d = server.query(s"""mutation{createUser(data:{name: "d", followers:{create:[{name:"e"}, {name:"f"}, {name:"x"}]}}){id}}""", project) |
| 136 | + val g = server.query(s"""mutation{createUser(data:{name: "g", followers:{create:[{name:"h"}, {name:"i"}, {name:"x"}]}}){id}}""", project) |
| 137 | + val k = server.query(s"""mutation{createUser(data:{name: "k", followers:{create:[{name:"l"}, {name:"m"}, {name:"x"}]}}){id}}""", project) |
124 | 138 |
|
125 | | - database.setup(project2) |
126 | | - |
127 | | - val a = server.query(s"""mutation{createUser(data:{name: "a", followers:{create:[{name:"b"}, {name:"c"}, {name:"x"}]}}){id}}""", project2) |
128 | | - val d = server.query(s"""mutation{createUser(data:{name: "d", followers:{create:[{name:"e"}, {name:"f"}, {name:"x"}]}}){id}}""", project2) |
129 | | - val g = server.query(s"""mutation{createUser(data:{name: "g", followers:{create:[{name:"h"}, {name:"i"}, {name:"x"}]}}){id}}""", project2) |
130 | | - val k = server.query(s"""mutation{createUser(data:{name: "k", followers:{create:[{name:"l"}, {name:"m"}, {name:"x"}]}}){id}}""", project2) |
131 | | - |
132 | | - val result = server.query( |
133 | | - s"""{ |
134 | | - | usersConnection(where: { |
135 | | - | followers_some: { |
136 | | - | name: "x" |
137 | | - | }, |
138 | | - | }, first: 2, after: "${a.pathAsString("data.createUser.id")}") { |
139 | | - | aggregate { |
140 | | - | count |
141 | | - | } |
142 | | - | edges { |
143 | | - | node { |
144 | | - | name |
145 | | - | } |
146 | | - | } |
147 | | - | } |
148 | | - |}""".stripMargin, |
149 | | - project2 |
150 | | - ) |
151 | | - |
152 | | - result.toString should be("""{"data":{"usersConnection":{"aggregate":{"count":2},"edges":[{"node":{"name":"d"}},{"node":{"name":"g"}}]}}}""") |
153 | | - |
154 | | - } |
| 139 | + val result = server.query( |
| 140 | + s"""{ |
| 141 | + | usersConnection(where: { |
| 142 | + | followers_some: { |
| 143 | + | name: "x" |
| 144 | + | }, |
| 145 | + | }, first: 2, after: "${a.pathAsString("data.createUser.id")}") { |
| 146 | + | aggregate { |
| 147 | + | count |
| 148 | + | } |
| 149 | + | edges { |
| 150 | + | node { |
| 151 | + | name |
| 152 | + | } |
| 153 | + | } |
| 154 | + | } |
| 155 | + |}""".stripMargin, |
| 156 | + project |
| 157 | + ) |
155 | 158 |
|
156 | | - "the connection query" should "work when using cursors when not on Mongo" taggedAs (IgnoreMongo) in { |
| 159 | + result.toString should be("""{"data":{"usersConnection":{"aggregate":{"count":2},"edges":[{"node":{"name":"d"}},{"node":{"name":"g"}}]}}}""") |
157 | 160 |
|
158 | | - val project2 = SchemaDsl.fromStringV11() { |
159 | | - """type User { |
160 | | - | id: ID! @id |
161 | | - | name: String |
162 | | - | following: [User!]! @relation(name: "UserToFollow", link: TABLE) |
163 | | - | followers: [User!]! @relation(name: "UserToFollow") |
164 | | - |}""".stripMargin |
165 | 161 | } |
166 | | - |
167 | | - database.setup(project2) |
168 | | - |
169 | | - val a = server.query(s"""mutation{createUser(data:{name: "a", followers:{create:[{name:"b"}, {name:"c"}, {name:"x"}]}}){id}}""", project2) |
170 | | - val d = server.query(s"""mutation{createUser(data:{name: "d", followers:{create:[{name:"e"}, {name:"f"}, {name:"x"}]}}){id}}""", project2) |
171 | | - val g = server.query(s"""mutation{createUser(data:{name: "g", followers:{create:[{name:"h"}, {name:"i"}, {name:"x"}]}}){id}}""", project2) |
172 | | - val k = server.query(s"""mutation{createUser(data:{name: "k", followers:{create:[{name:"l"}, {name:"m"}, {name:"x"}]}}){id}}""", project2) |
173 | | - |
174 | | - val result = server.query( |
175 | | - s"""{ |
176 | | - | usersConnection(where: { |
177 | | - | followers_some: { |
178 | | - | name: "x" |
179 | | - | }, |
180 | | - | }, first: 2, after: "${a.pathAsString("data.createUser.id")}") { |
181 | | - | aggregate { |
182 | | - | count |
183 | | - | } |
184 | | - | edges { |
185 | | - | node { |
186 | | - | name |
187 | | - | } |
188 | | - | } |
189 | | - | } |
190 | | - |}""".stripMargin, |
191 | | - project2 |
192 | | - ) |
193 | | - |
194 | | - result.toString should be("""{"data":{"usersConnection":{"aggregate":{"count":2},"edges":[{"node":{"name":"d"}},{"node":{"name":"g"}}]}}}""") |
195 | | - |
196 | 162 | } |
197 | 163 |
|
198 | 164 | } |
0 commit comments