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

[BUG] filter_query hook isn't called with graphql schema

devkral opened this issue · comments

Describe the bug

maybe it is my workaround to unfold the get_all_operations hook of a graphql schema to have APIOperations for the search strategy generation for unittests but in my case somehow the

filter_query hook isn't called.
I put a print statement in it. Example comes later

Indeed, at the moment it is called only for body, my line of thinking was that as we only generate body, then only body-related hooks should be called.

However, I think, even if Schemathesis does not generate data for query / cookies / headers, it should still be possible for the user to pass something manually. For example:

@schemathesis.hook
def map_query(context, query):
    # `query` is always `None` here as we don't generate anything
    return {"user_id": 101}

So, we can just behave the same way as with Open API - even if query / cookies / headers are not generated, we have default values and they are passed to hooks.

Working on a fix