@@ -246,30 +246,41 @@ export default class Compiler {
246
246
// Cache compiled files so identical input files are only compiled once
247
247
const compiledFiles = new Map ( ) ;
248
248
249
- subgraph = subgraph . update ( 'dataSources' , ( dataSources : any [ ] ) =>
250
- dataSources . map ( ( dataSource : any ) =>
251
- dataSource . updateIn ( [ 'mapping' , 'file' ] , ( mappingPath : string ) =>
252
- this . _compileDataSourceMapping (
253
- this . protocol ,
254
- dataSource ,
249
+ // Handle data sources
250
+ const dataSources = subgraph . get ( 'dataSources' ) ;
251
+ const compiledDataSources = await Promise . all (
252
+ dataSources . map ( async ( dataSource : any ) => {
253
+ const mappingPath = dataSource . getIn ( [ 'mapping' , 'file' ] ) ;
254
+ const compiledPath = await this . _compileDataSourceMapping (
255
+ this . protocol ,
256
+ dataSource ,
257
+ mappingPath ,
258
+ compiledFiles ,
259
+ spinner ,
260
+ validate ,
261
+ ) ;
262
+ return dataSource . setIn ( [ 'mapping' , 'file' ] , compiledPath ) ;
263
+ } ) ,
264
+ ) ;
265
+ subgraph = subgraph . set ( 'dataSources' , compiledDataSources ) ;
266
+
267
+ // Handle templates if they exist
268
+ const templates = subgraph . get ( 'templates' ) ;
269
+ if ( templates !== undefined ) {
270
+ const compiledTemplates = await Promise . all (
271
+ templates . map ( async ( template : any ) => {
272
+ const mappingPath = template . getIn ( [ 'mapping' , 'file' ] ) ;
273
+ const compiledPath = await this . _compileTemplateMapping (
274
+ template ,
255
275
mappingPath ,
256
276
compiledFiles ,
257
277
spinner ,
258
- validate ,
259
- ) ,
260
- ) ,
261
- ) ,
262
- ) ;
263
-
264
- subgraph = subgraph . update ( 'templates' , ( templates : any ) =>
265
- templates === undefined
266
- ? templates
267
- : templates . map ( ( template : any ) =>
268
- template . updateIn ( [ 'mapping' , 'file' ] , ( mappingPath : string ) =>
269
- this . _compileTemplateMapping ( template , mappingPath , compiledFiles , spinner ) ,
270
- ) ,
271
- ) ,
272
- ) ;
278
+ ) ;
279
+ return template . setIn ( [ 'mapping' , 'file' ] , compiledPath ) ;
280
+ } ) ,
281
+ ) ;
282
+ subgraph = subgraph . set ( 'templates' , compiledTemplates ) ;
283
+ }
273
284
274
285
return subgraph ;
275
286
} ,
@@ -332,7 +343,7 @@ export default class Compiler {
332
343
return missingHandlers ;
333
344
}
334
345
335
- _compileDataSourceMapping (
346
+ async _compileDataSourceMapping (
336
347
protocol : Protocol ,
337
348
dataSource : immutable . Map < any , any > ,
338
349
mappingPath : string ,
@@ -386,7 +397,7 @@ export default class Compiler {
386
397
}
387
398
const global = path . relative ( baseDir , this . globalsFile ) ;
388
399
389
- asc . compile ( {
400
+ await asc . compile ( {
390
401
inputFile,
391
402
global,
392
403
baseDir,
@@ -413,7 +424,7 @@ export default class Compiler {
413
424
}
414
425
}
415
426
416
- _compileTemplateMapping (
427
+ async _compileTemplateMapping (
417
428
template : immutable . Collection < any , any > ,
418
429
mappingPath : string ,
419
430
compiledFiles : Map < any , any > ,
@@ -467,7 +478,7 @@ export default class Compiler {
467
478
}
468
479
const global = path . relative ( baseDir , this . globalsFile ) ;
469
480
470
- asc . compile ( {
481
+ await asc . compile ( {
471
482
inputFile,
472
483
global,
473
484
baseDir,
0 commit comments