Graphql-code-generator: v2 apollo-react plugin enforces tsx by default

Created on 4 Aug 2020  路  5Comments  路  Source: dotansimha/graphql-code-generator

Describe the bug

https://github.com/dotansimha/graphql-code-generator/releases/tag/%40graphql-codegen%2Ftypescript-react-apollo%402.0.0 says withComponent: false is the default behavior, but that forces the generated file to be tsx instead of ts.

https://github.com/dotansimha/graphql-code-generator/blob/8f31a9a9d74f556975e5bdb3c92dc8da8a578be6/packages/plugins/typescript/react-apollo/src/index.ts#L36-L51

Adding an explicit withComponent: false fixes the issue

To Reproduce
Steps to reproduce the behavior:

  1. My GraphQL schema:

N/A

  1. My GraphQL operations:

N/A

  1. My codegen.yml config file:
config:
  reactApolloVersion: 2
generates:
  src/:
    schema:
      - schema.graphql
    documents: src/**/*.graphql
    preset: near-operation-file
    presetConfig:
      baseTypesPath: gqltypes.ts
    plugins:
      - typescript-operations
      - typescript-react-apollo

Expected behavior

Environment:

  • OS: macOS
  • @graphql-codegen/...: 1.17.7 plus v2 of react apollo
  • NodeJS: 12.18.1

Additional context

bug plugins

All 5 comments

Thanks @SimenB ! I guess we need to validate extensions based on configuration provided. I will look into it :)

Flipping to only enforcing tsx if withComponent: true should fix it, I believe 馃檪

@SimenB can you please try @graphql-codegen/[email protected]?

Yeah, that alpha works great!

Fixed in @graphql-codegen/[email protected]

Was this page helpful?
0 / 5 - 0 ratings

Related issues

leonardfactory picture leonardfactory  路  3Comments

edorivai picture edorivai  路  3Comments

zenVentzi picture zenVentzi  路  3Comments

quolpr picture quolpr  路  3Comments

NickClark picture NickClark  路  3Comments