apollographql / apollographql/apollo-tooling
Codegen should throw error on duplicate fragment names
- Dominant language
- TypeScript
- Stars
- 3k
- Forks
- 460
- PR merge metrics
- No merged PRs in 30d
Description
**Intended outcome:**
`apollo client:codegen` should throw an error if two fragments are named the same, similar to how it already does this for mutations + queries.
**Actual outcome:**
The last fragment for a given name will overwrite all the other ones.
**How to reproduce the issue:**
Repro here: https://github.com/glentakahashi/apollo-codegen-fragment-test
`yarn gql` creates `graphql.d.ts` without throwing an error which has only the fragment from `b.ts`, which has overwritten `a.ts`
**Versions**
2.21.1
Contributor guide
Research direction
Run `yarn gql` in the linked reproduction and compare the generated `graphql.d.ts` from `a.ts` and `b.ts`. Trace the `apollo client:codegen` entry point to find where duplicate mutations and queries are rejected. Done means duplicate fragment names produce an error instead of allowing the later fragment to overwrite the earlier one.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100