@@ -36,13 +36,13 @@ func TestIsTypeOfUsedToResolveRuntimeTypeForInterface(t *testing.T) {
36
36
})
37
37
38
38
// ie declare that Dog belongs to Pet interface
39
- _ = graphql .NewObject (graphql.ObjectConfig {
39
+ dogType : = graphql .NewObject (graphql.ObjectConfig {
40
40
Name : "Dog" ,
41
41
Interfaces : []* graphql.Interface {
42
42
petType ,
43
43
},
44
- IsTypeOf : func (value interface {}, info graphql.ResolveInfo ) bool {
45
- _ , ok := value .(* testDog )
44
+ IsTypeOf : func (p graphql.IsTypeOfParams ) bool {
45
+ _ , ok := p . Value .(* testDog )
46
46
return ok
47
47
},
48
48
Fields : graphql.Fields {
@@ -67,13 +67,13 @@ func TestIsTypeOfUsedToResolveRuntimeTypeForInterface(t *testing.T) {
67
67
},
68
68
})
69
69
// ie declare that Cat belongs to Pet interface
70
- _ = graphql .NewObject (graphql.ObjectConfig {
70
+ catType : = graphql .NewObject (graphql.ObjectConfig {
71
71
Name : "Cat" ,
72
72
Interfaces : []* graphql.Interface {
73
73
petType ,
74
74
},
75
- IsTypeOf : func (value interface {}, info graphql.ResolveInfo ) bool {
76
- _ , ok := value .(* testCat )
75
+ IsTypeOf : func (p graphql.IsTypeOfParams ) bool {
76
+ _ , ok := p . Value .(* testCat )
77
77
return ok
78
78
},
79
79
Fields : graphql.Fields {
@@ -112,6 +112,7 @@ func TestIsTypeOfUsedToResolveRuntimeTypeForInterface(t *testing.T) {
112
112
},
113
113
},
114
114
}),
115
+ Types : []graphql.Type {catType , dogType },
115
116
})
116
117
if err != nil {
117
118
t .Fatalf ("Error in schema %v" , err .Error ())
@@ -161,8 +162,8 @@ func TestIsTypeOfUsedToResolveRuntimeTypeForUnion(t *testing.T) {
161
162
162
163
dogType := graphql .NewObject (graphql.ObjectConfig {
163
164
Name : "Dog" ,
164
- IsTypeOf : func (value interface {}, info graphql.ResolveInfo ) bool {
165
- _ , ok := value .(* testDog )
165
+ IsTypeOf : func (p graphql.IsTypeOfParams ) bool {
166
+ _ , ok := p . Value .(* testDog )
166
167
return ok
167
168
},
168
169
Fields : graphql.Fields {
@@ -176,8 +177,8 @@ func TestIsTypeOfUsedToResolveRuntimeTypeForUnion(t *testing.T) {
176
177
})
177
178
catType := graphql .NewObject (graphql.ObjectConfig {
178
179
Name : "Cat" ,
179
- IsTypeOf : func (value interface {}, info graphql.ResolveInfo ) bool {
180
- _ , ok := value .(* testCat )
180
+ IsTypeOf : func (p graphql.IsTypeOfParams ) bool {
181
+ _ , ok := p . Value .(* testCat )
181
182
return ok
182
183
},
183
184
Fields : graphql.Fields {
@@ -269,14 +270,14 @@ func TestResolveTypeOnInterfaceYieldsUsefulError(t *testing.T) {
269
270
Type : graphql .String ,
270
271
},
271
272
},
272
- ResolveType : func (value interface {}, info graphql.ResolveInfo ) * graphql.Object {
273
- if _ , ok := value .(* testCat ); ok {
273
+ ResolveType : func (p graphql.ResolveTypeParams ) * graphql.Object {
274
+ if _ , ok := p . Value .(* testCat ); ok {
274
275
return catType
275
276
}
276
- if _ , ok := value .(* testDog ); ok {
277
+ if _ , ok := p . Value .(* testDog ); ok {
277
278
return dogType
278
279
}
279
- if _ , ok := value .(* testHuman ); ok {
280
+ if _ , ok := p . Value .(* testHuman ); ok {
280
281
return humanType
281
282
}
282
283
return nil
@@ -288,12 +289,6 @@ func TestResolveTypeOnInterfaceYieldsUsefulError(t *testing.T) {
288
289
Fields : graphql.Fields {
289
290
"name" : & graphql.Field {
290
291
Type : graphql .String ,
291
- Resolve : func (p graphql.ResolveParams ) (interface {}, error ) {
292
- if human , ok := p .Source .(* testHuman ); ok {
293
- return human .Name , nil
294
- }
295
- return nil , nil
296
- },
297
292
},
298
293
},
299
294
})
@@ -302,28 +297,12 @@ func TestResolveTypeOnInterfaceYieldsUsefulError(t *testing.T) {
302
297
Interfaces : []* graphql.Interface {
303
298
petType ,
304
299
},
305
- IsTypeOf : func (value interface {}, info graphql.ResolveInfo ) bool {
306
- _ , ok := value .(* testDog )
307
- return ok
308
- },
309
300
Fields : graphql.Fields {
310
301
"name" : & graphql.Field {
311
302
Type : graphql .String ,
312
- Resolve : func (p graphql.ResolveParams ) (interface {}, error ) {
313
- if dog , ok := p .Source .(* testDog ); ok {
314
- return dog .Name , nil
315
- }
316
- return nil , nil
317
- },
318
303
},
319
304
"woofs" : & graphql.Field {
320
305
Type : graphql .Boolean ,
321
- Resolve : func (p graphql.ResolveParams ) (interface {}, error ) {
322
- if dog , ok := p .Source .(* testDog ); ok {
323
- return dog .Woofs , nil
324
- }
325
- return nil , nil
326
- },
327
306
},
328
307
},
329
308
})
@@ -332,28 +311,12 @@ func TestResolveTypeOnInterfaceYieldsUsefulError(t *testing.T) {
332
311
Interfaces : []* graphql.Interface {
333
312
petType ,
334
313
},
335
- IsTypeOf : func (value interface {}, info graphql.ResolveInfo ) bool {
336
- _ , ok := value .(* testCat )
337
- return ok
338
- },
339
314
Fields : graphql.Fields {
340
315
"name" : & graphql.Field {
341
316
Type : graphql .String ,
342
- Resolve : func (p graphql.ResolveParams ) (interface {}, error ) {
343
- if cat , ok := p .Source .(* testCat ); ok {
344
- return cat .Name , nil
345
- }
346
- return nil , nil
347
- },
348
317
},
349
318
"meows" : & graphql.Field {
350
319
Type : graphql .Boolean ,
351
- Resolve : func (p graphql.ResolveParams ) (interface {}, error ) {
352
- if cat , ok := p .Source .(* testCat ); ok {
353
- return cat .Meows , nil
354
- }
355
- return nil , nil
356
- },
357
320
},
358
321
},
359
322
})
@@ -373,6 +336,7 @@ func TestResolveTypeOnInterfaceYieldsUsefulError(t *testing.T) {
373
336
},
374
337
},
375
338
}),
339
+ Types : []graphql.Type {catType , dogType },
376
340
})
377
341
if err != nil {
378
342
t .Fatalf ("Error in schema %v" , err .Error ())
@@ -405,7 +369,7 @@ func TestResolveTypeOnInterfaceYieldsUsefulError(t *testing.T) {
405
369
},
406
370
},
407
371
Errors : []gqlerrors.FormattedError {
408
- gqlerrors. FormattedError {
372
+ {
409
373
Message : `Runtime Object type "Human" is not a possible type for "Pet".` ,
410
374
Locations : []location.SourceLocation {},
411
375
},
@@ -461,14 +425,14 @@ func TestResolveTypeOnUnionYieldsUsefulError(t *testing.T) {
461
425
Types : []* graphql.Object {
462
426
dogType , catType ,
463
427
},
464
- ResolveType : func (value interface {}, info graphql.ResolveInfo ) * graphql.Object {
465
- if _ , ok := value .(* testCat ); ok {
428
+ ResolveType : func (p graphql.ResolveTypeParams ) * graphql.Object {
429
+ if _ , ok := p . Value .(* testCat ); ok {
466
430
return catType
467
431
}
468
- if _ , ok := value .(* testDog ); ok {
432
+ if _ , ok := p . Value .(* testDog ); ok {
469
433
return dogType
470
434
}
471
- if _ , ok := value .(* testHuman ); ok {
435
+ if _ , ok := p . Value .(* testHuman ); ok {
472
436
return humanType
473
437
}
474
438
return nil
@@ -523,7 +487,7 @@ func TestResolveTypeOnUnionYieldsUsefulError(t *testing.T) {
523
487
},
524
488
},
525
489
Errors : []gqlerrors.FormattedError {
526
- gqlerrors. FormattedError {
490
+ {
527
491
Message : `Runtime Object type "Human" is not a possible type for "Pet".` ,
528
492
Locations : []location.SourceLocation {},
529
493
},
0 commit comments