Posted On: May 31, 2022
AWS AppSync is a fully managed service that makes it easy to create and manage GraphQL and Real-time APIs, allowing developers to securely access, manipulate, and combine data from one or more data sources via a single API endpoint. With GraphQL, special functions called Resolvers are used to implement business logic linking or “resolving” types, fields, or operations defined in the GraphQL schema with the data in data sources such as Amazon DynamoDB, AWS Lambda, HTTP APIs, and more.
Resolvers in AppSync support flexible integrated utilities that allow developers to automatically generate identifiers ($util.autoId and $util.autoUlid), parse ($util.parseJson) or convert JSON ($util.toJson), perform URL/base64 encoding ($util.urlEncode) or decoding ($util.base64Decode), generate and convert timestamps ($util.time.nowISO8601), convert XML to JSON ($utils.xml), perform authorization checks, validate formatting and conditions, and much more, all directly in the AppSync API layer. There is no need to create your own logic to perform these tasks in AppSync resolvers.
Today we’re adding two new utilities AppSync developers can add to their serverless GraphQL development toolbox: $util.autoKsuid and $util.log. With the new utilities AppSync can now automatically generate KSUIDs (K-Sortable Unique IDentifiers), which are naturally sorted identifiers by generation timestamp without any special type-aware logic, and to send a string or object from a resolver directly to CloudWatch Logs, which makes it easier to troubleshoot and debug GraphQL resolver code.