enumPrefix = false applying to non-enum types
See original GitHub issueDescribe the bug
The enumPrefix = false config setting is stripping the prefix from non-enum types in IResolversTypes
and IResolversParentTypes
.
To Reproduce Steps to reproduce the behavior: https://codesandbox.io/s/quirky-proskuriakova-vmpz0v?file=/types.ts
- My GraphQL schema:
type Query {
user: User!
}
type User {
name: String!
}
- My GraphQL operations:
None
- My
codegen.yml
config file:
schema: schema.graphql
generates:
types.ts:
plugins:
- typescript
- typescript-resolvers
config:
typesPrefix: I
enumPrefix: false
Expected behavior
Only skip the type prefix for enum types. The type for User
should match the generated type IUser
.
export type IResolversParentTypes = {
Boolean: Scalars['Boolean'];
Query: {};
String: Scalars['String'];
User: IUser;
};
Instead of:
export type IResolversParentTypes = {
Boolean: Scalars['Boolean'];
Query: {};
String: Scalars['String'];
User: User;
};
Environment: https://codesandbox.io/s/quirky-proskuriakova-vmpz0v?file=/types.ts
"@graphql-codegen/add": "^3.1.1",
"@graphql-codegen/cli": "^2.4.0",
"@graphql-codegen/typescript": "2.4.5",
"@graphql-codegen/typescript-resolvers": "2.5.2",
"graphql": "^16.2.0"
Additional context
Also happens with typesSuffix
set and using {T}
in defaultMapper
.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7
Top Results From Across the Web
Debug - Reference Source
Assert(enumPrefix != null && enumNames != null); ... Assert(false,"Assembly, Type and Attribute records are not cached, ... IsEnum, "non enum clr type.
Read more >[Tisbury Treasure Hunt]: Feedback - Exercism/Python - IssueHint
enumPrefix = false applying to non-enum types, 7, 2022-02-18, 2022-09-18. Lots of errors executing flutter packages pub run build_runner build ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Fixed in:
@graphql-codegen/typescript-resolvers@2.5.3
@graphql-codegen/typescript@2.4.6
Confirmed for my real code that this fixes the internal mismatches in the generated types.
My full code requires setting a lot more model mappings if I remove
defaultMapper: unknown
so I have not resolved all the resolver mismatches but it looks like adding the right mappings will work now.