Graphql-code-generator: Type suffix placed incorrectly in query variables type

Created on 29 Oct 2020  路  3Comments  路  Source: dotansimha/graphql-code-generator

Describe the bug

Operation and variables types are incorrectly named when generated with the typesSuffix config option.

To Reproduce

The repro is available here: https://codesandbox.io/s/focused-allen-42r9f?file=/types.ts:655-681.

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

type User {
    id: ID!
    username: String!
    email: String!
}
  1. My GraphQL operations:
query user {
    user(id: 1) {
        id
        username
        email
    }
}
  1. My codegen.yml config file:
schema: schema.graphql
documents: document.graphql
generates:
  types.ts:
    plugins:
      - typescript
      - typescript-operations
      - typescript-react-apollo
    config:
      withHooks: false
      typesSuffix: 'Type'

Expected behavior

The generated type name should be UserQueryType and UserQueryVariablesType but instead it is UserTypeQueryType and UserTypeQueryVariablesType

Environment:

  • @graphql-codegen/add: 2.0.1
  • @graphql-codegen/cli: 1.19.0
  • @graphql-codegen/typescript: 1.17.11
  • @graphql-codegen/typescript-operations: 1.17.8
  • @graphql-codegen/typescript-react-apollo: 2.0.7
  • graphql: 15.3.0
  • NodeJS: 10.x

Additional context

There was another bug report in the similar vein which was already resolved: #4687

bug plugins waiting-for-release

All 3 comments

Hi @jaitd , I managed to fix this issue in: https://github.com/dotansimha/graphql-code-generator/pull/5038

Can you please give the alpha version a try? it's @graphql-codegen/[email protected]

Fixed in @graphql-codegen/[email protected].

Thanks @dotansimha. It works now 馃槃

Was this page helpful?
0 / 5 - 0 ratings