schemathesis / schemathesis

Supercharge your API testing, catch bugs, and ensure compliance

Home Page:https://schemathesis.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[FEATURE] graphql not required handling

devkral opened this issue · comments

Currently when fields in graphql schemas are not required, schemathesis can send null to them.
According to the graphql specs this is valid and it is useful to find bugs.

But sometimes it would be easier to not send null values

Is there a way to turn the null value sending behavior off? It would be nice to have a simple switch for it

I see it this way.

First, it should be added to hypothesis-graphql, ie. some argument to the strategy factories like allow_null: bool = True, then store it on the GraphQLStrategy instance and use it here to enforce non-nullability during data generation (i.e. before passing this to primitives.scalar, etc)

Second, this option should be added to Schemathesis CLI & other entry points to propagate it down via as_strategy to hypothesis-graphql