1

I'm building an application with Amplify and using DataStore.

I have a set of data in a data model called "Location" that I created several days ago and I was using it with DataStore.query but all of a sudden the data stopped coming back. I went to look at the Content tab in Amplify Studio and it wasn't there so I thought maybe it was dropped for some reason.

But the data still exists in DynamoDB, is queryable in GQL, but is not visible in DataStore or the Content page in Studio.

I have no idea what could cause this. The data looks complete--it's got the Amplify fields like createdAt, updatedAt, etc.

Here's another clue--when I first noticed them disappear I went and manually created one and it worked fine for a day or so but now it's gone. What can cause this?

(BTW, the DataStore query is this: return await DataStore.query(Location);)

Update So, new information. This started when I added a new model called DeviceLocationFollow with two @hasOne relationships to the Device and Location table. (I am not using a @manyToMany because I wanted to add the extra follow field).

When I delete the records from this third table it disables the ability to see the referenced records, but the records otherwise seem fine.

type DeviceLocationFollow @model @auth(rules: [{ allow: public }]) {
  id: ID!
  location: Location @hasOne
  device: Device @hasOne
  follow: FollowType!
}

Data visible in GQL and DynamoDB UI, not in DataStore or Amplify Studio Data Manager

1 Answers1

0

Well, that explains it. Apparently if you have an @hasOne relationship and you delete that record it also deletes the target record. I hadn't noticed that _deleted was true in DynamoDB, and apparently GQL lets you query those records if you don't exclude them explicitly.

  • In my case I do not have that relationship, Any new data that is being added, it shows null in GQL , for all newly added data, not sure why. I am stuck – 89n3ur0n Aug 14 '23 at 16:31