dotansimha / dotansimha/graphql-code-generator
Reserved keywords naming conflict e.g. TypeScript's `Record`, GraphQL's `Subscription`
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 1.4k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 23
Description
### Which packages are impacted by your issue?
@graphql-codegen/typescript-resolvers
### Describe the bug
If you have a type named `Subscription`:
```
type Query {
subscriptions: [Subscription]
}
type Subscription {
name: String
}
```
The generated output becomes:
```
export type QueryResolvers = {
subscriptions?: Resolver>>, ParentType, ContextType>;
};
export type SubscriptionResolvers = {
name?: SubscriptionResolver, "name", ParentType, ContextType>; // wrong
};
export type Resolvers = {
Query?: QueryResolvers;
Subscription?: SubscriptionResolvers;
};
```
This is wrong. The `name` field should be a `Resolver` instead of `SubscriptionResolver`.
### Your Example Website or App
https://codesandbox.io/p/sandbox/youthful-fermat-cg7ppp?file=%2Ftypes.ts&selection=%5B%7B%22endColumn%22%3A30%2C%22endLineNumber%22%3A133%2C%22startColumn%22%3A10%2C%22startLineNumber%22%3A133%7D%5D
### Steps to Reproduce the Bug or Issue
1. Open the sandbox.
2. Run `yarn generate`
3. Go to the `types.ts` file and see the wrong type.
### Expected behavior
The `name` field should be a `Resolver` instead of `SubscriptionResolver`.
### Screenshots or Videos
_No response_
### Platform
"@graphql-codegen/cli": "^2.16.4",
"@graphql-codegen/typescript": "^2.8.7",
"@graphql-codegen/typescript-resolvers": "^2.7.12",
### Codegen Config File
```
schema: "./schema.graphql"
generates:
types.ts:
plugins:
- "typescript"
- "typescript-resolvers"
```
### Additional context
_No response_
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.