Skip to content

Commit 13992b4

Browse files
committed
fix tests
1 parent c0772ce commit 13992b4

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

packages/federation/tests/federation-compatibility-requires-arguments-conflict.test.ts

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,12 @@ const supergraph = await getStitchedSchemaFromLocalSchemas({
9292
category: product.category,
9393
};
9494
},
95-
shippingEstimate(
96-
product: { price: number; weight: number },
97-
args: { currency?: string },
98-
) {
95+
shippingEstimate(product: { price: number; weight: number }) {
96+
const value = product.price * product.weight * 10;
97+
return value;
98+
},
99+
shippingEstimateEUR(product: { price: number; weight: number }) {
99100
const value = product.price * product.weight * 10;
100-
101-
if (args.currency === 'EUR') {
102-
return value * 1.5;
103-
}
104-
105101
return value;
106102
},
107103
isExpensiveCategory(product: {
@@ -166,18 +162,21 @@ const supergraph = await getStitchedSchemaFromLocalSchemas({
166162
category: product.category,
167163
};
168164
},
165+
price(parent, args) {
166+
if (args.currency === 'EUR') return parent.price * 2;
167+
if (args.currency === 'USD') return parent.price;
168+
throw new Error('Unsupported currency ' + args.currency);
169+
},
169170
},
170171
},
171172
},
172173
]),
173174
},
174-
// onSubgraphExecute(subgraph, executionRequest, result) {
175-
// const query = print(executionRequest.document);
176-
// console.log(query);
177-
// // if (subgraph === 'a' && query.includes('_entities')) {
178-
// // // debugger;
179-
// // }
180-
// },
175+
onSubgraphExecute(subgraph, executionRequest, result) {
176+
const query = print(executionRequest.document);
177+
console.log(query);
178+
console.dir(result, { depth: 3000 });
179+
},
181180
});
182181

183182
it('test-query-0', { timeout: 1000 }, async () => {
@@ -202,15 +201,15 @@ it('test-query-0', { timeout: 1000 }, async () => {
202201
{
203202
upc: 'p1',
204203
name: 'p-name-1',
205-
shippingEstimate: 110,
206-
shippingEstimateEUR: 165,
204+
shippingEstimate: 110, // 11 * 1 * 10
205+
shippingEstimateEUR: 220, // (11 * 2) * 1 * 10
207206
isExpensiveCategory: false,
208207
},
209208
{
210209
upc: 'p2',
211210
name: 'p-name-2',
212-
shippingEstimate: 440,
213-
shippingEstimateEUR: 660,
211+
shippingEstimate: 440, // 22 * 2 * 10
212+
shippingEstimateEUR: 880, // (22 * 2) * 2 * 10
214213
isExpensiveCategory: true,
215214
},
216215
],

0 commit comments

Comments
 (0)