Skip to content

Commit 6aa857a

Browse files
committed
Add IT (currently failing) wait for #206 to be merged
1 parent eabc147 commit 6aa857a

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
:toc:
2+
3+
= Github Issue #190: cypher directive with passThrough
4+
5+
== Schema
6+
7+
[source,graphql,schema=true]
8+
----
9+
type Query {
10+
## queriesRootQuery
11+
getUser(userId: ID): UserData
12+
@cypher(statement: "MATCH (u:User{id: $userId})-[:CREATED_MAP]->(m:Map) WITH collect({id: m.id, name: m.name}) AS mapsCreated, u RETURN {name: u.name, mapsCreated: mapsCreated}", passThrough:true)
13+
}
14+
15+
type UserData {
16+
name: String
17+
mapsCreated: [MapsCreated]
18+
}
19+
20+
type MapsCreated {
21+
id: String
22+
name: String
23+
}
24+
----
25+
26+
[source,cypher,test-data=true]
27+
----
28+
CREATE
29+
(u1:User{ id: 'u1', name: 'user 1' }),
30+
(u2:User{ id: 'u2', name: 'user 2' }),
31+
(m1:Map{ id: 'm1', name: 'v1' }),
32+
(m2:Map{ id: 'm2', name: 'v2' }),
33+
(m3:Map{ id: 'm3', name: 'v3' }),
34+
(u1)-[:CREATED_MAP]->(m1),
35+
(u1)-[:CREATED_MAP]->(m2),
36+
(u2)-[:CREATED_MAP]->(m3);
37+
----
38+
39+
== Tests
40+
41+
=== Query projected data
42+
43+
.GraphQL-Query
44+
[source,graphql]
45+
----
46+
query getUser {
47+
user: getUser(userId: "u1") {
48+
name
49+
mapsCreated { id }
50+
}
51+
}
52+
----
53+
54+
.Cypher Params
55+
[source,json]
56+
----
57+
{
58+
"userUserId" : "u1"
59+
}
60+
----
61+
62+
.GraphQL-Response
63+
[source,json,response=true]
64+
----
65+
{
66+
"user" : {
67+
"mapsCreated" : [ {
68+
"id" : "m2"
69+
}, {
70+
"id" : "m1"
71+
} ],
72+
"name" : "user 1"
73+
}
74+
}
75+
----
76+
77+
.Cypher
78+
[source,cypher]
79+
----
80+
UNWIND apoc.cypher.runFirstColumnSingle('WITH $userId AS userId MATCH (u:User{id: $userId})-[:CREATED_MAP]->(m:Map) WITH collect({id: m.id, name: m.name}) AS mapsCreated, u RETURN {name: u.name, mapsCreated: mapsCreated}', {
81+
userId: $userUserId
82+
}) AS user
83+
RETURN user AS user
84+
----

0 commit comments

Comments
 (0)