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

Created on 15 May 2017  路  4Comments  路  Source: facebook/relay

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.

All 4 comments

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
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

bondanherumurti picture bondanherumurti  路  3Comments

janicduplessis picture janicduplessis  路  3Comments

rayronvictor picture rayronvictor  路  3Comments

MartinDawson picture MartinDawson  路  3Comments

piotrblasiak picture piotrblasiak  路  3Comments