#✅ - Datastore deleting association after failed graphQL mutation error

5 messages · Page 1 of 1 (latest)

valid oar
#

Hi, I'm using Datastore for a flutter app and I have a problem with a one to many relationship: when I'm offline the data is saved the way it's intended but once I turn on an internet connection I get some messages like GraphQLResponse.Error{message='Cannot return null for non-nullable type: 'AWSTimestamp' within parent 'Form' (/updateRegister/form/_lastChangedAt)', locations='null', path='[GraphQLPathSegment{value='updateRegister'}, GraphQLPathSegment{value='form'}, GraphQLPathSegment{value='_lastChangedAt'}]', extensions='null'}, data is successfully uploaded to dynamodb with the right associations but the association is deleted locally after the sync
For example:
Offline

Post a123
Comments (with postID as the foreign key): postID = a123
Online

Post a123
Comments (with postID as the foreign key): postID = null

The only way to get the right associations again is to clear the database and synchronize data from zero

clear inlet
#

Hi @valid oar I'm not familiar with Flutter development but if it's anything like the JS/Web behavior, the lastChangedAt field might not have been populated when the record was created. This looks like an update mutation that errored. It might be helpful to check whether the selection set of this mutation returns that field or if there were any errors returned from the response of the create mutation.

I might not be of much help beyond that because this could also potentially be a bug. If you need further assistance, I would recommend searching for an existing issue or opening a new one in the amplify-flutter repo.

https://github.com/aws-amplify/amplify-flutter/issues

GitHub

A declarative library with an easy-to-use interface for building Flutter applications on AWS. - Issues · aws-amplify/amplify-flutter

valid oar
#

Thanks for your kind help @chris. Well, this project has two components, one is in Nextjs which also uses Datastore and the flutter app, the Amplify config is in Nextjs and flutter pulls from there, I don't know if this is causing some kind of conflict but I've tried to define the models following flutter docs, I'm gonna try to use the conflict resolution to favor the ID associations from the local database and will report if this is a solution

valid oar
#

As a follow up I spent a whole week trying to find a solution but ended up switching to Firestore, I noticed that this problem has been present for a long time (months) but there has not been a solution and when you know Datastore has been completely dropped with Gen 2 I just can suggest avoiding Datastore for any new projects

high stratusBOT
#

✅ - Datastore deleting association after failed graphQL mutation error