/// <summary> /// Adds the new directive to every field in this scope and will automatically preappend it to any new fields that are added later. /// Directives are propagated to parent scopres. /// </summary> /// <param name="queryDirective">The query directive.</param> public void InsertDirective(QueryDirective queryDirective) { _directives.Add(queryDirective); foreach (var part in _parts.OfType <IDirectiveContainerDocumentPart>()) { part.InsertDirective(queryDirective, _scopeRank); } }
/// <summary> /// Executes the construction step the specified node to ensure it is "correct" in the context of the rule doing the valdiation. /// </summary> /// <param name="context">The validation context encapsulating a <see cref="SyntaxNode" /> that needs to be validated.</param> /// <returns><c>true</c> if the node is valid, <c>false</c> otherwise.</returns> public override bool Execute(DocumentConstructionContext context) { var node = (DirectiveNode)context.ActiveNode; var directive = context.DocumentContext.Schema.KnownTypes.FindGraphType(node.DirectiveName.ToString()) as IDirectiveGraphType; if (directive == null) { return(false); } var location = node.ParentNode?.DirectiveLocation() ?? DirectiveLocation.NONE; var queryDirective = new QueryDirective(node, directive, location); context.AddDocumentPart(queryDirective); return(true); }