Open hmisonne opened 3 years ago
Thanks for opening the issue with excellent details @hmisonne! Unfortunately, having an array of owners with DataStore isn't currently supported due to how AppSync handles owner based auth with an array of owners and how the subscriptions need to be created. This is a limitation we're aware of, and we are currently working on updating the documentation to more accurately reflect any potential limitations you might run into with DataStore right now like this.
With that said, I'd recommend exploring static group authorization to see if you are able to address your use case in a similar way.
We will continue to track this issue and provide any updates here.
Thanks @amhinson, I looked at the static group authorization, but unfortunately it won't work for my use case.
I really hope that this new feature will be available soon!
Unfortunately I ran into the same problem. I have a multi-tenant application that should allow data editing for some users dynamically. By design, there is no way to achieve this functionality with static groups because the authorization changes from record to record.
Do you recommend to leave the Datastore way for now @amhinson ?
@hmisonne @giulio-dds can you give us more specifics on your use cases? This will help us give feedback to the AppSync service team so that we can better convey the requirements into their roadmap for 2021.
Hi @undefobj ,
In my use case, I am building a Grocery List App for shoppers who want to share and update a grocery list. It is the same concept as Tricount or Slitwise where users share expenses and can see live updates.
Having just one owner is not compatible with my concept since I need multiple users to get access to one grocery list. Not having the @auth
directive is not ideal since the users will receive the data from the entire database.
The only way I found to work around this issue was to use SelectiveSync, but it comes with a lot of challenges:
Hi @undefobj , we are developing a browser based ERP for transport logistics in Amplify + React.js. ERP owners (i.e. carriers) can receive orders from their customers through an app (Amplify + React Native) which allows read, writing and updating of shipment information recorded on an Orders table in DynamoDB.
Customers and carriers must be able to update the status and details of orders, based on the flow of logistics during transport (tracking, customer feedback, courier notifications, goods transported, invoicing, etc.). Therefore, both the customer and the carrier must be able to update the information on an order.
It would be easy with static groups if the ERP were for a single company, however in our case we have a network of carriers (with their customers) and the informations recorded in the table must necessarily be dynamic with multiple level of authorization to optimize the access and security of the data.
In a few words, all carrier's tenants (managed by cognito group auth) and customer specific user, have access to the order record and in both cases they can perform read, write and update operations.
@giulio-dds @hmisonne
I ran into the same issue and implemented a workaround.
You can see the details here https://github.com/aws-amplify/amplify-cli/issues/4794#issuecomment-677935432
In a gist, you need an alternative to get your notifications somewhere else (since it's impossible to subscribe based on an array filter), and you need to hack/modify the DataStore to inject incoming messages from your alternate subscription.
I have a version of the DataStore that allows passing in an Observable object. This custom observable serves as a replacement of the failing subscriptions due to the @auth
array filed. The client is then responsible for passing in the events that will mutate the DataStore indexedDB. I have a model with an array based ownership (like your "editors"), and I am using the DataStore just fine.
If it helps get this prioritized, I'll add my use case, which seems to be roughly similar to some of the other ones listed here: near-real time sync of information stored in one instance of an object with a group of users, only one of whom has Create/Delete permission. The expected number of groups will exceed the number supported by Cognito, so my understanding is that I have to use a [String]
ownerfield
for owners with Read and Update. Going to see if I can re-work it to get around this.
This is also a limitation for my use case. We're creating a tool where groups of people collaborate on projects. It works fine so far with the non-Datastore API (String array of userIDs per project as owner field), but we were really keen on upgrading to Datastore for the offline features, cascading mutations, more intuitive API, etc. We'll be really happy when this becomes available. :)
Describe the bug
I built a React Native App and I am following the amplify docs to add owner authorization. I am using
withAuthenticator
to register and sign in users through AWS Cognito.Adding an
@auth
rule to a model with multiple editors will throw a subscription Error :Having just one owner won't generate any errors.
To Reproduce Steps to reproduce the behavior:
Run
amplify update api
,amplify push
,npm run amplify-modelgem
Run the app locally and see the error (I am using a "GroceryList" model instead of "Draft"):![image](https://user-images.githubusercontent.com/52170580/97365433-e606d080-1862-11eb-9684-685d53eab8a9.png)
Expected behavior I am expecting the app to run without errors
Code Snippet
What is Configured?
Output of running
npx envinfo --system --binaries --browsers --npmPackages --npmGlobalPackages
Environment: