I need to write a custom query resolver that consists of a BatchGetItem dynamodb operation where i need to pass the table name. Now i'm stuck getting the table name passed to the resolver using environment variables.
Here is what my resolver looks like:
handler.ts
export function request(
ctx: Context<Schema["customListOrganizations"]["args"]>
): DynamoDBBatchGetItemRequest {
console.log(ctx.env.ORGANIZATION_TABLE);
...
return {
operation: "BatchGetItem",
tables: {
// I need to pass the table name using environment variables
[ctx.env.ORGANIZATION_TABLE]: {
keys: organizationIDs,
},
},
};
}
I tried passing the table name as an environment variable in backend.ts but i'm getting a circular dependency error.
backend.ts
backend.data.resources.cfnResources.cfnGraphqlApi.environmentVariables = {
ORGANIZATION_TABLE: backend.data.resources.tables.Organization.tableName,
};
Does anybody have a solution? Thanks in advance!