@@ -264,6 +264,36 @@ function processArgs() {
264
264
265
265
}
266
266
267
+ /**
268
+ * Saves the neptune schema to file
269
+ */
270
+ function saveNeptuneSchema ( ) {
271
+ // Output Neptune schema
272
+ if ( inputGraphDBSchema !== '' ) {
273
+ if ( outputNeptuneSchemaFile === '' ) {
274
+ if ( createUpdatePipelineName === '' ) {
275
+ outputNeptuneSchemaFile = outputFolderPath + '/output.neptune.schema.json' ;
276
+ } else {
277
+ outputNeptuneSchemaFile = `${ outputFolderPath } /${ createUpdatePipelineName } .neptune.schema.json` ;
278
+ }
279
+ }
280
+
281
+ try {
282
+ writeFileSync ( outputNeptuneSchemaFile , inputGraphDBSchema ) ;
283
+ loggerInfo ( 'Wrote Neptune schema to file: ' + yellow ( outputNeptuneSchemaFile ) , { toConsole : true } ) ;
284
+ } catch ( err ) {
285
+ loggerError ( 'Error writing Neptune schema to file: ' + yellow ( outputNeptuneSchemaFile ) , err ) ;
286
+ }
287
+ } else {
288
+ loggerDebug ( 'No neptune schema to save to file' )
289
+ }
290
+ }
291
+
292
+ function createOutputFolder ( ) {
293
+ // Init output folder
294
+ mkdirSync ( outputFolderPath , { recursive : true } ) ;
295
+ }
296
+
267
297
async function main ( ) {
268
298
269
299
if ( process . argv . length <= 2 ) {
@@ -321,6 +351,10 @@ async function main() {
321
351
loggerInfo ( 'Fetch neptune schema execution time: ' + ( executionTime / 1000 ) . toFixed ( 2 ) + ' seconds' , { toConsole : true } ) ;
322
352
}
323
353
354
+ createOutputFolder ( ) ;
355
+ // save the neptune schema early for troubleshooting purposes
356
+ saveNeptuneSchema ( ) ;
357
+
324
358
// Option 2: inference GraphQL schema from graphDB schema
325
359
if ( inputGraphDBSchema != '' && inputGraphQLSchema == '' && inputGraphQLSchemaFile == '' ) {
326
360
loggerInfo ( 'Inferencing GraphQL schema from graphDB schema' , { toConsole : true } ) ;
@@ -453,9 +487,6 @@ async function main() {
453
487
// Outputs
454
488
// ****************************************************************************
455
489
456
- // Init output folder
457
- mkdirSync ( outputFolderPath , { recursive : true } ) ;
458
-
459
490
// Output GraphQL schema no directives
460
491
if ( inputGraphQLSchema != '' ) {
461
492
@@ -493,24 +524,6 @@ async function main() {
493
524
loggerError ( 'Error writing output GraphQL schema to file: ' + yellow ( outputSourceSchemaFile ) , err ) ;
494
525
}
495
526
496
-
497
- // Output Neptune schema
498
- if ( outputNeptuneSchemaFile == '' ) {
499
- if ( createUpdatePipelineName == '' ) {
500
- outputNeptuneSchemaFile = outputFolderPath + '/output.neptune.schema.json' ;
501
- } else {
502
- outputNeptuneSchemaFile = `${ outputFolderPath } /${ createUpdatePipelineName } .neptune.schema.json` ;
503
- }
504
- }
505
-
506
- try {
507
- writeFileSync ( outputNeptuneSchemaFile , inputGraphDBSchema ) ;
508
- loggerInfo ( 'Wrote Neptune schema to file: ' + yellow ( outputNeptuneSchemaFile ) , { toConsole : true } ) ;
509
- } catch ( err ) {
510
- loggerError ( 'Error writing Neptune schema to file: ' + yellow ( outputNeptuneSchemaFile ) , err ) ;
511
- }
512
-
513
-
514
527
// Output Lambda resolver
515
528
if ( outputLambdaResolverFile == '' ) {
516
529
outputLambdaResolverFile = outputFolderPath + '/output.resolver.graphql.js' ;
0 commit comments