@@ -92,16 +92,12 @@ const supergraph = await getStitchedSchemaFromLocalSchemas({
92
92
category : product . category ,
93
93
} ;
94
94
} ,
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 } ) {
99
100
const value = product . price * product . weight * 10 ;
100
-
101
- if ( args . currency === 'EUR' ) {
102
- return value * 1.5 ;
103
- }
104
-
105
101
return value ;
106
102
} ,
107
103
isExpensiveCategory ( product : {
@@ -166,18 +162,21 @@ const supergraph = await getStitchedSchemaFromLocalSchemas({
166
162
category : product . category ,
167
163
} ;
168
164
} ,
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
+ } ,
169
170
} ,
170
171
} ,
171
172
} ,
172
173
] ) ,
173
174
} ,
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
+ } ,
181
180
} ) ;
182
181
183
182
it ( 'test-query-0' , { timeout : 1000 } , async ( ) => {
@@ -202,15 +201,15 @@ it('test-query-0', { timeout: 1000 }, async () => {
202
201
{
203
202
upc : 'p1' ,
204
203
name : 'p-name-1' ,
205
- shippingEstimate : 110 ,
206
- shippingEstimateEUR : 165 ,
204
+ shippingEstimate : 110 , // 11 * 1 * 10
205
+ shippingEstimateEUR : 220 , // (11 * 2) * 1 * 10
207
206
isExpensiveCategory : false ,
208
207
} ,
209
208
{
210
209
upc : 'p2' ,
211
210
name : 'p-name-2' ,
212
- shippingEstimate : 440 ,
213
- shippingEstimateEUR : 660 ,
211
+ shippingEstimate : 440 , // 22 * 2 * 10
212
+ shippingEstimateEUR : 880 , // (22 * 2) * 2 * 10
214
213
isExpensiveCategory : true ,
215
214
} ,
216
215
] ,
0 commit comments