1
votes

I have 2 types:

type Location {
    id: ID!
    room: Int
    title: String
}

type Populate {
    id: ID!
    locationID: ID!
    location: Location
}

I need to populate the location field when I call the GraphQL api. Locations are stored in DynamoDB. I know that a resolver is necessary but I haven't been a exactly how to write it. Thanks for the help!

1

1 Answers

1
votes

You can do this via AWS AppSync Console. When you try and attach a resolver to an existing field in your schema, AppSync gives you certain pre-defined resolver templates out of the box. You can use those to connect to your DynamoDB DataSource.

Refer to the following documentation to attach a resolver.

Alternatively, you can use AWS Amplify to use @connection directive to specify relationship between your Location and Populate types. This will transform it into a fully descriptive CloudFormation template and create DynamoDB tables, give you CRUDL based queries/mutations. It will also scaffold Resolver templates for the same.