#Flutter Datastore nested items are not inlcuded on querys.

2 messages · Page 1 of 1 (latest)

lapis venture
#

I have a project I would like to query datas from several object whose got inner object with @hasOne relation but wheneever I try to query these data, I got and Exception that these fields are not populated.
class AppTournament extends amplify_core.Model {
static const classType = const _AppTournamentModelType();
final String id;
final String? _name;
final Tournament? _real_tournament;
final User? _founder;
final amplify_core.TemporalDateTime? _createdAt;
final amplify_core.TemporalDateTime? _updatedAt;
final String? _appTournamentReal_tournamentId;
final String? _appTournamentFounderId; } for example here I dont receive the fouder nor the tournament object when I do a query. I need to enable somewhere the prepropulation of these datas ?

Future<List<AppTournament>> getAppTournaments2() async {
final value = await Amplify.DataStore.query(AppTournament.classType);
for (var i in value) {
i.founder;
}
return value;
},

This will throw an exception.

type AppTournament @model @auth(rules: [{allow: public}]) {
id: ID!
name: String!
real_tournament: Tournament! @hasOne
founder: User! @hasOne
}

this is the scheme.

Feel free to ask!
Hi, Zoli!

left kraken
#

Hi @lapis venture are there any records that might come back from that query and not have a founder? Perhaps that field was added later on and there were pre-existing records where founder would be null. The field is required so that might explain the error message.