public void DefaultScalarValueResolvers_InvalidInputValue(string expressionText, string inputText) { var generator = new InputResolverMethodGenerator(this.CreateSchema()); var text = inputText?.AsMemory() ?? ReadOnlyMemory <char> .Empty; var source = new SourceText(text); var tokenStream = Lexer.Tokenize(source); tokenStream.Prime(); InputValueNode node = null; if (!tokenStream.EndOfStream) { var maker = ValueMakerFactory.CreateMaker(tokenStream.ActiveToken); if (maker != null) { node = maker.MakeNode(tokenStream) as InputValueNode; } } var inputValue = QueryInputValueFactory.CreateInputValue(node); var typeExpression = GraphTypeExpression.FromDeclaration(expressionText); var resolver = generator.CreateResolver(typeExpression); Assert.Throws <UnresolvedValueException>(() => { resolver.Resolve(inputValue); }); }
/// <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) { // for whatever the active argument in context is // it could be an argument on a field, on a directive or // even an argument that is part of a nested input object inside a field argument set // make a value container for the active value // then add it to the context. var node = (InputValueNode)context.ActiveNode; var queryValue = QueryInputValueFactory.CreateInputValue(node); context.AddDocumentPart(queryValue); return(true); }