question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

enumPrefix = false applying to non-enum types

See original GitHub issue

Describe 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

  1. My GraphQL schema:
type Query {
    user: User!
}

type User {
    name: String!
}
  1. My GraphQL operations:

None

  1. 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:closed
  • Created 2 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
charlypolycommented, Mar 9, 2022

Fixed in:

  • @graphql-codegen/typescript-resolvers@2.5.3
  • @graphql-codegen/typescript@2.4.6
0reactions
bmarkercommented, Mar 9, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found