dotansimha / dotansimha/graphql-code-generator

Directive resolver input arguments type ignores enumPrefix = false

Open
#7,560 1 comment 0 reactions 0 assignees View on GitHub
core
Dominant language
TypeScript
Stars
11.3k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
23

Description

**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:

```graphql
enum TestEnum {
ONE
TWO
}

directive @debug(in: TestEnum) on FIELD_DEFINITION | OBJECT
```

2. My GraphQL operations:
None

3. My `codegen.yml` config file:

```yml
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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.