Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
task: (ctx, task) => {
// Make sure the expectations of our context are correct.
assert.strictEqual(typeof ctx.queryDocuments, "undefined");
ctx.queryDocuments = loadQueryDocuments(
ctx.documentSets[0].documentPaths,
flags.tagName
);
task.title = `Scanning for GraphQL queries (${
ctx.queryDocuments.length
} found)`;
}
});
const loadAsAST = () => {
const ast = loadQueryDocuments([referredSchema.schema!])[0];
if (referredSchema.clientSide) {
visit(ast, {
enter(node) {
if (node.kind == "FieldDefinition") {
(node as any).__client = true;
}
}
});
}
return ast;
};
task: async (ctx, task) => {
const docs = loadQueryDocuments(ctx.queryPaths, flags.tagName);
const errors: GraphQLError[] = [];
const warnings: GraphQLError[] = []
docs.forEach((doc, i) => {
const validateResult = validate(ctx.schema, doc);
const deprecationResult = findDeprecatedUsages(ctx.schema, doc);
errors.push(...validateResult);
warnings.push(...deprecationResult);
task.title = `Checking query compatibility with schema (${i + 1}/${docs.length}, ${errors.length} errors, ${warnings.length} warnings)`;
return validateResult.concat(deprecationResult);
});
if (errors.length > 0 || warnings.length > 0) {