Describe the bug
When graphql-codegen-typescript-client is configured with noNamespaces: true and a field value is a union of graphQL types, the field's value references the wrong name for the generated inlineFragments type. It appears the prefix is missing.
To Reproduce
Using this mouthwatering example in the demo app:
schema:schema {
query: Query
}
type Query {
me: User
user(id: ID!): User
}
type Pizza {
dough: String!
toppings: [String!]
}
type Hamburger {
patty: String!
toppings: [String!]
}
union FavoriteFood = Pizza | Hamburger
type User {
id: ID!
favoriteFood: FavoriteFood!
}
document:query findUser($userId: ID!) {
user(id: $userId) {
id
favoriteFood {
...on Pizza {
dough
toppings
}
... on Hamburger {
patty
toppings
}
}
}
}
config:config:
noNamespaces: true
generates:
client-types.ts:
- typescript-common
- typescript-client
generated:export type FindUserVariables = {
userId: string
}
export type FindUserQuery = {
__typename?: 'Query'
user: FindUserUser | null
}
export type FindUserUser = {
__typename?: 'User'
id: string
favoriteFood: FavoriteFood
}
export type FindUserFavoriteFood = FindUserPizzaInlineFragment | FindUserHamburgerInlineFragment
export type FindUserPizzaInlineFragment = {
__typename?: 'Pizza'
dough: string
toppings: string[] | null
}
export type FindUserHamburgerInlineFragment = {
__typename?: 'Hamburger'
patty: string
toppings: string[] | null
}
Expected behavior
generated:...
export type FindUserUser = {
__typename?: 'User'
id: string
favoriteFood: FindUserFavoriteFood // <= MUST MATCH TYPE NAME BELOW
}
export type FindUserFavoriteFood = FindUserPizzaInlineFragment | FindUserHamburgerInlineFragment
...
Schema/Documents
If possible and relevant, please provide your GraphQL schema and GraphQL documents.
Environment:
Additional context
Add any other context about the problem here.
Fixed in #983
Released in v0.15.0
Most helpful comment
Fixed in #983