Example #1
0
        public List <VariableUsage> GetVariables(
            ASTNode rootNode)
        {
            var usages = new List <VariableUsage>();

            var visitor = new RulesWalker(new CombineRule[]
            {
                (context, rule) =>
                {
                    rule.EnterVariable += node =>
                    {
                        usages.Add(new VariableUsage
                        {
                            Node         = node,
                            Type         = context.Tracker.GetInputType(),
                            DefaultValue = context.Tracker.GetDefaultValue()
                        });
                    };
                }
            },
                                          Schema,
                                          Document,
                                          VariableValues);


            visitor.BeginVisitNode(rootNode);

            return(usages);
        }
Example #2
0
        public static ValidationResult Validate(
            IEnumerable <CombineRule> rules,
            ISchema schema,
            GraphQLDocument document,
            Dictionary <string, object> variableValues = null)
        {
            var visitor = new RulesWalker(
                rules,
                schema,
                document,
                variableValues);

            return(visitor.Validate());
        }