Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getTemporaryOperationsFile(resource, schemaFile) {
const operationsFile = path.join('.serverless', 'amplify-operations.graphql');
graphqlGenerator(schemaFile, operationsFile, { language: 'graphql' });
return operationsFile;
}
writeGraphQLOperations(resources, fileDetails) {
const resource = resources.find(r => r.ResourceType === 'AWS::AppSync::GraphQLApi');
if (resource) {
const schemaFile = this.getTemporarySchemaFile(resource);
graphqlGenerator(schemaFile, fileDetails.filename, { language: 'graphql' });
} else {
throw new Error(`No GraphQL API found - cannot write ${fileDetails.filename} file`);
}
}
: path.dirname(path.dirname(includeFiles));
const schemaPath = path.join(projectPath, cfg.schema);
let region;
let frontend;
if (!withoutInit) {
({ region } = cfg.amplifyExtension);
await ensureIntrospectionSchema(context, schemaPath, apis[0], region, forceDownloadSchema);
frontend = getFrontEndHandler(context);
} else {
frontend = decoupleFrontend;
}
const language = frontend === 'javascript' ? cfg.amplifyExtension.codeGenTarget : 'graphql';
const opsGenSpinner = new Ora(constants.INFO_MESSAGE_OPS_GEN);
opsGenSpinner.start();
fs.ensureDirSync(opsGenDirectory);
await generate(schemaPath, opsGenDirectory, {
separateFiles: true,
language,
maxDepth: maxDepth || cfg.amplifyExtension.maxDepth,
});
opsGenSpinner.succeed(constants.INFO_MESSAGE_OPS_GEN_SUCCESS + path.relative(path.resolve('.'), opsGenDirectory));
});
}