dotansimha / dotansimha/graphql-code-generator-community
Incomplete type annotation for apollo's KeySpecifier type
- Dominant language
- TypeScript
- Stars
- 137
- Forks
- 195
- Avg merge
- 6h 20m
- Merged PRs (30d)
- 16
Description
### Which packages are impacted by your issue?
@graphql-codegen/typescript-apollo-client-helpers
### Describe the bug
There is a disconnect i.e. a missing type between the type generated for `KeySpecifier` and apollo's [actual interface](https://github.com/apollographql/apollo-client/blob/4e147b579bff210dbbc884d918edb1e69c2cfa9f/src/cache/inmemory/policies.ts#L112).
### Your Example Website or App
https://codesandbox.io/s/bug-gqlgen-apollo-keyspecifier-type-mismatch-wgjgkj?file=/repro.ts
### Steps to Reproduce the Bug or Issue
For example, considering the schema
```gql
type T {
Foo: String
Bar: String
}
```
After running the `typescript-apollo-client-helpers`, plugin, it would generate the following type policy for `T`:
```ts
export type TKeySpecifier = ('Foo' | 'Bar' | TKeySpecifier)[];
export type TFieldPolicy = { /* irrelevant to this issue */ };
```
### Expected behavior
Considering the [actual type shape](https://github.com/apollographql/apollo-client/blob/4e147b579bff210dbbc884d918edb1e69c2cfa9f/src/cache/inmemory/policies.ts#L112) for the `keyFields` property —which includes a function to generate a type's `keyField`— I would expect the following type annotation:
```ts
export type TKeySpecifier = ('Foo' | 'Bar' | TKeySpecifier | (o: Readonly, context: KeyFieldsContext) => string)[];
```
### Screenshots or Videos
_No response_
### Platform
- OS: macOS
- NodeJS: 16.4
- `graphql` version: 15.5.0
- `@graphql-codegen/*` version(s): 2.6.1
### Codegen Config File
_No response_
### Additional context
_No response_
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.