@@ -111,7 +111,7 @@ class MultiItemConnectionQuerySpec extends FlatSpec with Matchers with ApiSpecBa
111111 .toString should equal(""" {"data":{"todoesConnection":{"edges":[{"node":{"title":"Hello World!"}}]}}}""" )
112112 }
113113
114- " the connection query" should " work when using cursors when not on Mongo " taggedAs (IgnoreSQLite ) in {
114+ " the connection query" should " work when using cursors" taggedAs (IgnoreSQLite ) in {
115115 val datamodels = {
116116 val dm1 =
117117 """ type User {
@@ -122,14 +122,22 @@ class MultiItemConnectionQuerySpec extends FlatSpec with Matchers with ApiSpecBa
122122 }"""
123123
124124 val dm2 =
125+ """ type User {
126+ id: ID! @id
127+ name: String
128+ following: [User!]! @relation(name: "UserToFollow")
129+ followers: [User!]! @relation(name: "UserToFollow", link: INLINE)
130+ }"""
131+
132+ val dm3 =
125133 """ type User {
126134 | id: ID! @id
127135 | name: String
128136 | following: [User!]! @relation(name: "UserToFollow", link: TABLE)
129137 | followers: [User!]! @relation(name: "UserToFollow")
130138 |}"""
131139
132- TestDataModels (mongo = Vector (dm1), sql = Vector (dm2 ))
140+ TestDataModels (mongo = Vector (dm1, dm2 ), sql = Vector (dm3 ))
133141 }
134142 datamodels.testV11 { project =>
135143 val a = server.query(s """ mutation{createUser(data:{name: "a", followers:{create:[{name:"b"}, {name:"c"}, {name:"x"}]}}){id}} """ , project)
@@ -162,4 +170,81 @@ class MultiItemConnectionQuerySpec extends FlatSpec with Matchers with ApiSpecBa
162170 }
163171 }
164172
173+ " the connection query" should " work when not using cursors" taggedAs (IgnoreSQLite ) in {
174+ val datamodels = {
175+ val dm1 =
176+ """ type User {
177+ | id: ID! @id
178+ | name: String
179+ | company: Company @relation(link: INLINE)
180+ |}
181+ |
182+ |type Company {
183+ | id: ID! @id
184+ | name: String,
185+ | members: [User!]!
186+ |}"""
187+
188+ val dm2 =
189+ """ type User {
190+ | id: ID! @id
191+ | name: String
192+ | company: Company
193+ |}
194+ |
195+ |type Company {
196+ | id: ID! @id
197+ | name: String,
198+ | members: [User!]! @relation(link: INLINE)
199+ |}"""
200+
201+ val dm3 =
202+ """ type User {
203+ | id: ID! @id
204+ | name: String
205+ | company: Company @relation(link: TABLE)
206+ |}
207+ |
208+ |type Company {
209+ | id: ID! @id
210+ | name: String,
211+ | members: [User!]!
212+ |}"""
213+
214+ TestDataModels (mongo = Vector (dm1, dm2), sql = Vector (dm3))
215+ }
216+
217+ datamodels.testV11 { project =>
218+ val a = server.query(s """ mutation{createUser(data:{name: "a", company:{create:{name:"b"}}}){id, company{id}}} """ , project)
219+ val d = server.query(s """ mutation{createUser(data:{name: "d", company:{create:{name:"e"}}}){id, company{id}}} """ , project)
220+ val g = server.query(s """ mutation{createUser(data:{name: "g", company:{create:{name:"h"}}}){id, company{id}}} """ , project)
221+ val k = server.query(s """ mutation{createUser(data:{name: "k", company:{create:{name:"l"}}}){id, company{id}}} """ , project)
222+
223+ val result = server.query(
224+ s """ {
225+ | usersConnection(where: {
226+ | company: {
227+ | id: " ${a.pathAsString(" data.createUser.company.id" )}"
228+ | }
229+ | }) {
230+ | edges {
231+ | node {
232+ | name
233+ | company {
234+ | name
235+ | }
236+ | }
237+ | }
238+ | aggregate {
239+ | count
240+ | }
241+ | }
242+ |} """ .stripMargin,
243+ project
244+ )
245+
246+ result.toString should be(""" {"data":{"usersConnection":{"edges":[{"node":{"name":"a","company":{"name":"b"}}}],"aggregate":{"count":1}}}}""" )
247+ }
248+ }
249+
165250}
0 commit comments