@@ -14,12 +14,12 @@ const fetch = require('node-fetch');
14
14
async function testDistinct ( client ) {
15
15
// Creates 4 distinct objects of which the third one should fail.
16
16
// Then creates 2 new edges of which the first should fail.
17
-
17
+
18
18
// Create Distinct 1
19
19
let createDistinct1 = `
20
20
mutation {
21
21
createDistinctTest(data:{
22
- dummyField : 0
22
+ testDummyField : 0
23
23
}) {
24
24
id
25
25
}
@@ -30,13 +30,13 @@ async function testDistinct(client) {
30
30
console . error ( mutationCreateDistinct1 . errors ) ;
31
31
return false ;
32
32
}
33
- let distinct1Id = mutationCreateDistinct1 . data [ `createDistinct ` ] . id ;
34
-
33
+ let distinct1Id = mutationCreateDistinct1 . data [ `createDistinctTest ` ] . id ;
34
+
35
35
// Create Distinct 2
36
36
let createDistinct2 = `
37
37
mutation {
38
38
createDistinctTest(data:{
39
- dummyField : 1
39
+ testDummyField : 1
40
40
}) {
41
41
id
42
42
}
@@ -47,8 +47,8 @@ async function testDistinct(client) {
47
47
console . error ( mutationCreateDistinct2 . errors ) ;
48
48
return false ;
49
49
}
50
- let distinct2Id = mutationCreateDistinct2 . data [ `createDistinct ` ] . id ;
51
-
50
+ let distinct2Id = mutationCreateDistinct2 . data [ `createDistinctTest ` ] . id ;
51
+
52
52
// Create Distinct 3
53
53
let createDistinct3 = `
54
54
mutation {
@@ -62,14 +62,16 @@ async function testDistinct(client) {
62
62
}
63
63
}
64
64
` ;
65
- const mutationCreateDistinct3 = await client . mutate ( { mutation : gql `${ createDistinct3 } ` } ) ;
66
- if ( mutationCreateDistinct3 . errors ) {
67
- // empty, should actually give errors.
68
- } else {
65
+
66
+ try {
67
+ const mutationCreateDistinct3 = await client . mutate ( { mutation : gql `${ createDistinct3 } ` } ) ;
69
68
console . error ( "Breaking a @distinct directive did not yield an error!" ) ;
70
69
return false ;
71
70
}
72
-
71
+ catch ( e ) {
72
+ // Should actually throw an error
73
+ }
74
+
73
75
// Create Distinct 4
74
76
let createDistinct4 = `
75
77
mutation {
@@ -88,8 +90,8 @@ async function testDistinct(client) {
88
90
console . error ( mutationCreateDistinct4 . errors ) ;
89
91
return false ;
90
92
}
91
- let distinct4Id = mutationCreateDistinct4 . data [ `createDistinct ` ] . id ;
92
-
93
+ let distinct4Id = mutationCreateDistinct4 . data [ `createDistinctTest ` ] . id ;
94
+
93
95
// Create Distinct Edge 1
94
96
let createEdge1 = `
95
97
mutation {
@@ -100,15 +102,16 @@ async function testDistinct(client) {
100
102
id
101
103
}
102
104
}
103
- ` ;
104
- const mutationCreateEdge1 = await client . mutate ( { mutation : gql `${ createEdge1 } ` } ) ;
105
- if ( mutationCreateEdge1 . errors ) {
106
- // empty, should actually give errors.
107
- } else {
105
+ ` ;
106
+ try {
107
+ const mutationCreateEdge1 = await client . mutate ( { mutation : gql `${ createEdge1 } ` } ) ;
108
108
console . error ( "Breaking a @distinct directive did not yield an error!" ) ;
109
109
return false ;
110
110
}
111
-
111
+ catch ( e ) {
112
+ // Should actually throw an error
113
+ }
114
+
112
115
// Create Distinct Edge 2
113
116
let createEdge2 = `
114
117
mutation {
@@ -125,19 +128,19 @@ async function testDistinct(client) {
125
128
console . error ( mutationCreateEdge2 . errors ) ;
126
129
return false ;
127
130
}
128
-
131
+
129
132
return true ;
130
133
}
131
134
132
135
async function testNoloops ( client ) {
133
136
// Create the two connected object.
134
137
// Create two edges of which one the first is a loop and should fail
135
-
138
+
136
139
// Create Noloops 1
137
140
let createNoloops1 = `
138
141
mutation {
139
142
createNoloopsTest(data:{
140
- dummyField : 0
143
+ testDummyField : 0
141
144
}) {
142
145
id
143
146
}
@@ -148,7 +151,7 @@ async function testNoloops(client) {
148
151
console . error ( mutationCreateNoloops1 . errors ) ;
149
152
return false ;
150
153
}
151
- let noloops1Id = mutationCreateNoloops1 . data [ `createNoloops ` ] . id ;
154
+ let noloops1Id = mutationCreateNoloops1 . data [ `createNoloopsTest ` ] . id ;
152
155
153
156
// Create Noloops 2
154
157
let createNoloops2 = `
@@ -165,6 +168,7 @@ async function testNoloops(client) {
165
168
console . error ( mutationCreateNoloops2 . errors ) ;
166
169
return false ;
167
170
}
171
+ let noloops2Id = mutationCreateNoloops2 . data [ `createNoloopsTest` ] . id ;
168
172
169
173
// Create Loop edge
170
174
let createLoop = `
@@ -177,13 +181,15 @@ async function testNoloops(client) {
177
181
}
178
182
}
179
183
` ;
180
- const mutationCreateLoop = await client . mutate ( { mutation : gql `${ createLoop } ` } ) ;
181
- if ( mutationCreateLoop . errors ) {
182
- // empty, should actually give errors.
183
- } else {
184
+
185
+ try {
186
+ const mutationCreateLoop = await client . mutate ( { mutation : gql `${ createLoop } ` } ) ;
184
187
console . error ( "Breaking a @noloops directive did not yield an error!" ) ;
185
188
return false ;
186
189
}
190
+ catch ( e ) {
191
+ // Should actually throw an error
192
+ }
187
193
188
194
// Create Not Loop edge
189
195
let createNotLoop = `
@@ -197,7 +203,7 @@ async function testNoloops(client) {
197
203
}
198
204
` ;
199
205
const mutationCreateNotLoop = await client . mutate ( { mutation : gql `${ createNotLoop } ` } ) ;
200
- if ( mutationCreateNotLoops . error ) {
206
+ if ( mutationCreateNotLoop . error ) {
201
207
console . error ( mutationCreateNotLoop . errors ) ;
202
208
return false ;
203
209
}
@@ -210,30 +216,32 @@ async function testRequiredForTargetTest(client) {
210
216
// Queries the id of the edge, and tries to delete the edge followed by the object.
211
217
// Both deletions should fail.
212
218
// Lastly delete both objects in valid order
213
-
219
+
214
220
// Create RequiredForTargetTarget 1
215
221
let createRequiredForTargetTarget1 = `
216
222
mutation {
217
223
createRequiredForTargetTarget(data:{
218
- dummyField : 0
224
+ testDummyField : 0
219
225
}) {
220
226
id
221
227
}
222
228
}
223
229
` ;
224
- const mutationCreateRequiredForTargetTarget1 = await client . mutate ( { mutation : gql `${ createRequiredForTargetTarget1 } ` } ) ;
225
- if ( mutationCreateRequiredForTargetTarget1 . errors ) {
226
- // empty, should actually give errors.
227
- } else {
230
+
231
+ try {
232
+ const mutationCreateRequiredForTargetTarget1 = await client . mutate ( { mutation : gql `${ createRequiredForTargetTarget1 } ` } ) ;
228
233
console . error ( "Breaking a @requiredForTarget directive did not yield an error!" ) ;
229
234
return false ;
230
235
}
231
-
236
+ catch ( e ) {
237
+ // Should actually throw an error
238
+ }
239
+
232
240
// Create
233
241
let create = `
234
242
mutation {
235
243
createRequiredForTargetTest(data:{
236
- target: {create: {dummyField : 1}}
244
+ target: {create: {testDummyField : 1}}
237
245
}) {
238
246
id
239
247
}
@@ -245,13 +253,13 @@ async function testRequiredForTargetTest(client) {
245
253
return false ;
246
254
}
247
255
let noRequiredSourceId = mutationCreate . data [ `createRequiredForTargetTest` ] . id ;
248
-
256
+
249
257
// Get edge id
250
258
let getIds = `
251
259
query {
252
260
requiredForTargetTest(id: "${ noRequiredSourceId } ") {
253
- target
254
- _outgoingTargetEdges { id }
261
+ target { id }
262
+ _outgoingTargetEdgesFromRequiredForTargetTest { id }
255
263
}
256
264
}` ;
257
265
@@ -260,39 +268,44 @@ async function testRequiredForTargetTest(client) {
260
268
if ( queryIds . errors ) {
261
269
console . error ( queryIds . errors ) ;
262
270
}
263
- let targetId = queryIds . requiredForTargetTest . target . id
264
- let edgeId = queryIds . requiredForTargetTest . _outgoingTargetEdges . id ; ;
265
271
272
+ let targetId = queryIds . data . requiredForTargetTest . target . id
273
+ let edgeId = queryIds . data . requiredForTargetTest . _outgoingTargetEdgesFromRequiredForTargetTest . id ;
274
+
266
275
// Delete Edge
267
276
let deleteEdge = `
268
277
mutation {
269
278
deleteTargetEdgeFromRequiredForTargetTest(id: "${ edgeId } "){
270
279
id
271
280
}
272
281
}` ;
273
- const mutationDeleteEdge = await client . mutate ( { mutation : gql `${ deleteEdge } ` } ) ;
274
- if ( mutationDeleteEdge . errors ) {
275
- // empty, should actually give errors.
276
- } else {
282
+
283
+ try {
284
+ const mutationDeleteEdge = await client . mutate ( { mutation : gql `${ deleteEdge } ` } ) ;
277
285
console . error ( "Breaking a @requiredForTarget directive did not yield an error!" ) ;
278
286
return false ;
279
287
}
280
-
288
+ catch ( e ) {
289
+ // Should actually throw an error
290
+ }
291
+
281
292
// Delete Object
282
293
let deleteObject = `
283
294
mutation {
284
295
deleteRequiredForTargetTest(id: "${ noRequiredSourceId } "){
285
296
id
286
297
}
287
298
}` ;
288
- const mutationDeleteObject = await client . mutate ( { mutation : gql `${ deleteObject } ` } ) ;
289
- if ( mutationDeleteObject . errors ) {
290
- // empty, should actually give errors.
291
- } else {
299
+
300
+ try {
301
+ const mutationDeleteObject = await client . mutate ( { mutation : gql `${ deleteObject } ` } ) ;
292
302
console . error ( "Breaking a @requiredForTarget directive did not yield an error!" ) ;
293
303
return false ;
294
304
}
295
-
305
+ catch ( e ) {
306
+ // Should actually throw an error
307
+ }
308
+
296
309
// Delete Target
297
310
let deleteTarget = `
298
311
mutation {
@@ -305,7 +318,7 @@ async function testRequiredForTargetTest(client) {
305
318
console . error ( mutationDeleteTarget . errors ) ;
306
319
return false ;
307
320
}
308
-
321
+
309
322
// Delete Target
310
323
let deleteSource = `
311
324
mutation {
@@ -324,12 +337,12 @@ async function testRequiredForTargetTest(client) {
324
337
325
338
async function testUniqueForTargetTest ( client ) {
326
339
//
327
-
340
+
328
341
// Create UniqueForTargetTarget
329
342
let createUniqueForTargetTarget = `
330
343
mutation {
331
344
createUniqueForTargetTarget(data:{
332
- dummyField : 0
345
+ testDummyField : 0
333
346
}) {
334
347
id
335
348
}
@@ -368,13 +381,15 @@ async function testUniqueForTargetTest(client) {
368
381
}
369
382
}
370
383
` ;
371
- const mutationCreateUniqueForTargetTest2 = await client . mutate ( { mutation : gql `${ createUniqueForTargetTest2 } ` } ) ;
372
- if ( mutationCreateUniqueForTargetTest2 . errors ) {
373
- // empty, should actually give errors.
374
- } else {
384
+
385
+ try {
386
+ const mutationCreateUniqueForTargetTest2 = await client . mutate ( { mutation : gql `${ createUniqueForTargetTest2 } ` } ) ;
375
387
console . error ( "Breaking a @uniqueForTarget directive did not yield an error!" ) ;
376
388
return false ;
377
389
}
390
+ catch ( e ) {
391
+ // Should actually throw an error
392
+ }
378
393
379
394
return true ;
380
395
}
0 commit comments