Skip to content

Commit 50a22e4

Browse files
authored
Save the neptune schema to file early so that it can be used for troubleshooting if errors occur later in the pipeline. (#56)
Save the neptune schema to file early (as soon as it's available) so that it can be used for troubleshooting if errors occur later in the pipeline.
1 parent 64a6af9 commit 50a22e4

File tree

1 file changed

+34
-21
lines changed

1 file changed

+34
-21
lines changed

src/main.js

+34-21
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,36 @@ function processArgs() {
264264

265265
}
266266

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+
267297
async function main() {
268298

269299
if (process.argv.length <= 2) {
@@ -321,6 +351,10 @@ async function main() {
321351
loggerInfo('Fetch neptune schema execution time: ' + (executionTime/1000).toFixed(2) + ' seconds', {toConsole: true});
322352
}
323353

354+
createOutputFolder();
355+
// save the neptune schema early for troubleshooting purposes
356+
saveNeptuneSchema();
357+
324358
// Option 2: inference GraphQL schema from graphDB schema
325359
if (inputGraphDBSchema != '' && inputGraphQLSchema == '' && inputGraphQLSchemaFile == '') {
326360
loggerInfo('Inferencing GraphQL schema from graphDB schema', {toConsole: true});
@@ -453,9 +487,6 @@ async function main() {
453487
// Outputs
454488
// ****************************************************************************
455489

456-
// Init output folder
457-
mkdirSync(outputFolderPath, { recursive: true });
458-
459490
// Output GraphQL schema no directives
460491
if (inputGraphQLSchema != '') {
461492

@@ -493,24 +524,6 @@ async function main() {
493524
loggerError('Error writing output GraphQL schema to file: ' + yellow(outputSourceSchemaFile), err);
494525
}
495526

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-
514527
// Output Lambda resolver
515528
if (outputLambdaResolverFile == '') {
516529
outputLambdaResolverFile = outputFolderPath + '/output.resolver.graphql.js';

0 commit comments

Comments
 (0)