genql: Types regression: Field selection not working anymore

The latest version 1.1.21 does not correctly create selected fields types matching the query. The whole type is returned instead. The last working version that I know of is 1.0.58. See images below

v1.0.58 Screen Shot 2020-07-13 at 09 29 09

v1.1.21 Screen Shot 2020-07-13 at 09 23 03

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 20 (17 by maintainers)

Most upvoted comments

Now that typescript 4.0 added recursive types support this has become feasible

The problem was that it’s difficult to do the type inference from the query to the response is difficult because of the fields that start with the on_ prefix

I will think of a good way to implement this, stay tuned 😜

@remorses Really excited for version 2! Thanks for your awesome work on this project

I just ran into a bug in the app I’m working on where I’d accidentally forgot to include a field as part of a query but the types don’t help here so when handling the result I assumed that the value was actually there. I so badly want to use a TS GQL client that allows for fluent and type safe query building but not having safety on the structure of the query result may be a deal breaker for me continuing to use this library. It’s a bit more overhead but at this point I’m considering going back to using graphql-code-generator with named GQL operations to get the right type safety.

I’ve tried a bunch of different tools now including GraphQL Zeus but GenQL seems to have the most potential but this feels like a huge loss to me. Do you think there’s anyway that the type inference speed could be fixed or is it a limitation of the current state of TypeScript to be able to consider including this functionality?