Closed PeteDuncanson closed 3 years ago
Hi @PeteDuncanson thank you for reaching out with such a detailed description of your problem. I'm sorry to hear you are having issues with deleting relational content via Datastore.
I'm just beginning to dive into the details you've provided to try and gain further insight to the root cause of the issue. At first glance, I noticed you are utilizing an older version of the aws-amplify
library (looks like version 3.3.23
from your output provided above).
Not saying this will solve the problem, but I'm just curious if you are intentionally holding back from upgrading to the latest major version of the core library (as of today the latest version is 4.1.3
) for a certain reason?
Thanks for providing some historical context while we look to reproduce the problem and hopefully help you get to the bottom of it!
@nickarocho good question. I didn't know there was an update. I keep up to date with the CLI releases everytime they notify me about an update (which are really often, you lot of busy). I had no idea there was a separate thing for core! Thought it was all one and the same thing so I kind of thought I was on the cutting edge!
I can have a go at upgrading it and see if that changes anything and report back.
Well. That was interesting.
The good news, that seems to have fixed it!
The interesting bit is yarn upgrade aws-amplify
wouldn't upgrade it, kept it at v3.3.23 which might explain why I was on such an old version. Had to run yarn upgrade aws-amplify@^4.1.3
to force it.
Then gave my app another go and it deleted (via DataStore) without any errors! Woohoo!
I wonder how many other quirks that might have fixed :)
Thank you so much for taking a look and pointing me in the right direction, saved my weekend!
@PeteDuncanson yes the core JS library maintains its own release cycle, which can definitely be tricky to keep track of.
You can update all Amplify packages to the latest
version using the following script (depending on if you use yarn
or npm
):
# Using YARN
yarn upgrade --latest --pattern aws-amplify
or
# Using NPM
npx npm-check-updates -i '/@?aws-amplify/' && npm update
Please let us know how this affects your app either positively or if there are any other side-effects due to the major version bump.
If you are still having an issue with interacting with relational content it might be related to your setup, in which case I'll be happy to help by creating a similar setup to your current environment.
Hope that helps!
You beat me to the punch!
Great, I'm so happy updating the core library solved your problem. For future reference, here is our documentation on updating all Amplify libraries.
Hope this provides a nice start to your weekend :) Thanks again for reaching out and never hesitate to contact us again if you run into any roadblocks, we are here to happily assist.
Cheers, closing this ticket but feel free to reopen if anything else similar comes up in your future development.
@nickarocho not sure how you could surface that better, the way the CLI does it is wonderful and I keep up todate when I see there is a release, wonder if it could do something similar for the core etc? Just an idea.
Thanks again, have a great weekend!
@PeteDuncanson yes this is excellent feedback which I will be sharing with the team to improve the overall experience for everyone who uses Amplify across every platform.
Thanks again!
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.
Looking for a help forum? We recommend joining the Amplify Community Discord server *-help
channels or Discussions for those types of questions.
Before opening, please confirm:
JavaScript Framework
React
Amplify APIs
DataStore
Amplify Categories
Not applicable
Environment information
Describe the bug
I have a schema with several relations within it. I cannot seem to delete any of the models with a relation as I get the following Error:
Failed to execute 'index' on 'IDBObjectStore': The specified index was not found.
My Schema (trimmed as best I can) is below, the Gist is we have a Round (like a delivery service) which a StaffMember gets assigned too as they are the ones doing the Round. StaffMembers can be on multiple Rounds, so that should be a hasOne relationship from the Round to the StaffMember (this follows on from the example of a Comment hasOne BlogPost that it refers to in all the docs, https://docs.amplify.aws/lib/datastore/relational/q/platform/js#saving-relations). Each StaffMember also has a link to a User that we use for Authentication. StaffMember and User used to have a connection but I removed it in trying to fix this (wondered if it had issues with multiple nested relations) without any luck.
This seems to be being caused in this method (https://github.com/aws-amplify/amplify-js/blob/d16a8fbc5862281121812b1f8fc7af8bb001190d/packages/datastore/src/storage/adapter/AsyncStorageAdapter.ts#L492) when trying to delete, its trying to delete the StaffMember I have in the connection on Round. That causes it to blow up. If I change my schema to remove the connection to the StaffMember on Round then it will work. But I build the whole schema with GraphQL in mind so nearly everything has connections on it. Now when using DataStore it keeps blowing up when deleting. Even trying to go to AppSync directly with a GraphQL query still causes the error (when the connection is in place on Round to StaffMember) as I guess the subscription from AppSync causes it to try to delete it locally so its dying.
I've tried the fix mentioned in here https://github.com/aws-amplify/amplify-js/issues/6560#issuecomment-834618097 to enable a feature toggle in the /amplify/cli.json file (which didn't exist so I had to copy if from https://docs.amplify.aws/cli/reference/feature-flags#configuration). This injected in the new "targetName" fields so it was working as mentioned in the above issue.
This seems like quite a core thing, DataStore should be able to delete relational content right? Which makes me think this is either a mess up with my setup (why didn't I have a cli.json file for instance already? Its meant to already be there from what I've read) or my schema. This project is over a year old now on Amplify and a lot has changed with Amplify in that time, I wonder if something is busted that I need to update or something?
Happy to share my full schema but the above should give you an idea. Related content simply can't be deleted at all currently and I've no idea why.
Expected behavior
Running
await DateStore.delete( myRound )
should delete the Round but not the related StaffMember (a StaffMember can have multiple rounds.As shown in the docs https://docs.amplify.aws/lib/datastore/relational/q/platform/js#deleting-relations
Reproduction steps
Happy to privately share my app code if it will help. I've tried to make a demo repos but its slow going.
Code Snippet
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response