dotansimha/graphql-code-generator-community

Missing HOC suffix dedup leads to invalid generated types with `dedupeOperationSuffix` and `withHOC` options.

Open

#138 geöffnet am 13. Juli 2021

Auf GitHub ansehen
 (1 Kommentar) (1 Reaktion) (0 zugewiesene Personen)TypeScript (195 Forks)github user discovery
help wanted

Repository-Metriken

Stars
 (136 Stars)
PR-Merge-Metriken
 (PR-Metriken ausstehend)

Beschreibung

Describe the bug

The HOC generics are missing a name deduplication... https://github.com/dotansimha/graphql-code-generator/blob/0538923f0cee884f95136b3ac794f83238cee568/packages/plugins/typescript/react-apollo/src/visitor.ts#L181

So it generates:

export type GetUserInformationQueryVariables = Types.Exact<{ [key: string]: never; }>;

export type GetUserInformationQuery = (
// ...
);

// ...
export type GetUserInformationQueryProps<TChildProps = {}, TDataName extends string = 'data'> = {
      [key in TDataName]: ApolloReactHoc.DataValue<GetUserInformationQueryQuery, GetUserInformationQueryQueryVariables>
    } & TChildProps;

GetUserInformationQueryQuery, GetUserInformationQueryQueryVariables should be GetUserInformationQuery, GetUserInformationQueryVariables

To Reproduce

If a live reproduction is necessary I can create one.

  1. My GraphQL schema:
# Put your schema here
  1. My GraphQL operations:
# Put your operations here
  1. My codegen.yml config file:
# ...
        preset: near-operation-file
        presetConfig:
            extension: .generated.tsx
            baseTypesPath: webapp_gql.ts
        plugins:
            - typescript-operations
            - typescript-react-apollo
        config:
            reactApolloVersion: 2
            withHooks: true
            withHOC: true
            withComponent: true
            gqlImport: graphql.macro#gql
            dedupeFragments: true
            dedupeOperationSuffix: true
            exportFragmentSpreadSubTypes: true

Expected behavior

GetUserInformationQueryQuery, GetUserInformationQueryQueryVariables should be GetUserInformationQuery, GetUserInformationQueryVariables

Generics should dedup when HOC is enabled.

Environment:

  • OS: macOS
  • @graphql-codegen/...: latest
  • NodeJS: v14

Additional context

Happy to add more context, but I believe I found the broken line.

Contributor Guide