shurcooL / graphql

Package graphql provides a GraphQL client implementation.
MIT License
708 stars 282 forks source link

export GenerateQueryFields method. #16

Closed eric-am closed 6 years ago

eric-am commented 6 years ago

Sometimes I'm finding it useful to write queries manually, because the overall structure of a query is customized in some way, but it uses all the same types as other queries. Even in this situation, though, it turns out that since most of the types are the same, the graphql generated for those structs is all valid; it's just the top level composition of those fields that I'm interested in customizing.

So! It would be very nice if I could generate the graphql fields description for some of my types, and just handle that as a string, so I can compose it freely.

The functionality is exactly as before -- this method already exists, walks a Go type with reflect, and generates a graphql description of it. That graphql description string already happens to be fairly composable. The only novelty is exporting it and trying to provide some documentation of it :)

(This is pretty useless without https://github.com/shurcooL/graphql/pull/14 , despite being technically independent.)