Front-End Web & Mobile
AWS AppSync releases an enhanced “no-code” GraphQL API builder, HTTP resolvers, new built-in scalar types, and SDK cache abstraction
September 14, 2021: Amazon Elasticsearch Service has been renamed to Amazon OpenSearch Service. See details.
This past week at the AWS Summit – New York, we announced some new features for AWS AppSync and the client SDK. We’ve been working closely with developers in the community to enhance their experience in building applications, and the features incorporate their feedback. The new features include:
- More sample schemas in the console.
- A “no-code” GraphQL API builder that includes built-in filtering capabilities.
- HTTP data sources.
- Velocity Template Language (VTL) auto-complete for editing resolvers.
- Enhanced GraphQL scalar types.
- Cache abstraction in the SDK for subscriptions and offline programming.
For more details on these features, see the AWS AppSync Developer Guide and the AWS AppSync client SDK repository (on GitHub).
“No-code” GraphQL API builder and sample schemas
Many developers love to use GraphQL for building APIs. However, there’s a bit of a learning curve for customers who are just getting started. To help with this, we’ve added a couple of new capabilities. First, many people like to work backwards from a full example. When you create a new API, you’ll see new samples. The samples include the ChatQL example Progressive Web App (PWA) written in Angular. This is a fully functioning chat application that includes fine-grained user authorization.
If you’re a developer who wants to “build a custom schema” from scratch but you’ve never written a GraphQL schema before, you can now navigate to the schema page and select the “Create Resources” flow immediately, without an initial schema. The previous capability is still in place, where you can provision Amazon DynamoDB tables from defined types in your schema. But now you have the option to add new types in this flow. The entire schema is created for you, including DynamoDB tables and resolver connections.
Additionally, this new functionality has built-in filtering capabilities for DynamoDB, with new resolver utilities. This is helpful if you want to do complex querying, searching, comparisons, or filters on data just by using DynamoDB (for prototyping or applications that don’t need the full capabilities of Amazon OpenSearch Service (successor to Amazon Elasticsearch Service)).
Learn more about this functionality in the AWS AppSync documentation.
HTTP data sources
HTTP data sources are now supported in AWS AppSync. This feature can be useful when you’re trying to add GraphQL interfaces to existing backends, as well as when you’re aggregating and combining information from multiple data sources. You can pass HTTP options (such as query strings, headers, and Content-Type), and also control the resource path.
The response template for a resolver on an HTTP data source can also perform conditional checks on the returned status code. This allows you to control the GraphQL response, such as appending with error information. Additionally, there’s a new XML utility class for converting to JSON in the resolver templates. This can be helpful for connecting to legacy backends where you want to have GraphQL clients connecting to them, but the legacy backends respond with XML payloads. For more information about HTTP data sources, see the AWS AppSync documentation.
VTL auto-complete
In addition to the new features for HTTP data sources and improved setup, we’ve also added a new feature for advanced AWS AppSync developers who are editing or writing resolvers. In the console, when you type a dollar sign ($), you’ll see a list of available utilities and objects, including items in the resolver context. You can scroll through these when you’re editing or writing resolvers for a more streamlined experience.
GraphQL scalar types
You can now specify additional GraphQL scalar types in your AWS AppSync schema—such as email addresses, phone numbers, or dates. AWS AppSync validates the content of these fields before a resolver is invoked. You can find the full list of supported types in the AWS AppSync documentation.
SDK cache abstraction
In addition to the new service features, we’ve also been working with our client developer community on ways to improve the programming experience. Many customers have asked that we offer more opinionated capabilities around areas such as managing the Apollo cache, in order to reduce boilerplate and code duplication. Based on this feedback, we’ve released new functionality to the AWS AppSync SDK that performs:
- Automatic subscription payload merges into the cache.
- Automatic optimistic UI, online or offline, including support for multiple queries.
- Support for GraphQL connections on a single field.
- Automatic version control.
- Support for descendent mutations (for example, creating an object, and then updating it immediately while offline).
These new features are in the base AWS AppSync JavaScript SDK, but we also provide some React Higher Order Components (HOCs) that are optimized as well. An example of the new code vs. the old code is shown in the following image. The image shows how the new abstraction helpers can simplify offline or online cache management with GraphQL connections and non-standard type identifiers (‘commentId’ rather than ‘id’).
Learn more about this new functionality in the AWS AppSync JavaScript SDK tutorial and documentation.