dotansimha/graphql-code-generator

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

Open

#4,249 opened on Jun 17, 2020

View on GitHub
 (2 comments) (4 reactions) (0 assignees)TypeScript (10,341 stars) (1,295 forks)batch import
corehelp wantedpluginsstage/1-reproduction

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

Contributor guide