Closed rohit-gohri closed 4 years ago
Hi @rohit-smpx, this lib is more focused on generating types for back-end. If you're looking for generating types to be used in front-end, I'd recommend using apollo-tooling. Also I don't get what you mean by making it dynamically, could you elaborate?
Thanks
So, I had a use case where I was generating queries like this:
const itemId = somecondition ? 1 : 2;
const query = gql`
query{
products(id: ${id}){
nodes{
name
}
}
}
`;
apollo-tooling
only generates types for fully static queries. I was trying to get types generated for these type of queries. In the end I decided to convert everything to use variables but that ended up being a lot of work.
I think it's not feasible, because in this case the query is only available at run-time, but this library and apollo-tooling
(code-gen) generate TypeScript types, which only available at compile time. That's why both tools cannot generate types dynamically.
Cool. Thanks for clearing the doubts.
Any idea how I could use the generated types of schema to generate types for query results?
Something akin to what https://github.com/apollographql/apollo-tooling does but to do it dynamically. I would be willing to work on this if you could point in me the right direction.