Graphql-code-generator: 1.8.2 typescript-react-apollo doesn't properly implement the typesPrefix option.

Created on 24 Oct 2019  路  5Comments  路  Source: dotansimha/graphql-code-generator

Describe the bug
@graphql-codegen/typescript-react-apollo doesn't respect capitalized type prefixes anymore since 1.8.2. This results in a mismatch with the other 1.8.2 plugins that do properly implement capitalized type prefixes.

To Reproduce
Install @graphql-codegen/[email protected] and generate a hook with typesPrefix set to GQL. Results in:
return ApolloReactHooks.useQuery<GqlMyQuery.

instead of the expected:
return ApolloReactHooks.useQuery<GQLMyQuery.

My codegen.yml config file:

schema:
  - schema-location
documents: "./src/**/*.graphql"
overwrite: true
generates:
  ./.generated/fragmentTypes.json:
    plugins:
      - fragment-matcher
  ./.generated/gql.model.tsx:
    plugins:
      - typescript
      - typescript-operations
      - typescript-react-apollo
    config:
      scalars:
        Time: string
      withHooks: true
      withHOC: false
      hooksImportFrom: "@apollo/react-hooks"
      avoidOptionals: true
      typesPrefix: GQL
  ./.generated/schema.graphql:
    - schema-ast

Expected behavior
All plugins should implement the typesPrefix config the same way.

Environment:

  • OS: Linux Ubuntu 19.04
  • @graphql-codegen/typescript-react-apollo: 1.8.2
  • NodeJS: v10.14.2
bug plugins waiting-for-release

All 5 comments

Another issues related to 1.8.2 #2742

I think I managed to reproduce and fix this in: https://github.com/dotansimha/graphql-code-generator/pull/2862

@Rachnerd @xiaoyu-tamu Can you please try this alpha? 1.8.3-alpha-57c54418.34

@dotansimha 1.8.3-alpha-57c54418.34 fixes the issue. Thanks!

@dotansimha it works. Thank you!

Fixed in 1.8.3

Was this page helpful?
0 / 5 - 0 ratings

Related issues

quolpr picture quolpr  路  3Comments

zenVentzi picture zenVentzi  路  3Comments

rogerg93 picture rogerg93  路  3Comments

iamdanthedev picture iamdanthedev  路  3Comments

NickClark picture NickClark  路  3Comments