Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function generateAndVisitComplexMethod(maximumComplexity: number): ValidationContext {
const query = /* graphql */ `
query {
sampleQuery {
complexResolverMethod
}
}
`;
const ast = parse(query);
const typeInfo = new TypeInfo(schema);
const context = new ValidationContext(schema, ast, typeInfo);
const visitor = new ComplexityVisitor(context, {
maximumComplexity,
estimators: [fieldExtensionsEstimator(), simpleEstimator({ defaultComplexity: 1 })],
});
visit(ast, visitWithTypeInfo(typeInfo, visitor));
return context;
}