Given a parent container fragment like so:
export const ListLoader = createFragmentContainer(List, {
productCategories: graphql`
fragment List_productCategories on ProductCategory @relay(plural: true) {
...Item_productCategory
id
name
}
`,
})
Sorts ProductCategory by name and maps the data to React components. With a child:
export const ItemLoader = createFragmentContainer(Item, {
productCategory: graphql`
fragment Item_productCategory on ProductCategory {
name
products {
id
name
}
}
`,
})
Gives the error: Expected __typename to be be consistent, but the record was assigned conflicting types
Removing the products { ... } from the child component makes the error go away.
I used this pattern without problem in Relay using getFragment.
FWIW - Relay modern has the same requirement for globally unique ids. A dumb mistake.
Reopening to improve the warning a bit for other people running into this.
how to deal with this?
When I query id field this error happen
products {
id
}
So my workaround is to use alias
products {
key: id
}