|
8 | 8 | let(:context) { GraphQL::Query::Context.new(query: OpenStruct.new(schema: schema), values: nil) }
|
9 | 9 |
|
10 | 10 | def compatible?(*args)
|
11 |
| - GraphQL::Execution::Typecast.compatible?(*args) |
12 |
| - end |
| 11 | + GraphQL::Execution::Typecast.compatible?(*args) |
| 12 | + end |
| 13 | + |
13 | 14 | it "resolves correctly when both types are the same" do
|
14 |
| - assert compatible?(milk_value, MilkType, MilkType, context) |
15 |
| - assert !compatible?(milk_value, MilkType, CheeseType, context) |
| 15 | + assert compatible?(MilkType, MilkType, context) |
| 16 | + |
| 17 | + assert !compatible?(MilkType, CheeseType, context) |
16 | 18 | end
|
17 | 19 |
|
18 | 20 | it "resolves a union type to a matching member" do
|
19 |
| - assert compatible?(milk_value, DairyProductUnion, MilkType, context) |
20 |
| - assert compatible?(cheese_value, DairyProductUnion, CheeseType, context) |
| 21 | + assert compatible?(DairyProductUnion, MilkType, context) |
| 22 | + assert compatible?(DairyProductUnion, CheeseType, context) |
21 | 23 |
|
22 |
| - assert !compatible?(cheese_value, DairyProductUnion, MilkType, context) |
23 |
| - assert !compatible?(nil, DairyProductUnion, MilkType, context) |
| 24 | + assert !compatible?(DairyProductUnion, GraphQL::INT_TYPE, context) |
| 25 | + assert !compatible?(DairyProductUnion, HoneyType, context) |
24 | 26 | end
|
25 | 27 |
|
26 | 28 | it "resolves correcty when potential type is UnionType and current type is a member of that union" do
|
27 |
| - assert compatible?(milk_value, MilkType, DairyProductUnion, context) |
28 |
| - assert compatible?(cheese_value, CheeseType, DairyProductUnion, context) |
| 29 | + assert compatible?(MilkType, DairyProductUnion, context) |
| 30 | + assert compatible?(CheeseType, DairyProductUnion, context) |
29 | 31 |
|
30 |
| - # assert !compatible?(nil, CheeseType, DairyProductUnion, context) |
31 |
| - # assert !compatible?(cheese_value, MilkType, DairyProductUnion, context) |
| 32 | + assert !compatible?(QueryType, DairyProductUnion, context) |
| 33 | + assert !compatible?(EdibleInterface, DairyProductUnion, context) |
32 | 34 | end
|
33 | 35 |
|
34 | 36 | it "resolves an object type to one of its interfaces" do
|
35 |
| - assert compatible?(cheese_value, CheeseType, EdibleInterface, context) |
36 |
| - assert compatible?(milk_value, MilkType, EdibleInterface, context) |
| 37 | + assert compatible?(CheeseType, EdibleInterface, context) |
| 38 | + assert compatible?(MilkType, EdibleInterface, context) |
37 | 39 |
|
38 |
| - # assert !compatible?(nil, MilkType, EdibleInterface, context) |
39 |
| - # assert !compatible?(milk_value, CheeseType, EdibleInterface, context) |
| 40 | + assert !compatible?(QueryType, EdibleInterface, context) |
| 41 | + assert !compatible?(LocalProductInterface, EdibleInterface, context) |
40 | 42 | end
|
41 | 43 |
|
42 | 44 | it "resolves an interface to a matching member" do
|
43 |
| - assert compatible?(cheese_value, EdibleInterface, CheeseType, context) |
44 |
| - assert compatible?(milk_value, EdibleInterface, MilkType, context) |
| 45 | + assert compatible?(EdibleInterface, CheeseType, context) |
| 46 | + assert compatible?(EdibleInterface, MilkType, context) |
45 | 47 |
|
46 |
| - assert !compatible?(nil, EdibleInterface, MilkType, context) |
47 |
| - assert !compatible?(cheese_value, EdibleInterface, MilkType, context) |
| 48 | + assert !compatible?(EdibleInterface, GraphQL::STRING_TYPE, context) |
| 49 | + assert !compatible?(EdibleInterface, DairyProductInputType, context) |
48 | 50 | end
|
49 | 51 | end
|
0 commit comments