@@ -60,37 +60,39 @@ public INodeVisitor Validate(ValidationContext context)
6060 } ) ;
6161 }
6262
63- private bool SkipAuthCheck ( Field fieldAst , ValidationContext context )
63+ private bool SkipAuthCheck ( Field field , ValidationContext context )
6464 {
65- if ( fieldAst . Directives == null || ! fieldAst . Directives . Any ( ) ) return false ;
65+ if ( field . Directives == null || ! field . Directives . Any ( ) ) return false ;
6666
67- var includeField = GetDirectiveValue ( context , fieldAst . Directives , DirectiveGraphType . Include ) ;
67+ var operationName = context . OperationName ;
68+ var documentOperations = context . Document . Operations ;
69+ var operation = ! string . IsNullOrWhiteSpace ( operationName )
70+ ? documentOperations . WithName ( operationName )
71+ : documentOperations . FirstOrDefault ( ) ;
72+ var variables = ExecutionHelper . GetVariableValues ( context . Document , context . Schema ,
73+ operation ? . Variables , context . Inputs ) ;
74+
75+ var includeField = GetDirectiveValue ( context , field . Directives , DirectiveGraphType . Include , variables ) ;
6876 if ( includeField . HasValue ) return ! includeField . Value ;
6977
70- var skipField = GetDirectiveValue ( context , fieldAst . Directives , DirectiveGraphType . Skip ) ;
78+ var skipField = GetDirectiveValue ( context , field . Directives , DirectiveGraphType . Skip , variables ) ;
7179 if ( skipField . HasValue ) return skipField . Value ;
7280
7381 return false ;
7482 }
7583
76- private static bool ? GetDirectiveValue ( ValidationContext context , Directives directives , DirectiveGraphType directiveType )
84+ private static bool ? GetDirectiveValue ( ValidationContext context , Directives directives , DirectiveGraphType directiveType , Variables variables )
7785 {
7886 var directive = directives . Find ( directiveType . Name ) ;
7987 if ( directive == null ) return null ;
8088
81- var operationName = context . OperationName ;
82- var documentOperations = context . Document . Operations ;
83- var operation = ! string . IsNullOrWhiteSpace ( operationName )
84- ? documentOperations . WithName ( operationName )
85- : documentOperations . FirstOrDefault ( ) ;
86-
87- var values = ExecutionHelper . GetArgumentValues (
89+ var argumentValues = ExecutionHelper . GetArgumentValues (
8890 context . Schema ,
8991 directiveType . Arguments ,
9092 directive . Arguments ,
91- ExecutionHelper . GetVariableValues ( context . Document , context . Schema , operation ? . Variables , context . Inputs ) ) ;
93+ variables ) ;
9294
93- values . TryGetValue ( "if" , out object ifObj ) ;
95+ argumentValues . TryGetValue ( "if" , out object ifObj ) ;
9496 return bool . TryParse ( ifObj ? . ToString ( ) ?? string . Empty , out bool ifVal ) && ifVal ;
9597 }
9698
0 commit comments