Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Store the loadable GraphiQL URL against that id
const queryParams = buildGraphiqlQueryParams(req.body);
devQueryLog[id] = `${graphiqlPath}?${queryParams}`;
const ast = gql(req.body.query);
const operations = ast.definitions.map(
def => `${def.operation} ${def.name ? `${def.name.value} ` : ''}{ .. }`
);
// Make the queries clickable in the terminal where supported
console.log(
terminalLink(
`${chalk.blue(operations.map(op => chalkColour.bold(op)).join(', '))}${
terminalLink.isSupported ? ` (👈 click to view)` : ''
}`,
`${req.protocol}://${req.get('host')}${devQueryPath}?id=${id}`,
{
// Otherwise, show the link on a new line
fallback: (text, url) => `${text}\n${chalkColour.gray(` ⤷ inspect @ ${url}`)}`,
}
)
);
// finally pass requests to the actual graphql endpoint
next();
};
exports.linkifyCommit = (url, commit) => {
if (!(url && terminalLink.isSupported)) {
return commit;
}
return terminalLink(commit, `${url}/commit/${commit}`);
};