@@ -15,6 +15,154 @@ public class DemoIntegrationTests(ITestOutputHelper output)
15
15
{
16
16
private readonly Func < ICompositionLog > _logFactory = ( ) => new TestCompositionLog ( output ) ;
17
17
18
+ [ Fact ]
19
+ public async Task Same_Selection_On_Two_Object_Types_That_Require_Data_From_Another_Subgraph ( )
20
+ {
21
+ // arrange
22
+ var subgraphA = await TestSubgraph . CreateAsync (
23
+ """
24
+ type Query {
25
+ item1: Item1!
26
+ item2: Item2!
27
+ }
28
+
29
+ type Item1 {
30
+ product: Product!
31
+ }
32
+
33
+ type Item2 {
34
+ product: Product!
35
+ }
36
+
37
+ type Product implements Node {
38
+ id: ID!
39
+ }
40
+
41
+ interface Node {
42
+ id: ID!
43
+ }
44
+ """ ) ;
45
+
46
+ var subgraphB = await TestSubgraph . CreateAsync (
47
+ """
48
+ type Query {
49
+ node(id: ID!): Node
50
+ nodes(ids: [ID!]!): [Node]!
51
+ }
52
+
53
+ type Product implements Node {
54
+ id: ID!
55
+ name: String!
56
+ }
57
+
58
+ interface Node {
59
+ id: ID!
60
+ }
61
+ """ ) ;
62
+
63
+ using var subgraphs = new TestSubgraphCollection ( output , [ subgraphA , subgraphB ] ) ;
64
+ var executor = await subgraphs . GetExecutorAsync ( ) ;
65
+ var request = Parse ( """
66
+ query {
67
+ item1 {
68
+ product {
69
+ id
70
+ name
71
+ }
72
+ }
73
+ item2 {
74
+ product {
75
+ id
76
+ name
77
+ }
78
+ }
79
+ }
80
+ """ ) ;
81
+
82
+ // act
83
+ var result = await executor . ExecuteAsync (
84
+ OperationRequestBuilder
85
+ . New ( )
86
+ . SetDocument ( request )
87
+ . Build ( ) ) ;
88
+
89
+ // assert
90
+ var snapshot = new Snapshot ( ) ;
91
+ CollectSnapshotData ( snapshot , request , result ) ;
92
+ await snapshot . MatchMarkdownAsync ( ) ;
93
+ }
94
+
95
+ [ Fact ]
96
+ public async Task Same_Selection_On_Two_List_Fields_That_Require_Data_From_Another_Subgraph ( )
97
+ {
98
+ // arrange
99
+ var subgraphA = await TestSubgraph . CreateAsync (
100
+ """
101
+ interface Node {
102
+ id: ID!
103
+ }
104
+
105
+ type Query {
106
+ productsA: [Product]
107
+ productsB: [Product]
108
+ }
109
+
110
+ type Product implements Node {
111
+ id: ID!
112
+ name: String!
113
+ }
114
+ """ ) ;
115
+
116
+ var subgraphB = await TestSubgraph . CreateAsync (
117
+ """
118
+ interface Node {
119
+ id: ID!
120
+ }
121
+
122
+ type Query {
123
+ node(id: ID!): Node
124
+ nodes(ids: [ID!]!): [Node]!
125
+ }
126
+
127
+ type Product implements Node {
128
+ id: ID!
129
+ price: Float!
130
+ reviewCount: Int!
131
+ }
132
+ """ ) ;
133
+
134
+ using var subgraphs = new TestSubgraphCollection ( output , [ subgraphA , subgraphB ] ) ;
135
+ var executor = await subgraphs . GetExecutorAsync ( ) ;
136
+ var request = Parse ( """
137
+ query {
138
+ productsA {
139
+ id
140
+ name
141
+ price
142
+ reviewCount
143
+ }
144
+ productsB {
145
+ id
146
+ name
147
+ price
148
+ reviewCount
149
+ }
150
+ }
151
+ """ ) ;
152
+
153
+ // act
154
+ var result = await executor . ExecuteAsync (
155
+ OperationRequestBuilder
156
+ . New ( )
157
+ . SetDocument ( request )
158
+ . Build ( ) ) ;
159
+
160
+ // assert
161
+ var snapshot = new Snapshot ( ) ;
162
+ CollectSnapshotData ( snapshot , request , result ) ;
163
+ await snapshot . MatchMarkdownAsync ( ) ;
164
+ }
165
+
18
166
[ Fact ]
19
167
public async Task Authors_And_Reviews_AutoCompose ( )
20
168
{
0 commit comments