aws-amplify DataStore query response has relational oneToOne property which is t

Started by ammusk354, February 23, 2023, 07:04:14 AM

ammusk354

i am playing around with aws-amplify datastore. I have developed three apps:

2 mobile apps using react-native and aws-amplify v4
create-react-app using aws-amplify v5 (using v5 because @aws-amplify/ui-react requires)
Now the DataModel i am facing issues has following schema.graphql:
type OrderDish @model @auth(rules: [{allow: public}]) {
  id: ID!
  quantity: Int!
  Dish: Dish @hasOne
  orderID: ID! @index(name: "byOrder")
}

type Dish @model @auth(rules: [{allow: public}]) {
  id: ID!
  name: String!
  image: String
  description: String!
  shortDescription: String
  price: Float!
  restaurantID: ID! @index(name: "byRestaurant")
  soldOut: Boolean
}
This is how i query the data in the frontend:
const [dishes, setDishes] = useState<OrderDish[]>()

useEffect(()=> {
  DataStore.query(OrderDish, (o) =>
  o.orderID.eq(order.id)).then(setDishes);
},[])
Now in the OrderDish query response the one to one relational property Dish is treated as promise. So i am not sure if i am missing any breaking changes, but using aws-amplify v4 within my react-native frontend gives me the Dish property as Model. Any ideas what is happening here?
createdAt: "2022-11-18T12:39:56.962Z"
id: "fa29e0cd-115c-4ed5-ad3f-d2b602ca2954"
orderDishDishId: "1da861eb-d106-4ccf-a9c7-3440916b6fd8"
orderID: "7bf9c694-d127-4bdf-ae0f-cdf6a2316efe"
quantity: 3
updatedAt: "2022-11-18T12:39:56.962Z"
_deleted: null
_lastChangedAt: 1668775196984
_version:1
Dish: Promise