You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have started converting our VTL resolvers to JS resolvers. When run in with CDK they appear to work. When we want to try out new ones or debug, we tried using the in Console Test for a simple resolver but toJsonObject seems to throw a runtime error:
import { sql, createMySQLStatement, toJsonObject } from '@aws-appsync/utils/rds';
export function request(ctx) {
const query = sql`
select
uuid as id,
name as name,
tab_id as groupId,
enforce_ordering as enforceOrder,
DATE_FORMAT(created, '%Y-%m-%dT%H:%i:%s.000Z') as created,
DATE_FORMAT(modified, '%Y-%m-%dT%H:%i:%s.000Z') as modified
from bundles_bundle
WHERE uuid=${ctx.args.id}`
return createMySQLStatement(query);
}
export function response(ctx) {
const { error, result } = ctx;
if (error) {
return util.appendError(
error.message,
error.type,
result
)
}
return toJsonObject(result)[0][0]
}
Additionally the toJsonObject ignores field aliasing and constructs the JSON based on the underlying field name. This is breaking behaviour as it is exceptionally useful to rename returns from the SQL/Stored Procedure.
e.g. SELECT ee.firstname as firstName [whether you include `` around the alias]
is mapped as "firstname": "value" by toJsonObject which is highly undesirable.
We have started converting our VTL resolvers to JS resolvers. When run in with CDK they appear to work. When we want to try out new ones or debug, we tried using the in Console Test for a simple resolver but toJsonObject seems to throw a runtime error:
With a normally working execution context.
{ "arguments": { "id": "b16d57a4-0240-4d2b-aa1c-fb3866a554fe", "batchId": "ACjXZpufRbwAU9h9PnMZFoRARaa1ximM" }, "env": {}, "source": { "task": "{\"key\":\"value\"}" }, "result": { "id": "EGKiGDy8rJ1vxCvjM21wOTQ646Bf0Lkr", "name": "Hello, world!", "enforceOrder": true, "requestId": "aB0W8lF7R125SN6YfnLHlCRoAeDpEhmo", "created": "1970-01-01T12:30:00.000Z", "modified": "1970-01-01T12:30:00.000Z" }, "identity": { "sub": "uuid", "issuer": "https://cognito-idp.{region}.amazonaws.com/{userPoolId}", "username": "my-username", "claims": {}, "sourceIp": [ "x.x.x.x" ], "defaultAuthStrategy": "ALLOW" } }
The text was updated successfully, but these errors were encountered: