Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
goto-bus-stop authored Dec 1, 2023
1 parent 2003b33 commit 1afc623
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 32 deletions.
10 changes: 5 additions & 5 deletions crates/apollo-smith/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
## Documentation -->

# [x.x.x] (unreleased) - 2023-mm-dd
# [0.6.0-beta.1](https://crates.io/crates/apollo-smith/0.6.0-beta.1) - 2023-11-30

## BREAKING

- **Remove the `parser-impl` feature flag - [SimonSapin], [pull/FIXME].**
- **Remove the `parser-impl` feature flag - [SimonSapin], [pull/754].**
This functionality is now always enabled.
- **Use apollo-compiler instead of apollo-encoder for serialization - [SimonSapin], [pull/FIXME].**
- **Use apollo-compiler instead of apollo-encoder for serialization - [SimonSapin], [pull/754].**
The exact string output may change.

## Fixes

- **Make serialization ordering deterministic - [SimonSapin], [pull/FIXME].**
- **Make serialization ordering deterministic - [SimonSapin], [pull/754].**
Internally use `IndexMap` and `IndexSet` instead of `IndexMap` and `IndexSet`

[SimonSapin]: https://github.com/SimonSapin

[pull/754]: https://github.com/apollographql/apollo-rs/pull/754

# [0.5.0](https://crates.io/crates/apollo-smith/0.5.0) - 2023-10-19

Expand Down
2 changes: 1 addition & 1 deletion crates/apollo-smith/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "apollo-smith"
version = "0.5.0" # When bumping, also update README.md
version = "0.6.0-beta.1" # When bumping, also update README.md
edition = "2021"
authors = ["Benjamin Coenen <[email protected]>"]
license = "MIT OR Apache-2.0"
Expand Down
31 changes: 5 additions & 26 deletions crates/apollo-smith/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ and add `apollo-smith` to your Cargo.toml:
## fuzz/Cargo.toml

[dependencies]
apollo-smith = "0.5.0"
apollo-smith = "0.6.0-beta.1"
```

It can then be used in a `fuzz_target` along with the [`arbitrary`] crate,
Expand Down Expand Up @@ -81,15 +81,7 @@ $ cargo +nightly fuzz run my_apollo_smith_fuzz_target

## Using `apollo-smith` with `apollo-parser`

You can use `apollo-parser` to generate valid operations in `apollo-smith`. This
can be done with the `parser-impl` feature flag.

```toml
## Cargo.toml

[dependencies]
apollo-smith = { version = "0.3.1", features = ["parser-impl"] }
```
You can use `apollo-parser` to generate valid operations in `apollo-smith`.

```rust,compile_fail
use std::fs;
Expand All @@ -100,19 +92,18 @@ 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]) {
pub fn generate_valid_operation(input: &[u8]) -> Result<String> {
let parser = Parser::new(&fs::read_to_string("supergraph.graphql").expect("cannot read file"));
let tree = parser.parse();
if !tree.errors().is_empty() {
if tree.errors().next().is_some() {
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());
let apollo_smith_doc = Document::try_from(tree.document()).unwrap();
// Create a `DocumentBuilder` given an existing document to match a schema.
let mut gql_doc = DocumentBuilder::with_document(&mut u, apollo_smith_doc)?;
Expand All @@ -122,18 +113,6 @@ pub fn generate_valid_operation(input: &[u8]) {
}
```

## Feature flags
Enable `parser-impl` feature in `apollo-smith` is used to convert
`apollo-parser` types to `apollo-smith` types. This is useful when you require
the test-case generator to generate documents based on a given schema.

```toml
## Cargo.toml

[dependencies]
apollo-smith = { version = "0.3.1", features = ["parser-impl"] }
```

## Limitations
- Recursive object type not yet supported (example : `myType { inner: myType }`)

Expand Down

0 comments on commit 1afc623

Please sign in to comment.