@@ -289,6 +289,21 @@ func validateArgs(schema *Schema, args ArgumentDefinitionList, currentDirective
289289 return nil
290290}
291291
292+ func validateDirectiveArgs (dir * Directive , schema * Schema ) * gqlerror.Error {
293+ allowedArgs := make (map [string ]struct {})
294+ for _ , arg := range schema .Directives [dir .Name ].Arguments {
295+ allowedArgs [arg .Name ] = struct {}{}
296+ }
297+
298+ for _ , arg := range dir .Arguments {
299+ if _ , ok := allowedArgs [arg .Name ]; ! ok {
300+ return gqlerror .ErrorPosf (dir .Position , "%s is not supported as an argument for %s directive." , arg .Name , dir .Name )
301+ }
302+ }
303+ return nil
304+
305+ }
306+
292307func validateDirectives (schema * Schema , dirs DirectiveList , location DirectiveLocation , currentDirective * DirectiveDefinition ) * gqlerror.Error {
293308 for _ , dir := range dirs {
294309 if err := validateName (dir .Position , dir .Name ); err != nil {
@@ -301,6 +316,9 @@ func validateDirectives(schema *Schema, dirs DirectiveList, location DirectiveLo
301316 if schema .Directives [dir .Name ] == nil {
302317 return gqlerror .ErrorPosf (dir .Position , "Undefined directive %s." , dir .Name )
303318 }
319+ if err := validateDirectiveArgs (dir , schema ); err != nil {
320+ return err
321+ }
304322 validKind := false
305323 for _ , dirLocation := range schema .Directives [dir .Name ].Locations {
306324 if dirLocation == location {
0 commit comments