Access amplify generated GSI from Lambda function
Amplify CLI Version
8.3.0
Question
I've added a Lambda function and am able to access GSI of DDB tables where I have explicitly added @index within a model.
For amplify generated GSI, where I use @belongsTo, I can see it propogates a GSI for me. Is it possible to access this index from my Lambda function? If so, how do I proceed?
For more clarity, I'm wanting to access the parent item of an item within one of my DDB tables, so that when I update this item it also updates the parent.
Let me know if you need more information or if any of the above is unclear.
Thanks in advance!
Hey @mnikolic10 :wave: thanks for raising this! From the details you've provided it sounds like calling the GraphQL API using the GSI's query field would be sufficient https://docs.amplify.aws/lib/graphqlapi/graphql-from-nodejs/q/platform/js/#commonjs
Are you looking to interact with DynamoDB directly from your Lambda? If so, direct SDK calls would be the suggestion, however I feel for this use case calling GraphQL directly using a private IAM auth rule would be the recommended path.
I am already using the aws sdk to interact with my tables, ill take a look at the link you mentioned. Thanks for your help!
@mnikolic10 absolutely! If you are also using subscriptions in your frontend app I believe it is also recommended to make changes via GraphQL.
I will close this issue for now, however please feel free to reply back and we can re-open to continue investigating!