Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Directive resolver input arguments type ignores enumPrefix = false #7560

Open
Tracked by #8296 ...
bmarker opened this issue Feb 18, 2022 · 1 comment
Open
Tracked by #8296 ...

Directive resolver input arguments type ignores enumPrefix = false #7560

bmarker opened this issue Feb 18, 2022 · 1 comment
Labels
core Related to codegen core/cli

Comments

@bmarker
Copy link

bmarker commented Feb 18, 2022

Describe the bug
The generated directive arguments ignore enumPrefix = false. This results in the wrong type name when typesPrefix is set.

To Reproduce
https://codesandbox.io/s/pedantic-lalande-q0g1qr?file=/types.ts

Set enumPrefix = false and typesPrefix = I.

Define a directive with an input argument that is an enum and generate the resolvers.

  1. My GraphQL schema:
enum TestEnum {
    ONE
    TWO
}

directive @debug(in: TestEnum) on FIELD_DEFINITION | OBJECT
  1. My GraphQL operations:
    None

  2. My codegen.yml config file:

schema: schema.graphql
generates:
  types.ts:
    plugins:
      - typescript
      - typescript-resolvers
    config:
      typesPrefix: I
      enumPrefix: false
      defaultMapper: unknown

Setting defaultMapper works around another name collision with the default IResolversTypes and IResolversParentTypes. Normally I'd map the model types.

Expected behavior
Does not add the types prefix to the enum type in the input args type for the directive resolver.

Environment:
https://codesandbox.io/s/pedantic-lalande-q0g1qr?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
I don't actually need the directives so a skip directives option would work as well.
I may be able to get a hook to rename it as a workaround for now.

@bmarker
Copy link
Author

bmarker commented Feb 18, 2022

Specifically generating this code:

export type IDebugDirectiveArgs = {
  in?: Maybe<ITestEnum>;
};

Instead of this code:

export type IDebugDirectiveArgs = {
  in?: Maybe<TestEnum>;
};

@charlypoly charlypoly added the core Related to codegen core/cli label Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Related to codegen core/cli
Projects
None yet
Development

No branches or pull requests

2 participants