Skip to content

Commit 4db05bb

Browse files
Cotofana Radujoemcbride
authored andcommitted
added support for argument fields (#17)
* added support for argument fields * use the previous value of the OperationType
1 parent 8ec6cd8 commit 4db05bb

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/GraphQL.Authorization/AuthorizationValidationRule.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using GraphQL.Language.AST;
1+
using System.Linq;
2+
using GraphQL.Language.AST;
23
using GraphQL.Types;
34
using GraphQL.Validation;
45

@@ -34,6 +35,16 @@ public INodeVisitor Validate(ValidationContext context)
3435
CheckAuth(astType, type, userContext, context, operationType);
3536
});
3637

38+
_.Match<ObjectField>(objectFieldAst =>
39+
{
40+
var argumentType = context.TypeInfo.GetArgument().ResolvedType.GetNamedType() as IComplexGraphType;
41+
if (argumentType == null)
42+
return;
43+
44+
var fieldType = argumentType.Fields.First(p => p.Name == objectFieldAst.Name);
45+
CheckAuth(objectFieldAst, fieldType, userContext, context, operationType);
46+
});
47+
3748
_.Match<Field>(fieldAst =>
3849
{
3950
var fieldDef = context.TypeInfo.GetFieldDef();

0 commit comments

Comments
 (0)