0

We have a table in DynamoDB and we need to fetch data from the table using AppSync using AWS Java SDK.

AWSAppSync awsAppSyncClient;

  public UserManagementAppSyncService(AWSCredentialsProvider credentialsProvider) {

    this.awsAppSyncClient = AWSAppSyncClientBuilder.standard()
        .withRegion("eu-central-1")
        .withCredentials(credentialsProvider)
        .build();

}

How to achieve this further? I cannot find further code to do this. Any leads?

The Resolvers were generated from a GraphQL schema using Schema first approach. It is a maven project AND the generated resolvers are in target folder.

Manushi
  • 597
  • 1
  • 7
  • 26

1 Answers1

0

You do not actually need to run your Java code to connect AppSync to DynamoDB. Instead you attach resolvers to your schema and just configure your mappings using VTL language. You can find the documentation of what it can do here.

When you attach a resolver to a graphql field in the AppSync console you can select a sample template that fetches dynamo item by Id: DynamoDB item fetching in AppSync

If you really have to run your own code with custom business logic you can make use of Lambda Resolvers or if you want to skip the mapping template work you can also use Direct Lambda Resolvers

dennis
  • 121
  • 6