amplify-swift
amplify-swift copied to clipboard
Detected multiple owner type auth rules with a READ operation.
Describe the bug
I have this schema:
type Profile @model
@auth(rules: [
{allow: owner},
{allow: owner, ownerField: "followerIDs", operations: [read]},
{allow: public, provider: apiKey}
]) {
id: ID!
name: String
...
followerIDs: [String]
}
When I use DataStore I can query and create Profiles, but I can't update Profiles and get following warning:
Detected multiple owner type auth rules with a READ operation. We currently do not support this use case. Please limit your type to just one owner auth rule with a READ operation restriction.
Is it correct, that the use case above is not possible with amplify (DataStore) on iOS, or do anyone have an idea what I'm doing wrong?
Steps To Reproduce
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
Expected behavior
I should be able to update models that have two owner types defined.
Amplify Framework Version
1.18.1 (2021-12-15)
Amplify Categories
DataStore
Dependency manager
Swift PM
Swift version
5.0
CLI version
7.6.5
Xcode version
13.2.1
Relevant log output
No response
Is this a regression?
No
Regression additional context
No response
Device
iPhone 12 simulator
iOS Version
iOS 15.2
Specific to simulators
No response
Additional context
No response
Hi @TimmBaier, thanks for reporting this us. Your schema is valid and I believe the error message you're seeing is an old check we put in place before implementing multiple authorization rules. We are currently looking into and we'll update this issue with our findings.
If I have the env deployed with the schema above, just comment out the second owner locally and generate the swift code with amplify codegen models I can update and sync without problems.
If I have the env deployed with the schema above, just comment out the second owner locally and generate the swift code with
amplify codegen modelsI can update and sync without problems.
What if I need the second owner?
Unfortunately dynamic auth rules like array of owners aren’t fully compatible with DataStore at the moment as subscriptions with multiple owner rules require extra support from the service, therefore we'll need to hold off a bit on the PR. @maziarzamani @TimmBaier we'll update this thread and the PR.
Unfortunately dynamic auth rules like array of owners aren’t fully compatible with DataStore at the moment as subscriptions with multiple owner rules require extra support from the service, therefore we'll need to hold off a bit on the PR. @maziarzamani @TimmBaier we'll update this thread and the PR.
Hi @diegocstn. Thanks for the reply. Is there a workaround? Our product relies on multiple owners, without this we cannot launch, ever.
Any update on this one? Our project is still stuck.
I too am looking for this feature. After finally figuring out the right way to handle this I got hit by this error with subscriptions. I filed an issue #10110 that talks about what use case I'm seeking BUT the relevant info related to this issue is in my first comment which speaks to exactly this.
Unfortunately dynamic auth rules like array of owners aren’t fully compatible with DataStore at the moment as subscriptions with multiple owner rules require extra support from the service, therefore we'll need to hold off a bit on the PR. @maziarzamani @TimmBaier we'll update this thread and the PR.
You mentioned "subscriptions", what if we do not use subscriptions? As far as I can see the iOS SDK fails with the presence of arrays without initiating any subscriptions.
Unfortunately dynamic auth rules like array of owners aren’t fully compatible with DataStore at the moment as subscriptions with multiple owner rules require extra support from the service, therefore we'll need to hold off a bit on the PR. @maziarzamani @TimmBaier we'll update this thread and the PR.
With this finally released for AppSync, https://aws.amazon.com/blogs/mobile/appsync-enhanced-filtering/ and with the CLI adding support soon: aws-amplify/amplify-category-api#389 what is the timeline for dynamic group support for subscriptions for iOS? Would making SyncExpressions server sided also make sense?
Any update?
We do also require the feature to have multiple owner type auth rules to share data from the "creator" of the record to many different read-users. The auth rules look like this:
{ allow: owner, ownerField: "owner" operations: [create, read, delete, update] }
{ allow: owner, ownerField: "readers", operations: [read, update] }
Is there any update by when this will be available?
We do also require the feature to have multiple owner type auth rules to share data from the "creator" of the record to many different read-users. The auth rules look like this:
{ allow: owner, ownerField: "owner" operations: [create, read, delete, update] } { allow: owner, ownerField: "readers", operations: [read, update] }Is there any update by when this will be available?
@dnys1 this is the same issue I reported to you way back in November of 2021, correct? I know there are a few issues open on this, do any of them have additional information that may be useful to @bflatone and myself? I'm still looking to implement multiple owner records with subscriptions using DataStore. Please advise and thanks for your continued help.
Any progress?
Any progress?
I'm looking at this stuff as we speak. I uncovered this re:Invent video last night and this looks promising. The video link below is at the current time of the auth rules that coincide to the ones I need for my project. They talk about real-time sync between customer order and the driver flutter app so this all seems very promising. FYI, they are using BETA flutter plugins.
Bumping for an update
Any progress?
Any update on this, we have a similar use case?
I believe the changes to enable this use case was merged in from https://github.com/aws-amplify/amplify-swift/pull/3223
Please try with the latest Amplify version and let us know in a new issue with your schema use case if something isn't working.
⚠️COMMENT VISIBILITY WARNING⚠️
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.