Open edomazi opened 4 years ago
@edomazi DataStore doesn't currently support syncing any connections to a model. In your case, you can query Order
and Client
separately then combine them in your app for the time being. With that said, we are working on making this simpler. I'm going to mark this as a feature request for now, and we will come back with any related future updates.
Any updates on this?
The connections are solved automatically by DataStore when dealing with BELONGS_TO relations but still not working with HAS_ONE relations and this issue is almost one year old....
Re https://github.com/aws-amplify/amplify-js/issues/6973#issuecomment-712272925: could we please have an update?
i ran into this issue and would love to get myself unblocked. in my case, i have a model, RentalItem
, which is restricted to CRUD from the model owner only. i have another model, Rental
, which is also restricted to CRUD from the model owner only. this way, i create a Rental item for a logged in user on a particular RentalItem based on the id of a third model, a MediaItem
(RentalItem
has a mediaItemID @hasOne
field). the schema for the Rental model includes:
rentalItemID: ID!
rentalItem: RentalItem! @hasOne(fields: ["rentalItemID"])
in this way, whoever creates the Rental gets access to the RentalItem via the hasOne relationship. however, i cannot cross-reference the RentalItem with the rentalItemID
i receive from DataStore because only the owner of the RentalItem
has access to it.
looking at this thread, i see that using @belongsTo
will make it so that DataStore
includes the referenced model. is replacing my @hasOne
with a @belongsTo
a viable workaround? the Rental
to RentalItem
relationship is many-to-one, where “many” could be 100,000+. thanks for any advice any of you can provide!
Hello, I have a small problem with a
hasOne
relationship between those 2 models:When I query the database from appsync I get the following nested data which is correct:
But when I query the database from my app (
this.orders = await DataStore.query(Orders);
) I get those results which don't have the nested clientname
andemail
:What am I am missing? Why i don't get the name and email from the client? Also this is what grapql generated with
amplify codegen
:amplify versions:
What should I do to get all the data I need? Thanks