Graphql-code-generator: typescript-compatibility doesn't work with typescript-react-apollo's withHOC: false

Created on 16 May 2019  路  9Comments  路  Source: dotansimha/graphql-code-generator

Describe the bug
Using typescript-compatibility and typescript-react-apollo with withHOC: false:

generates:
  types.gen.tsx:
    config:
      noGraphqlTag: false
      strict: true
    schema:
      - "schema.graphql"
    documents:
      - "documents/*.graphql"
    plugins:
      - typescript:
      - typescript-operations
      - typescript-react-apollo:
          withComponent: false
          withHOC: false
      - typescript-compatibility

I get a generated line like this:
export type Props = EmployeeCreateWidgetsProps;, with a squiggle under the right side:

types.gen.tsx:90:23 - error TS2304: Cannot find name 'EmployeeCreateWidgetsProps'.

90   export type Props = EmployeeCreateWidgetsProps;
                         ~~~~~~~~~~~~~~~~~~~~~~~~~~

To Reproduce
Steps to reproduce the behavior:

clone https://github.com/jrr/gql-codegen-issue, yarn install and yarn run gql-gen -o, then open types.gen.tsx.

Using latest stable packages.

bug plugins waiting-for-release

All 9 comments

@ardatan Maybe it's related to your recent change in typescript-react-apollo? (with the Props)

Available in 1.2.0.

it happens again.

"@graphql-codegen/cli": "^1.4.0",
"@graphql-codegen/fragment-matcher": "1.4.0",
"@graphql-codegen/introspection": "1.4.0",
"@graphql-codegen/typescript": "1.4.0",
"@graphql-codegen/typescript-compatibility": "1.4.0",
"@graphql-codegen/typescript-operations": "1.4.0",
"@graphql-codegen/typescript-react-apollo": "1.4.0",
"@graphql-codegen/typescript-resolvers": "1.4.0",

overwrite: true
schema:
  - http://localhost:5001/graphql:
documents: ./graphql/**/*.gql
generates:
  graphql/index.tsx:
    plugins:
      - typescript
      - typescript-compatibility // remove this plugin works like a charm
      - typescript-operations
      - typescript-react-apollo
    config:
      prettify: false
      strict: true
      noNamespaces: true
      preResolveTypes: true
      namingConvention:
        typeNames: change-case#pascalCase
        transformUnderscore: true
      scalars:
        role_enum: "'admin' | 'customer' | 'partner' | 'driver' | 'public' | 'mine'"
        uuid: string
      maybeValue: T | undefined
      withHooks: true
      withHOC: false
      withComponent: false 

@xiaoyu-tamu can you please create a reproduction for this? I couldn't reproduce it in a test: https://github.com/dotansimha/graphql-code-generator/commit/2369c1d1e4c095e19bc67527adfd8f6b6e8e37cb

I think I fixed it in: https://github.com/dotansimha/graphql-code-generator/pull/2285
@xiaoyu-tamu can you please try it? 1.4.1-alpha-6a24d831.80

I can confirm it fixed in ^1.4.1-alpha-ffc76e57.81

Fixed in 1.5.0 馃帀

Was this page helpful?
0 / 5 - 0 ratings