Attach Your Database Tables to the AppSync GraphQL API

After you implement the example solution outlined here, you can explore how to surface your database tables to Amazon AppSync and Salesforce.

If your database tables are in the same Amazon RDS instance as the example solution, complete these AWS configuration steps. See Attach Applied Discount Database Table.

  1. Update the schema.

    1. From the Amazon AppSync console, go to the Schema page.
    2. In the editor, add the type and input declarations for the database table. To get the syntax correct, follow the Graphqlsample_MyOrder pattern.
    3. Choose Save Schema.
  2. Attach the resolver to the query and mutations for the new database table.

    1. In the navigation pane of the Amazon AppSync Console, choose Schema.
    2. In the Resolvers section, choose the query or mutation, and then click Attach.
    3. In Create new resolver, choose the Lambda function from the dropdown list.

    Repeat the process to attach the resolver for all the queries and mutations defined in the GraphQL schema. For example, if the Salesforce Connect adapter for GraphQL can perform create, read, update, and delete operations on records, attach the resolver four times.

  3. Add additional entries in the Parameter Store to capture the table metadata.

    1. Open the AWS Systems Manager console.
    2. In the navigation pane, choose Parameter Store.
    3. Follow the Graphqlsample_MyOrder example and create an additional parameter for the database table, including the fieldTypes and keyColumns.

If your database tables are in a different Amazon RDS instance, you must complete additional configuration steps. Add the Amazon RDS credentials to the Secrets Manager, and set up the port forwarding so that the resolver can have a persistent connection to the RDS. If necessary, contact AWS Support for help with setting up this configuration.

After the new GraphQL type is added to the API endpoint and validated, complete these Salesforce configuration steps.

  1. Edit your external data source definition.
  2. Sync the metadata so that Salesforce Connect can sync the new objects and fields required for the new database table.
  3. Decide where you want to surface this external data in the Salesforce UI, and make the required updates.