I have a new Amplify Gen 2 project ( NextJS 14 app) that uses DynamoDB and also needs to access existing AppSync GraphGL API.
Existing API is added to the app first by running
amplify add codegen --apiId XXXXXXXXXXXXXXX
and adding:
Amplify.configure({
API: {
GraphQL:{
apiKey:"da2-XXXXXXXXXXXXXXXXXX",
region:"us-east-1",
defaultAuthMode: "apiKey",
endpoint: "https://XXXXXXXXXXXXX.appsync-api.us-east-1.amazonaws.com/graphql"
}
}
});
I can’t figure out how to distinguish between two graphql endpoints. When the above code is added integration with DynamoDB stops working.
I can make one or the other work but not both at the same time.
Should it be possible to use AppSync and DynamoDB at the same time?
2
Answers
Creating new API that was a "Merged APIs" of both of the other ones seems to be a way to fix this issue.
Yes, it’s possible to use both AppSync and DynamoDB at the same time. You need to configure them separately in Amplify. For AppSync, you can use
Amplify.API
and for DynamoDB, you can useAmplify.DataStore
orAWS.DynamoDB.DocumentClient
if you’re using the AWS SDK directly.Example