gql-generator icon indicating copy to clipboard operation
gql-generator copied to clipboard

Using programmatically

Open samhatoum opened this issue 6 years ago • 3 comments

Thanks for writing this.

Is there a way to use this programmatically instead of writing files?

I would love to use this tool + https://github.com/marak/Faker.js to use the field types in the schema to generate a query with random data :)

samhatoum avatar Dec 12 '18 16:12 samhatoum

This tool generates general queries accepting variables as the query argument. In your case, you can generate random data as the variables. However, this tool did not tell you what the possible variables a query accepts, you might need to get this info by other ways.

timqian avatar Dec 13 '18 02:12 timqian

What Sam is asking about is whether there is a way of generating and running the queries on-the-fly instead of writing to files first and then importing. I imagine there is no easy way to do so now, but it shouldn't be too hard to add that option.

lgandecki avatar Dec 13 '18 10:12 lgandecki

For reference, I ran into the same question and I adopted the code so queries can be generated programmatically. Moreover, it runs with more clever arguments dedupe algorithm (symbol23 -> amar_symbolB) and request fields might be customized (useful with fragments resolvers). https://github.com/Skitionek/gql-generator-node

Skitionek avatar Jun 06 '19 14:06 Skitionek