dotansimha / dotansimha/graphql-code-generator-community

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

Open
#138 1 comment 1 reaction 0 assignees View on GitHub
help wanted
Dominant language
TypeScript
Stars
137
Forks
195
Avg merge
6h 20m
Merged PRs (30d)
16

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:

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

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

// ...
export type GetUserInformationQueryProps = {
[key in TDataName]: ApolloReactHoc.DataValue
} & TChildProps;
```

`GetUserInformationQueryQuery, GetUserInformationQueryQueryVariables` should be `GetUserInformationQuery, GetUserInformationQueryVariables`

**To Reproduce**

If a live reproduction is necessary I can create one.

1. My GraphQL schema:

```graphql
# Put your schema here
```

2. My GraphQL operations:

```graphql
# Put your operations here
```

3. My `codegen.yml` config file:

```yml
# ...
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

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.