Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function _getOutline(queryText: string): EXIT_CODE {
try {
const outline = getOutline(queryText);
if (outline) {
process.stdout.write(JSON.stringify(outline, null, 2));
} else {
throw Error('Error parsing or no outline tree found');
}
} catch (error) {
process.stderr.write(error);
return GRAPHQL_FAILURE_CODE;
}
return GRAPHQL_SUCCESS_CODE;
}
const formatted = result.map(
res => ({
text: res.label,
typeName: res.detail ? String(res.detail) : null,
description: res.documentation || null,
}),
);
responseMsg = convertToRpcMessage({
type: 'response',
id,
formatted,
});
process.stdout.write(JSON.stringify(responseMsg) + '\n');
break;
case 'getOutline':
result = getOutline(query);
responseMsg = convertToRpcMessage({
type: 'response',
id,
result,
});
process.stdout.write(JSON.stringify(responseMsg) + '\n');
break;
default:
break;
}
}