Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Commit b9849b1

Browse files
TotktonadaSudoBobo
authored andcommitted
Nullable 1:1 connections
Fixes #44.
1 parent d01729c commit b9849b1

8 files changed

+1642
-316
lines changed

graphql/tarantool_graphql.lua

+160-316
Large diffs are not rendered by default.
+180
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
2+
3+
+---------------------+
4+
| a-+ h x y |
5+
| |\ \ |\ |
6+
| b c d k l |
7+
| | |\ \ |
8+
| e f g m |
9+
+---------------------+
10+
RUN downside_a {{{
11+
QUERY
12+
query emails_tree_downside($body: String) {
13+
email(body: $body) {
14+
body
15+
successors {
16+
body
17+
successors {
18+
body
19+
successors {
20+
body
21+
}
22+
}
23+
}
24+
}
25+
}
26+
VARIABLES
27+
---
28+
body: a
29+
...
30+
31+
RESULT
32+
---
33+
email:
34+
- successors:
35+
- successors: &0 []
36+
body: c
37+
- successors:
38+
- successors: *0
39+
body: g
40+
- successors: *0
41+
body: f
42+
body: d
43+
- successors:
44+
- successors: *0
45+
body: e
46+
body: b
47+
body: a
48+
...
49+
50+
}}}
51+
52+
RUN downside_h {{{
53+
QUERY
54+
query emails_tree_downside($body: String) {
55+
email(body: $body) {
56+
body
57+
successors {
58+
body
59+
successors {
60+
body
61+
successors {
62+
body
63+
}
64+
}
65+
}
66+
}
67+
}
68+
VARIABLES
69+
---
70+
body: h
71+
...
72+
73+
RESULT
74+
---
75+
email:
76+
- successors:
77+
- successors:
78+
- successors: &0 []
79+
body: m
80+
body: l
81+
- successors: *0
82+
body: k
83+
body: h
84+
...
85+
86+
}}}
87+
88+
RUN upside {{{
89+
QUERY
90+
query emails_trace_upside($body: String) {
91+
email(body: $body) {
92+
body
93+
in_reply_to {
94+
body
95+
in_reply_to {
96+
body
97+
in_reply_to {
98+
body
99+
}
100+
}
101+
}
102+
}
103+
}
104+
VARIABLES
105+
---
106+
body: f
107+
...
108+
109+
RESULT
110+
---
111+
email:
112+
- body: f
113+
in_reply_to:
114+
body: d
115+
in_reply_to:
116+
body: a
117+
...
118+
119+
}}}
120+
121+
RUN upside_x {{{
122+
QUERY
123+
query emails_trace_upside($body: String) {
124+
email(body: $body) {
125+
body
126+
in_reply_to {
127+
body
128+
in_reply_to {
129+
body
130+
in_reply_to {
131+
body
132+
}
133+
}
134+
}
135+
}
136+
}
137+
VARIABLES
138+
---
139+
body: x
140+
...
141+
142+
RESULT
143+
---
144+
ok: false
145+
err: 'FULL MATCH constraint was failed: connection key parts must be all non-nulls
146+
or all nulls; object: {"domain":"graphql.tarantool.org","localpart":"062b56b1885c71c51153ccb880ac7315","body":"x","in_reply_to_domain":"graphql.tarantool.org","in_reply_to_localpart":null}'
147+
...
148+
149+
}}}
150+
151+
RUN upside_y {{{
152+
QUERY
153+
query emails_trace_upside($body: String) {
154+
email(body: $body) {
155+
body
156+
in_reply_to {
157+
body
158+
in_reply_to {
159+
body
160+
in_reply_to {
161+
body
162+
}
163+
}
164+
}
165+
}
166+
}
167+
VARIABLES
168+
---
169+
body: y
170+
...
171+
172+
RESULT
173+
---
174+
ok: false
175+
err: 'FULL MATCH constraint was failed: connection key parts must be all non-nulls
176+
or all nulls; object: {"domain":"graphql.tarantool.org","localpart":"1f70391f6ba858129413bd801b12acbf","body":"y","in_reply_to_domain":null,"in_reply_to_localpart":"1f70391f6ba858129413bd801b12acbf"}'
177+
...
178+
179+
}}}
180+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env tarantool
2+
3+
local fio = require('fio')
4+
5+
-- require in-repo version of graphql/ sources despite current working directory
6+
package.path = fio.abspath(debug.getinfo(1).source:match("@?(.*/)")
7+
:gsub('/./', '/'):gsub('/+$', '')) .. '/../../?.lua' .. ';' ..
8+
package.path
9+
10+
local graphql = require('graphql')
11+
local testdata = require('test.testdata.nullable_1_1_conn_testdata')
12+
13+
-- init box, upload test data and acquire metadata
14+
-- -----------------------------------------------
15+
16+
-- init box and data schema
17+
box.cfg{background = false}
18+
testdata.init_spaces()
19+
20+
-- upload test data
21+
testdata.fill_test_data()
22+
23+
-- acquire metadata
24+
local metadata = testdata.get_test_metadata()
25+
local schemas = metadata.schemas
26+
local collections = metadata.collections
27+
local service_fields = metadata.service_fields
28+
local indexes = metadata.indexes
29+
30+
-- build accessor and graphql schemas
31+
-- ----------------------------------
32+
33+
local accessor = graphql.accessor_space.new({
34+
schemas = schemas,
35+
collections = collections,
36+
service_fields = service_fields,
37+
indexes = indexes,
38+
})
39+
40+
local gql_wrapper = graphql.new({
41+
schemas = schemas,
42+
collections = collections,
43+
accessor = accessor,
44+
})
45+
46+
-- run queries
47+
-- -----------
48+
49+
testdata.run_queries(gql_wrapper)
50+
51+
-- clean up
52+
-- --------
53+
54+
testdata.drop_spaces()
55+
56+
os.exit()

0 commit comments

Comments
 (0)