I use codegen to generate TS types and I use Apollo client to send queries to server.
when I generate code for the following example, Typescript dosen’t know that people has firstName and lastName fields, It only knows that avatar field exists. If I remove fragment and move fields directly to query all fields are usable.
What should I do to support fragments correctly?
fragments/person.graphql
fragment NameParts on Person {
firstName
lastName
}
queries/person.ts
import { graphql } from '@/gql'
export const getPersonDocument = graphql(`
query GetPerson {
people(id: "7") {
...NameParts
avatar(size: LARGE)
}
}
`)
'@/gql' is the output directory of codegen
2

I think the frag should be in a separate file or something from what I'm looking at on Google.
46 mins ago
This is just an example , my fragments are in separate files. I have updated question to clarify that they are not in the same file.
21 mins ago