Skip to content

Generate an Expression for testing a custom visitor #5155

Answered by BrookyNBS
BrookyNBS asked this question in Q&A
Discussion options

You must be logged in to vote

I've found some inspiration in FilterConventionTests

Using a very similar setup to that suite of tests, I can have my test queries as strings which are then parsed into an IValueNode by using Utf8GraphQLParser.Syntax.ParseValueLiteral(queryText). Then a slightly modified version of the ExecutorBuilder class allows me to return an Expression which I can pass into my CustomExpressionVisitor -

    public class ExecutorBuilder
    {
        private readonly IFilterInputType _inputType;

        public ExecutorBuilder(IFilterInputType inputType)
        {
            _inputType = inputType;
        }

        public Expression<Func<T, bool>> Build<T>(IValueNode filter)
        {
            var 

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by BrookyNBS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant