Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// TODO
// DANGEROUS
// UNSAFE
// Never save user's query.
// This is only for demonstration
const resolvers = new Function(...args, body).call({});
const execSchema = makeExecutableSchema({
typeDefs: schema,
resolvers
});
const compileStart = performance.now();
const compiledQuery = compileQuery(execSchema, parse(query), undefined, {debug: true} as any);
if (!isCompiledQuery(compiledQuery)) {
return {
compiledQuery: "",
executionResult: JSON.stringify(compiledQuery, null, 2)
};
}
const compileTime = performance.now() - compileStart;
const execStart = performance.now();
const executionResult = await compiledQuery.query({}, {}, {});
const executeTime = performance.now() - execStart;
return {
compiledQuery: prettier.format((compiledQuery as any).__DO_NOT_USE_THIS_OR_YOU_WILL_BE_FIRED_compilation,
{ parser: "babel", plugins: [babylonParser], printWidth: 80 }
),
executionResult: JSON.stringify(