graphql-code-generator icon indicating copy to clipboard operation
graphql-code-generator copied to clipboard

Support auto selecting ids in typescript-operations

Open tbezman opened this issue 2 years ago • 1 comments

Is your feature request related to a problem? Please describe.

I'm always frustrated when I use @graphql-codegen/typescript-operations to generate mock types for my Relay queries. It's frustrating because Relay will automatically select the id field behind the scenes if your type has one, but the generated types from typescript-operations do not include the id field.

This leads to me drop a bunch of @ts-expect-errors in my test files which actually make the entire object not type safe.

Describe the solution you'd like

I'd like typescript-operations to automatically include the id in the selection set if the type allows for it.k

Describe alternatives you've considered

I haven't thought of any.

Additional context

I've taken a stab at an implementation in this PR

I created a repro of this problem in this repo.

Steps to repro

  1. Clone that repo
  2. yarn install
  3. yarn jest
  4. See the following error image

tbezman avatar May 25 '22 20:05 tbezman

can we please get support for this?

Robinnnnn avatar Aug 19 '22 04:08 Robinnnnn