public ValidationResult IsValid(Schema schema, Document document, string operationName) { var result = new ValidationResult(); if (string.IsNullOrWhiteSpace(operationName) && document.Operations.Count() > 1) { result.Errors.Add(new ExecutionError("Must provide operation name if query contains multiple operations")); } return result; }
public IValidationResult Validate( string originalQuery, ISchema schema, Document document, IEnumerable<IValidationRule> rules = null, object userContext = null) { if (!schema.Initialized) { schema.Initialize(); } var context = new ValidationContext { OriginalQuery = originalQuery, Schema = schema, Document = document, TypeInfo = new TypeInfo(schema), UserContext = userContext }; if (rules == null) { rules = CoreRules(); } var visitors = rules.Select(x => x.Validate(context)).ToList(); visitors.Insert(0, context.TypeInfo); // #if DEBUG // visitors.Insert(1, new DebugNodeVisitor()); // #endif var basic = new BasicVisitor(visitors.ToArray()); basic.Visit(document); var result = new ValidationResult(); result.Errors.AddRange(context.Errors); return result; }