How to generate complete query programmatically given the query/mutation name for tests?

Hi,
I’m trying to write some tests where I want the entire query(gql) to be generated by a tool so that I can feed this to my test server to test my resolvers functionality. How can I do it? Is there any graphql tool which does this today?
Today I write it manually but this is difficult to maintain and takes time for me write given our queries contain 40-50 fields(nested) per resolver.

Hi @terabyte, are you looking to test existing queries that your clients execute or are you looking to generate queries based on your schema?

Hi @trevor.scheer I want to generate queries based on schema

I can imagine a tool which does this, but I’m not aware of one that exists. You would need to build out a tree starting from the root query fields on the Query type and branching out through the possible selection sets. One difficulty to consider is that your schema represents a graph, not a tree, so you will need to decide what happens in the recursive cases with respect to depth limit. Presumably you’d want no depth at all and to only call each resolver a minimum number of times in testing.