@@ -78,6 +78,7 @@ public func graphql(
78
78
mutationStrategy: MutationFieldExecutionStrategy = SerialFieldExecutionStrategy ( ) ,
79
79
subscriptionStrategy: SubscriptionFieldExecutionStrategy = SerialFieldExecutionStrategy ( ) ,
80
80
instrumentation: Instrumentation = NoOpInstrumentation,
81
+ validationRules: [ ( ValidationContext ) -> Visitor ] = [ ] ,
81
82
schema: GraphQLSchema ,
82
83
request: String ,
83
84
rootValue: Any = ( ) ,
@@ -89,7 +90,7 @@ public func graphql(
89
90
90
91
let source = Source ( body: request, name: " GraphQL request " )
91
92
let documentAST = try parse ( instrumentation: instrumentation, source: source)
92
- let validationErrors = validate ( instrumentation: instrumentation, schema: schema, ast: documentAST)
93
+ let validationErrors = validate ( instrumentation: instrumentation, schema: schema, ast: documentAST, rules : validationRules )
93
94
94
95
guard validationErrors. isEmpty else {
95
96
return eventLoopGroup. next ( ) . makeSucceededFuture ( GraphQLResult ( errors: validationErrors) )
@@ -195,6 +196,7 @@ public func graphqlSubscribe(
195
196
mutationStrategy: MutationFieldExecutionStrategy = SerialFieldExecutionStrategy ( ) ,
196
197
subscriptionStrategy: SubscriptionFieldExecutionStrategy = SerialFieldExecutionStrategy ( ) ,
197
198
instrumentation: Instrumentation = NoOpInstrumentation,
199
+ validationRules: [ ( ValidationContext ) -> Visitor ] = [ ] ,
198
200
schema: GraphQLSchema ,
199
201
request: String ,
200
202
rootValue: Any = ( ) ,
@@ -206,7 +208,7 @@ public func graphqlSubscribe(
206
208
207
209
let source = Source ( body: request, name: " GraphQL Subscription request " )
208
210
let documentAST = try parse ( instrumentation: instrumentation, source: source)
209
- let validationErrors = validate ( instrumentation: instrumentation, schema: schema, ast: documentAST)
211
+ let validationErrors = validate ( instrumentation: instrumentation, schema: schema, ast: documentAST, rules : validationRules )
210
212
211
213
guard validationErrors. isEmpty else {
212
214
return eventLoopGroup. next ( ) . makeSucceededFuture ( SubscriptionResult ( errors: validationErrors) )
0 commit comments