By default AWS Amplify transformers creating tables per each graphql type.
But according DynamoDB documentation it's best practice to
I have an impression Amplify way of doing things stays in contradiction with the statement above.
I am new to both NoSQL and Amplify Can someone suggest ways to address those issues?
I think we're in a bit of a transition or gray area here. I'm very new to Amplify and have been investigating moving to a single-table design as there are sources (below) that indicate that it's always be there but you'd have to write everything in VTL templates. But in 2020 they released direct lambda resolver support: https://youtu.be/EOQqi6Yun7g?t=960 (clip)
However, it seems like you lose access to the @auth
directive (and probably others because you're no longer going to use @model
) along with a lot of the nice out-of-the-box functionality that's available with Amplify's multi-table approach.
At this point, being that I'm developing a new app, I'm going to stick with the default multi-table design to hasten the process of getting the app functional.
Trying to implement the single-table design seems to go against what the Amplify team recommends and requires more manual work. You'd have to manually create custom lambda functions (AppSync) and code queries to DynamoDb for each data access element and manage authorization through some other means which I'm not aware of at this time. Maybe someone can chime in here...
Using Amplify with single table: https://youtu.be/EOQqi6Yun7g
Single vs Multi Clip:
Example single table design by Alex Debrie: https://gist.github.com/dabit3/96dc51e688b18a7d40fc534331758c56
More Discussion: https://stackoverflow.com/a/56438716/1956540
I setup a single table by following the below instructions. Again, you don't use @model
s for this. Also, I think you have to include a type query {}
in your schema for it to compile, but I could be wrong here.
So the basic steps are:
schema.graphql
file.Complete steps for Setting up a single Table:
https://catalog.us-east-1.prod.workshops.aws/workshops/53b10bf8-2271-4ab4-bfd2-39e878a90dc8/en-US/lab2/1-vtl (both "Connecting to an existing DynamoDB table" and "Direct Lambda Resolver" steps)
Not trying to be negative about Amplify, it is awesome, I love what they are doing with this product. I just think it's very new to everyone and I'm hoping this post is no longer valid next year and we continue to see great progress from the team.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With