All notable changes to apollo-smith will be documented in this file.
This project adheres to Semantic Versioning.
0.16.0 - 2026-07-21
Important: 6 breaking changes below, indicated by BREAKING
-
Make response generation configurable - SharkBaitDLS, tninesling, pull/1033
ResponseBuildernow supportswith_min_list_size,with_max_list_size, andwith_null_ratioto control the shape of generated responses, pluswith_generatorto register a customGeneratorfor any scalar, object, interface, or union type by name. It can also be driven by eitherarbitrary::Unstructuredor a standardrand::Rng(via the newRandProviderwrapper), so the same builder works for both fuzz testing and general-purpose mock data. The primary breaking change is thatResponseBuilderis now generic over its randomness source, and its error type changed toResponseError. -
Improve byte efficiency for type and field name generation - tninesling, pull/1040
This change makes document generation more efficient by using
Unstructured::choosewhen building type names from characters, instead of generating a randomusizeand indexing into the character set. This mitigates cases where the generator would consume all bytes in the sequence before finishing the document, resulting in only one instance of each type. There is no breaking change to the API, but it does change the name selections chosen for types and therefore changes the generated documents. -
Pass the correct directive location to input_values_def - tninesling, pull/1053
This change adds a new directive location parameter to
DocumentBuilder::input_values_def. This specifying whether it is generating an input value definition for an argument or an input object field. This is necessary to ensure that the correct directives are applied to the generated input value definition. -
Make upper bounds for type counts configurable - tninesling, pull/1054
Previously, the document generator would create up to 50 instances of each type kind. Now, you can specify the upper bound for how many of each type are generated.
let builder = DocumentBuilder::new().max_scalar_types(75);
The breaking change is that the constructor now infallibly returns a builder instead of a partial document, which allows chaining these type count bounds before document generation. In order to provide a more standardized API, the previous API's
.finish()method is replaced with the more usual.build().Before
let mut u = Unstructured::new(fuzzer_input); let gql_doc = DocumentBuilder::new(&mut u)?; let doc = gql_doc.finish();
After
let mut u = Unstructured::new(fuzzer_input); let builder = DocumentBuilder::new(&mut u); let doc = builder.build()?;
-
Prevent extensions from duplicating existing values - tninesling, pull/1057
Adds a new
excludeparameter toDocumentBuilder::enum_values_definitionandDocumentBuilder::input_values_def, plus the argument of the same name inDocumentBuilder::fields_definitionis now anIndexSetinstead of&[&Name]to match the other two.When generating the initial definition for any of these, an empty
IndexSetshould be passed. They are used internally when generating extensions to to existing types, ensuring that an extension does not duplicate some already-chosen field or value from the base definition. -
Prevent non-null self-references in input objects - tninesling, pull/1062
The
DocumentBuilder::input_values_deffunction now takes aself_name: Option<&Name>parameter so inner value definitions do not choose a non-null value of the type being generated, which would otherwise cause an impossible cycle.
- Ensure type names are unique across all type kinds - tninesling, pull/1045, pull/1058, and pull/1063
- Choose input definition types from valid input types - tninesling, pull/1046
- Ensure scalar and union extensions correctly extend original types - tninesling, pull/1047
- Ensure generated documents do not have unused fragment definitions - tninesling, pull/1048
- Allow directive applications when only one directive is defined - duckki, pull/1049
- Generate valid interface inheritance - tninesling, pull/1050
- Produce schemas with valid root operation types - tninesling, pull/1051
- Restrict union members to object types - tninesling, pull/1052
- Disable alias generation to avoid field selection merging conflicts - tninesling, pull/1059
- Fix fragment spread and argument selection merging - tninesling, pull/1060
- update dependency rust to v2 - pull/1055
- update dependency gh to v3 - pull/1056
- update rust crate anyhow to 1.0.103 - pull/1064
0.15.2 - 2025-11-10
- Return arbitrary::Error::IncorrectFormat for unsupported floats- tninesling, pull/1005
When generating floats for GraphQL documents, we were naively unwrapping the
conversion from
f64toserde_json::Number. This would panic whenarbitraryreturnedf64::INFINITYoff64::NANbecause theNumberconversion only works when its input is finite. In this case, the underlying bytes used to generate the value are considered to be in an invalid format. So, we returnarbitrary::Error::IncorrectFormatto tell fuzzers to use a different seed in the future.
- Apply new clippy rules from Rust 1.90 - goto-bus-stop, pull/1001
- bump minimum arbitrary version - goto-bus-stop, pull/1007
0.15.1 - 2025-08-08
- Implement builder for arbitrary responses - tninesling, pull/981
0.15.0 - 2025-01-16
- Update apollo-compiler dependency to stable
^1.25.0
0.14.0 - 2024-09-24
- Update apollo-compiler dependency to
=1.0.0-beta.24
0.13.0 - 2024-09-17
- Update apollo-compiler dependency to
=1.0.0-beta.23
0.12.0 - 2024-09-09
- Update apollo-compiler dependency to
=1.0.0-beta.22
0.11.0 - 2024-09-03
- Update apollo-compiler dependency to
=1.0.0-beta.21
0.10.0 - 2024-07-31
- Update apollo-parser dependency to
0.8.0 - Update apollo-compiler dependency to
=1.0.0-beta.20
0.9.0 - 2024-07-19
- Update apollo-compiler dependency to
=1.0.0-beta.19
0.8.0 - 2024-06-27
- Update apollo-compiler dependency to
=1.0.0-beta.18
0.7.0 - 2024-06-20
- Improve field variability in Selection Set generation - geal, pull/866. This changes the field generation algorithm in apollo-smith to allow more variety, because the previous implementation was the previous implementation was too biased towards the first field specified in a type. This also adds an example to generate a random query from a schema.
0.6.0-beta.1 - 2023-11-30
- Remove the
parser-implfeature flag - SimonSapin, pull/754. This functionality is now always enabled. - Use apollo-compiler instead of apollo-encoder for serialization - SimonSapin, pull/754. The exact string output may change.
- Make serialization ordering deterministic - SimonSapin, pull/754.
Internally use
IndexMapandIndexSetinstead ofIndexMapandIndexSet
0.5.0 - 2023-10-19
-
apollo-parser@0.7.0 - SimonSapin, pull/694
This updates the version of
apollo-parserrequired by theTryFromimplementations in this crate. -
removes
tryfromfrom apollo-compiler - SimonSapinapollo-compiler@1.0.0can be directly serialised to sdl without requiring apollo-encoder. thetryfromimplementation is therefore no longer necessary.
0.4.0 - 2023-08-21
-
apollo-parser@0.6.0 - goto-bus-stop, pull/621
This updates the version of
apollo-parserrequired by theTryFromimplementations in this crate. -
apollo-encoder@0.7.0 - goto-bus-stop, pull/623
This updates the version of
apollo-encoderrequired by theFromimplementations in this crate.
0.3.2 - 2023-01-18
- Derive
Cloneonapollo-smithtypes, SimonSapin in 429 - Add
DocumentBuilder::input_exhausted, SimonSapin in 430
- TryFrom for enums to use std::Result, continuation of [390], bnjjj in 428
- Break infinite loop in input string generation, SimonSapin in 427
0.3.1 - 2022-11-29
This is a re-publish of 0.3.0 with fixed dependency versions.
0.3.0 - 2022-11-29 (YANKED)
-
make conversions from apollo-parser types fallible - goto-bus-stop, pull/371
The
parser-implfeature flag contains conversion code from apollo-parser AST node types to apollo-smith types. With this change, those conversions now use theTryFromtrait instead of theFromtrait, and return errors instead of panicking.You now have to use the
try_from()andtry_into()methods instead offrom()andinto().
0.2.0 - 2022-11-08
-
update apollo-parser@0.3.x - lrlna, pull/340, pull/348
This change was first released in the apollo-smith@0.1.4 patch release. It should have been a breaking change, as the update to the new version requires users to also update apollo-parser to 0.3.0 at the same time.
This version is identical to 0.1.5 except for the version number. apollo-smith versions 0.1.4 and 0.1.5 have been yanked.
0.1.5 - 2022-11-04 (YANKED)
0.1.4 - 2022-11-04 (YANKED)
0.1.3 - 2022-05-12
-
add interface definition to internal stack - bnjjj, pull/213
Added support of interface definition in the stack to fill an operation with correct fields.
0.1.2 - 2022-04-28
- Update apollo-encoder to 0.3.0 - lrlna, pull/207 pull/208
apollo-encoder's 0.3.0 changesdesciptionanddefault-valuesetters to accept String as a parameter. This changes the internals of apollo-smith accordingly.
0.1.1 - 2022-04-01
-
Add
parser-implfeature flag - bnjjj, pull/197parser-implfeature inapollo-smithis used to convertapollo-parsertypes toapollo-smithtypes. This is useful when you require the test-case generator to generate documents based on a given schema.## Cargo.toml [dependencies] apollo-smith = { version = "0.1.1", features = ["parser-impl"] }
use std::fs; use apollo_parser::Parser; use apollo_smith::{Document, DocumentBuilder}; use libfuzzer_sys::arbitrary::{Result, Unstructured}; /// This generate an arbitrary valid GraphQL operation pub fn generate_valid_operation(input: &[u8]) { let parser = Parser::new(&fs::read_to_string("supergraph.graphql").expect("cannot read file")); let tree = parser.parse(); if !tree.errors().is_empty() { panic!("cannot parse the graphql file"); } let mut u = Unstructured::new(input); // Convert `apollo_parser::Document` into `apollo_smith::Document`. let apollo_smith_doc = Document::from(tree.document()); // Create a `DocumentBuilder` given an existing document to match a schema. let mut gql_doc = DocumentBuilder::with_document(&mut u, apollo_smith_doc)?; let operation_def = gql_doc.operation_definition()?.unwrap(); Ok(operation_def.into()) }
-
Introduces semantic validations to the test-case generation - bnjjj, pull/197
Semantic validations currently include:
- Directives used in the document must already be defined
- Directives must be unique in a given Directive Location
- Default values must be of correct type
- Input values must be of correct type
- All type extensions are applied to an existing type
- Field arguments in fragments and operation definitions must be defined on original type and must be of correct type
0.1.0 - 2021-02-18
Introducing apollo-smith!
The goal of apollo-smith is to generate valid GraphQL documents by sampling
from all available possibilities of GraphQL grammar.
We've written apollo-smith to use in fuzzing, but you may wish to use it for
anything that requires GraphQL document generation.
apollo-smith is inspired by bytecodealliance's wasm-smith crate, and the
article written by Nick Fitzgerald on writing test case generators in Rust.
This is still a work in progress, for outstanding issues, checkout out the apollo-smith label in our issue tracker.