apollographql / apollo-rs

Spec compliant GraphQL Tools in Rust.
Apache License 2.0
566 stars 43 forks source link

apollo-smith: more varied fields generation #866

Closed Geal closed 3 months ago

Geal commented 3 months ago

This changes the field generation algorithm in apollo-smith to allow more variety, because 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.

One thing that comes out of these tests is that we need the input data for Arbitrary to be large enough, otherwise once it has no more bytes to consume, it returns 0 every time and the selections get no more variations

lrlna commented 3 months ago

This does make the snapshots fail, and I think that failure is legit. We should have some fields in the operation's selection set and the fragment's selection set

Geal commented 3 months ago

you're right, I messed up the lower bound of the range. I set it to at least 1 selection instead of 2 and updated the snapshots. We do not lose much by doing that