Skip to content

Commit

Permalink
Save the neptune schema to file early so that it can be used for trou…
Browse files Browse the repository at this point in the history
…bleshooting 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.
  • Loading branch information
andreachild authored Jan 8, 2025
1 parent 64a6af9 commit 50a22e4
Showing 1 changed file with 34 additions and 21 deletions.
55 changes: 34 additions & 21 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,36 @@ function processArgs() {

}

/**
* Saves the neptune schema to file
*/
function saveNeptuneSchema() {
// Output Neptune schema
if (inputGraphDBSchema !== '') {
if (outputNeptuneSchemaFile === '') {
if (createUpdatePipelineName === '') {
outputNeptuneSchemaFile = outputFolderPath + '/output.neptune.schema.json';
} else {
outputNeptuneSchemaFile = `${outputFolderPath}/${createUpdatePipelineName}.neptune.schema.json`;
}
}

try {
writeFileSync(outputNeptuneSchemaFile, inputGraphDBSchema);
loggerInfo('Wrote Neptune schema to file: ' + yellow(outputNeptuneSchemaFile), {toConsole: true});
} catch (err) {
loggerError('Error writing Neptune schema to file: ' + yellow(outputNeptuneSchemaFile), err);
}
} else {
loggerDebug('No neptune schema to save to file')
}
}

function createOutputFolder() {
// Init output folder
mkdirSync(outputFolderPath, {recursive: true});
}

async function main() {

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

createOutputFolder();
// save the neptune schema early for troubleshooting purposes
saveNeptuneSchema();

// Option 2: inference GraphQL schema from graphDB schema
if (inputGraphDBSchema != '' && inputGraphQLSchema == '' && inputGraphQLSchemaFile == '') {
loggerInfo('Inferencing GraphQL schema from graphDB schema', {toConsole: true});
Expand Down Expand Up @@ -453,9 +487,6 @@ async function main() {
// Outputs
// ****************************************************************************

// Init output folder
mkdirSync(outputFolderPath, { recursive: true });

// Output GraphQL schema no directives
if (inputGraphQLSchema != '') {

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


// Output Neptune schema
if (outputNeptuneSchemaFile == '') {
if (createUpdatePipelineName == '') {
outputNeptuneSchemaFile = outputFolderPath + '/output.neptune.schema.json';
} else {
outputNeptuneSchemaFile = `${outputFolderPath}/${createUpdatePipelineName}.neptune.schema.json`;
}
}

try {
writeFileSync(outputNeptuneSchemaFile, inputGraphDBSchema);
loggerInfo('Wrote Neptune schema to file: ' + yellow(outputNeptuneSchemaFile), {toConsole: true});
} catch (err) {
loggerError('Error writing Neptune schema to file: ' + yellow(outputNeptuneSchemaFile), err);
}


// Output Lambda resolver
if (outputLambdaResolverFile == '') {
outputLambdaResolverFile = outputFolderPath + '/output.resolver.graphql.js';
Expand Down

0 comments on commit 50a22e4

Please sign in to comment.