@@ -312,14 +312,14 @@ impl Unstructured<'_> {
312312 }
313313
314314 fn all_fields_from_interfaces (
315- implements : & Vec < & Node < InterfaceType > > ,
315+ interfaces : & Vec < & Node < InterfaceType > > ,
316316 ) -> Vec < Node < FieldDefinition > > {
317- let implements_fields = implements
317+ let all_fields = interfaces
318318 . iter ( )
319319 . flat_map ( |interface| interface. fields . values ( ) )
320320 . map ( |field| field. deref ( ) . clone ( ) )
321321 . collect :: < Vec < _ > > ( ) ;
322- implements_fields
322+ all_fields
323323 }
324324
325325 pub ( crate ) fn arbitrary_field_definition (
@@ -439,9 +439,15 @@ impl Unstructured<'_> {
439439 executable_document : & ExecutableDocument ,
440440 name : Option < Name > ,
441441 ) -> Result < OperationDefinition > {
442- let operation = schema. random_query_mutation_subscription ( self ) ?;
442+ let object = schema. random_query_mutation_subscription ( self ) ?;
443+ let directive_location = match object. name . as_ref ( ) {
444+ "Query" => DirectiveLocation :: Query ,
445+ "Mutation" => DirectiveLocation :: Mutation ,
446+ "Subscription" => DirectiveLocation :: Subscription ,
447+ _ => panic ! ( "invalid object name" ) ,
448+ } ;
443449 Ok ( OperationDefinition {
444- operation_type : operation
450+ operation_type : object
445451 . deref ( )
446452 . operation_type ( )
447453 . expect ( "top level operation must have type" ) ,
@@ -450,12 +456,10 @@ impl Unstructured<'_> {
450456 directives : schema
451457 . sample_directives ( self ) ?
452458 . into_iter ( )
453- . with_location ( DirectiveLocation :: Field )
454- // skip and include are not allowed on operations
455- . filter ( |d| d. name != "skip" && d. name != "include" )
459+ . with_location ( directive_location)
456460 . try_collect ( self , schema) ?,
457461 selection_set : self . arbitrary_vec ( 1 , 5 , |u| {
458- Ok ( u. arbitrary_selection ( schema, operation . deref ( ) , executable_document) ?)
462+ Ok ( u. arbitrary_selection ( schema, object . deref ( ) , executable_document) ?)
459463 } ) ?,
460464 } )
461465 }
0 commit comments