Missing HOC suffix dedup leads to invalid generated types with `dedupeOperationSuffix` and `withHOC` options.
#138 aberto em 13 de jul. de 2021
Métricas do repositório
- Stars
- (136 stars)
- Métricas de merge de PR
- (Métricas PR pendentes)
Description
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.
- My GraphQL schema:
# Put your schema here
- My GraphQL operations:
# Put your operations here
- My
codegen.ymlconfig 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.