Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const compileFromSource = source => {
const document = parse(source);
const context = compileToLegacyIR(schema, document, {
mergeInFieldsFromFragmentSpreads: true,
addTypename: true
});
generator.context = context;
return context;
};
compileFromSource = source => {
const document = parse(source);
const context = compileToLegacyIR(schema, document, {
mergeInFieldsFromFragmentSpreads: true,
addTypename: true
});
generator.context = context;
return context;
};
compileFromSource = (
source,
options = { generateOperationIds: false, namespace: undefined }
) => {
const document = parse(source);
let context = compileToLegacyIR(schema, document);
options.generateOperationIds &&
Object.assign(context.options, {
generateOperationIds: true,
operationIdsMap: {}
});
options.namespace &&
Object.assign(context.options, { namespace: options.namespace });
generator.context = context;
return context;
};
writeGeneratedFiles(outFiles, path.resolve("."));
writtenFiles += Object.keys(outFiles).length;
} else {
fs.writeFileSync(
outputPath,
generatedFiles.map(o => o.content().fileContents).join("\n") +
"\n" +
generatedGlobalFile.fileContents
);
writtenFiles += 1;
}
} else {
let output;
const context = compileToLegacyIR(schema, document, options);
switch (target) {
case "json":
output = serializeToJSON(context);
break;
case "scala":
output = generateScalaSource(context);
}
if (outputPath) {
fs.writeFileSync(outputPath, output);
writtenFiles += 1;
} else {
console.log(output);
}
}