I am using graphql-codegen/typescript-apollo-angular
to generate typescript code can be useed in our Angular application.
We decided to enable strictNullChecks
the only issue is that we use the following pattern to specify the types of inner nodes that are returned by the API:
type ListSomethingEdge = ListSomethingQuery["something"]["edges"][0];
In my case something
is generated as a Maybe<Array<...>>
which is correct.
When I enable strictNullChecks
the above code does not work anymore as something might be undefined / null as well.
Property 'edges' does not exist on type '({ __typename?: "SomethingConnection" | undefined; } & Pick<SomethingConnection, "totalCount"> & { edges?: Maybe<{ __typename?: "SomethingEdge" | undefined; } & { ...; }>[] | null | undefined; pageInfo: { ...; } & Pick<...>; }) | null | undefined'.ts(2339)
I was unable to find documentation on how to remove null
/ undefined
types from a type alias like this. Maybe there is a different way to do this.