Skip to content

Commit 467c4e0

Browse files
committed
temp
1 parent 601cdb8 commit 467c4e0

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

crates/apollo-smith/src/next/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ pub(crate) fn generate_executable_document(
135135
let mut doc = Document::new();
136136
let mut executable_document = doc.to_executable(schema).expect("initial document must be valid");
137137
let mutations = mutations::executable_document_mutations();
138-
for _ in 0..1000 {
138+
for _ in 0..10 {
139139
if u.len() == 0 {
140140
// We ran out of data abort. This is not an error
141141
return Err(Error::Arbitrary(arbitrary::Error::NotEnoughData))?;
@@ -190,6 +190,7 @@ pub(crate) fn generate_executable_document(
190190
}
191191
}
192192
}
193+
println!("Generated executable document: {}\n for schema {}", doc, schema);
193194

194195
Ok(doc)
195196
}

crates/apollo-smith/src/next/unstructured.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)