Reputation: 425
I am working on an app which allows users to upload resources to the internet.
I'm struggling with how to write a resolver for fetching resources posted by a specific user.
I have 3 DynamoDB tables
UserTable
-> a collection for userPostTable
-> a collection for resourcesPostUserTable
-> a collection for storing relations between User and PostIn a traditional RDBS, it would be done by joining 2 tables(UserTable
and PostTable
) using PostUserTable
. Even though DynamoDB, or any kinds of NoSQL database allows us to have a more flexible way to store data, I expect(hope) each user has many resources at the end of the day, so I decided to design tables in the same way as RDMS.
But I'm not sure how you can write a resolver for filtering posts only by a specific user? I have a graphql query named getMyPosts
and I want it to return posts uploaded by me.
Upvotes: 1
Views: 2224
Reputation: 3683
If you go to the AppSync console and click "Attach" on a field to add a resolver, there is a drop down in the top right of each resolver template code editor that has a number of commented examples of how to craft resolver templates for DynamoDB. This is a good place to start and has multiple examples of filters and more. You can read more about the full DynamoDB filter syntax here: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.html#Query.FilterExpression.
Upvotes: 1