apollographql / apollographql/apollo-tooling

Codegen won't show Warning or Error for conflicting Fragments

Open
#1,803 0 comments 0 reactions 0 assignees View on GitHub
🤖 component - codegen
Dominant language
TypeScript
Stars
3k
Forks
460
PR merge metrics
No merged PRs in 30d

Description

For example, you have RestaurantSchema.ts:
```javascript
const RestaurantCityFragment = gql`
fragment CityFragment on City {
id
name
region
}
`
export const FetchRestaurants = gql`
query FetchRestaurants {
Restaurants {
id
city{
...CityFragment
}
}
}
${CityFragment}
`
```

and CitySchema.ts:
``` javascript
const CityFragment = gql`
fragment CityFragment on City {
id
name
slug
}
`
export const FetchCities = gql`
query FetchCities {
Cities {
...CityFragment
}
}
${CityFragment}
`
```
What one would expect is a warning or a error about naming conflicts in schema that will lead to unpredictable behavior.

But codegen finishes with success and no indication of an error .

Commands run:
```
apollo client:codegen --target=typescript --outputFlat src/types/api.d.ts
```
Version:
apollo: 2.21.0

Contributor guide

Open the contributing guide

Research direction

Reproduce the conflict using RestaurantSchema.ts and CitySchema.ts with the reported apollo client:codegen command. Trace the codegen validation path for duplicate fragment names; done means the command reports a warning or error instead of finishing silently.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, typescript
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.