dotansimha / dotansimha/graphql-code-generator
Trailing underscore in fragment spread sub types
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 1.4k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 23
Description
**Describe the bug**
The generated sub types for fragment spreads end with a trailing underscore, e.g. `MandateFragment_DigitalMandate_`. The expected behaviour is generating the name without the trailing underscore, e.g. `MandateFragment_DigitalMandate`.
**To Reproduce**
Steps to reproduce the behavior:
https://codesandbox.io/s/graphql-codegen-fragment-spread-bug-1yovy?file=/types.ts
1. My GraphQL schema:
```graphql
type Query {
mandates: [Mandate!]!
}
interface Mandate {
id: ID!
reason: String!
}
type DigitalMandate implements Mandate {
id: ID!
reason: String!
code: String!
}
type PaperMandate implements Mandate {
id: ID!
reason: String!
file: String!
}
```
2. My GraphQL operations:
```graphql
fragment MandateFragment on Mandate {
id
reason
...DigitalMandateFragment
...PaperMandateFragment
}
fragment DigitalMandateFragment on DigitalMandate {
code
}
fragment PaperMandateFragment on PaperMandate {
file
}
query GetMandates {
mandates {
...MandateFragment
}
}
```
3. My `codegen.yml` config file:
```yml
schema: schema.graphql
documents: document.graphql
generates:
types.ts:
plugins:
- typescript
- typescript-operations
config:
dedupeOperationSuffix: true
exportFragmentSpreadSubTypes: true
namingConvention: keep
```
**Expected behavior**
The name should not end with a trailing underscore, so `MandateFragment_DigitalMandate` instead of `MandateFragment_DigitalMandate_`.
**Environment:**
- OS: Ubuntu 18.04
- `@graphql-codegen/...`: 1.15.4
- NodeJS: 14.4.0 (or 10.20.1 in the CodeSandbox)
**Additional context**
-
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.