GraphQL, TypeScript & Apollo Client

a better practice is to use the generated types as reference of what the api gives
pass your api data through a mapper function that giives the results in the types used for your app
with this you make sure that you have 100% you need
if api changes and types generated changes you wont be going through all the app fixing types
you will only edit the mappers
and the mapper function will also play the role of doing a fall back behaviour if certain data does nto exists

example

type ProductGeneratedType = {
id:string
name:string
code:string
description:string | undefined
collectionId:string
variants: VariantGeneratedType[]
}

type AppProduct {
id:string
name:string
description:string
}

function fetchOneProductMapper(product: ProductGeneratedType):AppProduct {
return {
id:product.id
name:product.name
description: product.description ?? ''
}
}