@@ -401,7 +401,7 @@ public final class OperationDefinition {
401401 }
402402 return . array( variableDefinitions)
403403 case " directives " :
404- guard !variableDefinitions . isEmpty else {
404+ guard !directives . isEmpty else {
405405 return nil
406406 }
407407 return . array( directives)
@@ -475,12 +475,20 @@ public final class VariableDefinition {
475475 public private( set) var variable : Variable
476476 public private( set) var type : Type
477477 public private( set) var defaultValue : Value ?
478+ public private( set) var directives : [ Directive ]
478479
479- init ( loc: Location ? = nil , variable: Variable , type: Type , defaultValue: Value ? = nil ) {
480+ init (
481+ loc: Location ? = nil ,
482+ variable: Variable ,
483+ type: Type ,
484+ defaultValue: Value ? = nil ,
485+ directives: [ Directive ] = [ ]
486+ ) {
480487 self . loc = loc
481488 self . variable = variable
482489 self . type = type
483490 self . defaultValue = defaultValue
491+ self . directives = directives
484492 }
485493
486494 public func get( key: String ) -> NodeResult ? {
@@ -491,6 +499,11 @@ public final class VariableDefinition {
491499 return . node( type)
492500 case " defaultValue " :
493501 return defaultValue. map { . node( $0) }
502+ case " directives " :
503+ guard !directives. isEmpty else {
504+ return nil
505+ }
506+ return . array( directives)
494507 default :
495508 return nil
496509 }
@@ -525,6 +538,14 @@ public final class VariableDefinition {
525538 return
526539 }
527540 self . defaultValue = defaultValue
541+ case " directives " :
542+ guard
543+ case let . array( values) = value,
544+ let directives = values as? [ Directive ]
545+ else {
546+ return
547+ }
548+ self . directives = directives
528549 default :
529550 return
530551 }
0 commit comments