https://prefect.io logo
Title
z

Zachary Hughes

02/02/2020, 12:33 AM
Hi @Alex Cano, great question! 100% agree that there's a lot of surface area to test, here are some tips from what we do: • we use Hasura to manage all of queries. This is helpful because it handles a lot of the grunt work for us, but we still need to test it. To that end, we have tests to ensure each of our entities (for example, flows and flow runs) are properly relating to each other, that they're displaying the proper fields, and that they can only be viewed by the appropriate users. • beyond what's handled by Hasura, we have several additional layers of testing. We test to ensure that we're surfacing the correct fields, that we sanitize and handle erroneous input, that any non-Hasura permissions are correctly applied, our models look like we expect them to, etc. We start small with unit tests for each individual model/piece of functionality, then work our way up to larger integration tests. (And
pytest.mark.parametrize
is definitely our friend) TL;DR Test that fields are being surfaced as expected, test object relationships, and test permissions. Happy to go deeper/broader if you'd like (we have an inordinate number of tests), but these were the items I found most useful when starting out with GraphQL.
:upvote: 4
:prefect: 1
👨‍🎓 4
a

Alex Cano

02/02/2020, 12:46 AM
That’s awesome! Thanks for so much detail! I was initially worried about the sheer amount of surface area when testing a GQL API! Thanks for the insight