Open karolzlot opened 3 years ago
The main reason they're a Go value is so that you can access the query response by using that Go value. Other approaches are certainly possible and can be explored. I don't have plans to work on this myself.
@dmitshur I see your point.
I wonder about one thing: would it be possible to make transpiler which would convert GrapQL query to correct golang types? It seems to me that it is reapeatable work which can be automated, but I am not sure.
How do you think?
Yes, a GraphQL query → Go type tool (with a UI similar to https://mholt.github.io/json-to-go/; CC @mholt) is very possible and likely a good idea, as it'd help eliminate the manual work involved in those conversions. It would need a parser for GraphQL queries, and those exist now. I had this idea at the start of the project, but haven't had a chance to implement it myself. It'd be great if someone makes such a tool.
While I would love a graphql-to-go for clients like gqlgen for servers, even if I had it now, there are some times I would like the option to bypass the struct tag solution for the outermost operation name and variable definitions in queries.
Specifically, I find that for long operation names and long lists of variable definitions, having that as a struct tag gets unwieldy (1024+ character go struct lines?).
I can dynamically alter the struct tag to load the query from a file, but I feel like there's probably something much simpler that could be exposed to facilitate this specific use case.
I see that currently this library requires every query to be a "golang type".
It is not possible to use graphql string (or file) with ready to use query.
I am generating queries in Hasura, so I really don't need to convert them do golang types, I think.
WDYT?