Open mdoesburg opened 4 years ago
@mdoesburg DataStore sync operations only work with DynamoDB at this time, so @function
cannot be used. However you can use @function
on your schema and leverage the API category for those GraphQL fields in combination with DataStore in the same application.
Is there a reason you're looking to use this with DataStore? Synchronization is a process that needs strong controls or you end up with data inconsistency problems, which is why DynamoDB is the data source which AppSync leverages for DataStore. If you used a Lambda function then there's a strong chance that data integrity issues could arise causing complexity in your app or worse loss of data.
@undefobj I am working on an app with full offline support, hence I am using DataStore, but another requirement is that calls need to be done to an external REST API, so that a legacy database can be updated after mutations occur in this app.
My first inclination was to use DynamoDB streams with a Lambda trigger that calls the REST API, but we need to know the identity of the user, and as far as I know you can't get get this information from DynamoDB streams.
So the use case is to sync some external database when data in DynamoDB gets updated.
@undefobj Do you have any suggestions on what the best approach would be? I tried opening a discussion a while back, but with no luck so far. :p https://github.com/aws-amplify/amplify-js/discussions/5861
Thanks for the information @mdoesburg. We're looking at this for a future feature but have no timeline. Leaving this issue open for anyone to +1 with their use case details.
I know this issue is nearly a year old, however I'd be curious to understand:
@undefobj
Can one specify - at the level of your models (/amplify/backend/api/name/schema.grapqhl, or elsewhere) which models SHOULD be using DataStore, and which models shouldn't (or should be somehow ignored by DataStore)?
Would anything break or return unexpected behavior (behind the scenes, in Amplify, in AppSync, etc) if I enable datastore on the entire API, but one of my models uses an @function resolver?
@armenr Please did you get any response to your question above, if you've find anyway around it, can you possibly share as I'm in the same consideration of using @function resolver one of my models. Thanks.
Any response from @undefobj is also appreciated.
@Johnhollack - Never got a reply or clear answer to that one, unfortunately. :-\
Which Category is your question related to? DataStore,
@function
directiveAmplify CLI Version 4.21.1
How does one use the
@function
directive on a query when using the DataStore? I know I can edit the .vtl files, but is it possible to use@function
in combination with the DataStore, and if so, is there an example available? I am trying to use a Lambda resolver in one of the DataStore queries.