dotansimha/graphql-code-generator

set typesPrefix with enumPrefix doesn't work with typescript-resolvers

Open

#4 249 ouverte le 17 juin 2020

Voir sur GitHub
 (2 commentaires) (4 réactions) (0 assignés)TypeScript (1 295 forks)batch import
corehelp wantedpluginsstage/1-reproduction

Métriques du dépôt

Stars
 (10 341 stars)
Métriques de merge PR
 (Merge moyen 46j 1h) (11 PRs mergées en 30 j)

Description

Describe the bug

When enumPrefix is set to false typescript-resolver doesn't use prefixed type name even if typesPrefix is set to T.

To Reproduce Steps to reproduce the behavior:

  1. set enumPrefix to false
  2. set typesPrefix to T
  3. graphql-codegen

Here is codesandbox.

https://codesandbox.io/s/quirky-proskuriakova-yyexo?file=/types.ts

  1. My GraphQL schema:
# Put your schema here
type Query {
    user(id: ID!): User!
}

type User {
    id: ID!
    username: String!
    email: String!
}
  1. My GraphQL operations: (Not related to this issue)
query user {
    user(id: 1) {
        id
        username
        email
    }
}
# Put your operations here
  1. My codegen.yml config file:
schema: schema.graphql
documents: document.graphql
generates:
  types.ts:
    config:
      typesPrefix: T
      enumPrefix: false
    plugins:
      - typescript
      - typescript-operations
      - typescript-resolvers

# Put your YML here

Expected behavior

generated resolver type should use prefixed type.

Environment:

  • OS: macOS 10.15.4 catalina
  • "@graphql-codegen/cli": "^1.15.3",
  • "@graphql-codegen/typescript": "^1.15.3",
  • "@graphql-codegen/typescript-resolvers": "^1.15.3"
  • NodeJS: v10.20.1

Additional context

Guide contributeur