File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -207,4 +207,32 @@ class ParseAndValidateTest extends Specification {
207207 error. message == " Validation error (UnknownOperation): The 'Subscription' operation is not supported by the schema"
208208 error. locations == [new SourceLocation (1 , 1 )]
209209 }
210+
211+ def " known operation validation rule checks all operations in document" () {
212+ def sdl = '''
213+ type Query {
214+ myQuery : String!
215+ }
216+ '''
217+
218+ def registry = new SchemaParser (). parse(sdl)
219+ def schema = UnExecutableSchemaGenerator . makeUnExecutableSchema(registry)
220+ String request = " mutation MyMutation { myMutation } subscription MySubscription { mySubscription }"
221+
222+ when :
223+ Document inputDocument = new Parser (). parseDocument(request)
224+ List<ValidationError > errors = ParseAndValidate . validate(schema, inputDocument)
225+
226+ then :
227+ errors. size() == 2
228+ def error1 = errors. get(0 )
229+ error1. validationErrorType == ValidationErrorType.UnknownOperation
230+ error1. message == " Validation error (UnknownOperation): The 'Mutation' operation is not supported by the schema"
231+ error1. locations == [new SourceLocation (1 , 1 )]
232+
233+ def error2 = errors. get(1 )
234+ error2. validationErrorType == ValidationErrorType.UnknownOperation
235+ error2. message == " Validation error (UnknownOperation): The 'Subscription' operation is not supported by the schema"
236+ error2. locations == [new SourceLocation (1 , 36 )]
237+ }
210238}
You can’t perform that action at this time.
0 commit comments