profile
viewpoint

Ask questions[Modern] Expected __typename to be be consistent, but the record was assigned conflicting types

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.

facebook/relay

Answer questions MinhThienDX

When I query id field this error happen

products {
  id
}

So my workaround is to use alias

products {
  key: id
}
useful!
source:https://uonfu.com/
Github User Rank List