Skip to content

Commit 027a126

Browse files
committed
temp
1 parent 467c4e0 commit 027a126

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,21 @@ pub enum Error {
1919

2020
#[error("schema document validation failed")]
2121
SchemaDocumentValidation {
22+
mutation: String,
2223
doc: Document,
2324
errors: WithErrors<Schema>,
2425
},
2526

2627
#[error("executable document validation failed")]
2728
ExecutableDocumentValidation {
29+
mutation: String,
2830
doc: Document,
2931
schema: Valid<Schema>,
3032
errors: WithErrors<ExecutableDocument>,
3133
},
3234

3335
#[error("validation passed, but should have failed")]
34-
SchemaExpectedValidationFail { doc: Document, mutation: String },
36+
SchemaExpectedValidationFail { mutation: String, doc: Document },
3537

3638
#[error("the serialized AST did not round trip to an identical AST")]
3739
SerializationInconsistency { original: Document, new: Document },
@@ -48,12 +50,14 @@ pub enum Error {
4850

4951
#[error("reparse error")]
5052
SchemaReparse {
53+
mutation: String,
5154
doc: Document,
5255
errors: WithErrors<Document>,
5356
},
5457

5558
#[error("reparse error")]
5659
ExecutableReparse {
60+
mutation: String,
5761
schema: Valid<Schema>,
5862
doc: Document,
5963
errors: WithErrors<Document>,
@@ -89,6 +93,7 @@ pub fn generate_schema_document(u: &mut Unstructured) -> Result<Document, Error>
8993
// Let's reparse the document to check that it can be parsed
9094
let reparsed = Document::parse(new_doc.to_string(), PathBuf::from("synthetic"))
9195
.map_err(|e| Error::SchemaReparse {
96+
mutation: mutation.type_name().to_string(),
9297
doc: new_doc.clone(),
9398
errors: e,
9499
})?;
@@ -109,6 +114,7 @@ pub fn generate_schema_document(u: &mut Unstructured) -> Result<Document, Error>
109114
}
110115
(true, Err(e)) => {
111116
return Err(Error::SchemaDocumentValidation {
117+
mutation: mutation.type_name().to_string(),
112118
doc: new_doc,
113119
errors: e,
114120
});
@@ -154,6 +160,7 @@ pub(crate) fn generate_executable_document(
154160
// Let's reparse the document to check that it can be parsed
155161
let reparsed = Document::parse(new_doc.to_string(), PathBuf::from("synthetic"))
156162
.map_err(|e| Error::ExecutableReparse {
163+
mutation: mutation.type_name().to_string(),
157164
schema: schema.clone(),
158165
doc: new_doc.clone(),
159166
errors: e,
@@ -173,15 +180,16 @@ pub(crate) fn generate_executable_document(
173180
}
174181
(true, Err(e)) => {
175182
return Err(Error::ExecutableDocumentValidation {
183+
mutation: mutation.type_name().to_string(),
176184
doc: new_doc,
177185
schema: schema.clone(),
178186
errors: e,
179187
});
180188
}
181189
(false, Ok(_)) => {
182190
return Err(Error::SchemaExpectedValidationFail {
183-
doc: new_doc,
184191
mutation: mutation.type_name().to_string(),
192+
doc: new_doc,
185193
});
186194
}
187195
(false, Err(_)) => {

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ impl Unstructured<'_> {
144144
) -> Result<ObjectTypeDefinition> {
145145
let implements = schema.sample_interface_types(self)?;
146146
let implements_fields = Self::all_fields_from_interfaces(&implements);
147+
println!("implements: {:?}", implements);
148+
println!("implements_fields: {:?}", implements_fields);
147149
let new_fields = self.arbitrary_vec(1, 5, |u| {
148150
Ok(Node::new(u.arbitrary_field_definition(
149151
schema,
@@ -285,6 +287,9 @@ impl Unstructured<'_> {
285287
// All interfaces need to have all the fields from the interfaces they implement.
286288
let implements = schema.sample_interface_types(self)?;
287289
let implements_fields = Self::all_fields_from_interfaces(&implements);
290+
println!("implements: {:?}", implements);
291+
println!("implements_fields: {:?}", implements_fields);
292+
288293
let new_fields = self.arbitrary_vec(1, 5, |u| {
289294
Ok(Node::new(u.arbitrary_field_definition(
290295
schema,

fuzz/fuzz_targets/parser_next.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,44 +31,50 @@ fuzz_target!(|data: &[u8]| {
3131
new.to_string()
3232
);
3333
}
34-
Error::SchemaDocumentValidation { doc, errors } => {
34+
Error::SchemaDocumentValidation {mutation, doc, errors } => {
3535
println!(
36-
"{}\ndoc:\n{}\nerrors:\n{}",
36+
"{}\nmutation:\n{}\ndoc:\n{}\nerrors:\n{}",
3737
e,
38+
mutation,
3839
doc.to_string(),
3940
errors.errors
4041
);
4142
}
42-
Error::SchemaReparse { doc, errors } => {
43+
Error::SchemaReparse { mutation, doc, errors } => {
4344
println!(
44-
"{}\ndoc:\n{}\nerrors:\n{}",
45+
"{}\nmutation:\n{}\ndoc:\n{}\nerrors:\n{}",
4546
e,
47+
mutation,
4648
doc.to_string(),
4749
errors.errors
4850
);
4951
}
5052

5153
Error::ExecutableReparse {
54+
mutation,
5255
schema,
5356
doc,
5457
errors,
5558
} => {
5659
println!(
57-
"{}\ndoc:\n{}\nschema:\n{}\nerrors:\n{}",
60+
"{}\nmutation:\n{}\ndoc:\n{}\nschema:\n{}\nerrors:\n{}",
5861
e,
62+
mutation,
5963
doc.to_string(),
6064
schema.to_string(),
6165
errors.errors
6266
);
6367
}
6468
Error::ExecutableDocumentValidation {
69+
mutation,
6570
doc,
6671
schema,
6772
errors,
6873
} => {
6974
println!(
70-
"{}\ndoc\n{}\nschema:\n{}\nerrors:\n{}",
75+
"{}\nmutation:\n{}\ndoc\n{}\nschema:\n{}\nerrors:\n{}",
7176
e,
77+
mutation,
7278
doc.to_string(),
7379
schema.to_string(),
7480
errors.errors

0 commit comments

Comments
 (0)