banner 728x90

New AWS AppSync functions and deletion on the whitelist

banner 728x90

At AWS re: Invent 2017 we announced AWS AppSync, a managed GraphQL service with offline and real-time data capabilities. Based on feedback from customers, we have added the following new features for building applications with AWS AppSync.

  • Ability to automatically generate a GraphQL schema and resolvers of an existing Amazon DynamoDB table
  • Android support for offline questions and mutations
  • Interface and union support in GraphQL schema & # 39; s
  • A "local" resolver to perform data conversion or publish actions using subscriptions
  • Ability to access headers of requests, including custom headers, within a GraphQL resolver
  • Resolver helper functions for common tasks
  • AWS CloudTrail support

Please refer to the AWS AppSync documentation for more information about these functions.

In addition to the above functions, access to the whitelist for the use of AWS AppSync Preview has been removed. Now anyone with an AWS account can start to try GraphQL with AWS AppSync today. You can get started using the AWS AppSync console.

Autogenerate GraphQL from DynamoDB

For the launch of AWS AppSync, we have included the functionality to write a GraphQL schema and automatically provide DynamoDB tables with resolvers. If you have existing DynamoDB tables, or if you want to create tables first and then "connect" them with a GraphQL API, AWS AppSync now supports this feature without having to write a GraphQL schema or resolvers. This means that with a few clicks you can take any DynamoDB table and create a GraphQL endpoint, including offline and real-time functionality.

Go to the Data Resources section of your GraphQL API in the AWS AppSync console, select New and add a descriptive name. Use a data source type of Amazon DynamoDB and choose the table you want to import. Select the switch at the bottom to "Automatically generate GraphQL" and two editors are shown. The top editor is to adjust the type that contains data from the DynamoDB table and the bottom editor is a read-only view of the GraphQL schema that will be merged. You can change the name of the type in the top editor, as well as all DynamoDB non-key attributes that you want to include in the GraphQL type.

You see CRUDL + Query operations translated into GraphQL types, queries, mutations and subscriptions. The query & # 39; s and mutations are created in your schema and contain both primary and sort keys from the DynamoDB table (if the keys are present) and any secondary indices. Resolvers are automatically set for you. If necessary, you can adapt them to your needs later on. If you navigate to the Queries tab of the AWS AppSync console, you can perform GraphQL queries or mutations against your table.

new aws appsync functions and deletion on the whitelist - New AWS AppSync functions and deletion on the whitelist

Android support and custom headers

AWS AppSync is a GraphQL-compatible service and any GraphQL-compatible client can use an endpoint. Because AWS uses AppSync GraphQL over HTTP, you can also specify custom headers. From today's launch these are available in your resolvers. For example, you can easily send a GraphQL mutation with curl if you enter an API key, plus an extra header:

  curl -XPOST -H "Content type: application / graphql" -H "modified: mytest" 
-H "x-api-key:  -d & # 39; {" query ":" query  & # 39; 
https: //  / graphql

The modified header of will be available in your resolver until $ context.request.headers.custom

Speaking on GraphQL-compatible clients, at re: Invent we launched full support for iOS and JavaScript clients. This includes web (React, Vue, etc.) and hybrid (React Native, Ionic) technologies. Today we are launching an extra SDK that allows customers using the Apollo client for Android to use all authorization functions and offline functionality of AWS AppSync. You can get started by including the AWS AppSync dependencies in your build.gradle file and then instantiating the client:

  AWSAppSyncClient client = AWSAppSyncClient.builder ()
Context (context)
.credentialsProvider (getCredentialsProvider (context))
.region (Constants.APPSYNC_REGION)
.serverUrl (Constants.APPSYNC_API_URL)
.building ()  

Offline storage, including mutations and persistence in case of app crashes, is fully supported by the SDK. Refer to the tutorial documentation for more information.

Local resolvers

Real-time database functionality in AWS AppSync comes with GraphQL subscriptions. Any data source in AWS AppSync can even use subscriptions and can trigger notifications from subscriptions to clients in response to a mutation. However, many customers build post-processing or out-of-band systems that can change data independently. Yet they still want to activate a GraphQL subscription notification without actually changing data.

To help customers with this, we have introduced a new data source called "None", which can be linked to a "local solver". When you define a field in your GraphQL schema and use this local resolver, the resolver processes the template logic for requests and response mapping without leaving AWS AppSync and returning results to the caller.

The local resolver offers interesting uses. First, you can use the @aws_subscribe () directive about a mutation with this resolver to publish data to clients without making any changes to a database. For example, a Lambda function can call GraphQL mutations to AWS AppSync in response to an event that takes place, such as processing data that has been uploaded to an S3 bucket. Second, you can still use Velocity Template Language (VTL) to run logic on data passed to the resolver. Because VTL is a logical language, it may be for mathematical calculations, string operations on lists and maps, or Graphrite type format fields that are children in a query that returns values ​​from DynamoDB.

Resolver helper functions

We also continue to simplify corporate logic for developers who need to customize resolverization templates in the GraphQL engine.

Firstly, we have added an extensive program guide to the AWS AppSync documentation. New features, such as importing existing DynamoDB tables or creating resources from a GraphQL schema, reduce the need to edit resolvers. However, applications such as authorization checks, server-side validation and data generation and input validation require that customers can edit the logic. The programming guide is meant to give a "cookbook-like" tutorial on the use of the VTL language with GraphQL, so that these use cases become easier

Second, we've added a number of new tools to make it easier to run logic, generate and validate data. There are also tools for automatically assigning data to and from DynamoDB tables. Allows you to add or remove fields of user types in a GraphQL schema without even editing a resolver.

  • $ utils.isNull () $ utils.isNullOrEmpty () for conditional validation of data
  • $ utils.list.copyAndRemoveAll () $ utils.list.copyAndRetainAll () and related key operations for filtering / mapping lists
  • $ utils.validate () and $ utils.matches () to perform conditional checks, to give error messages and to agree regular expressions
  • $ utils.typeOf () $ utils.isMap () $ utils.isList () $ utils.isString () $ utils.isNumber ()

There are also several new tools for generating server time stamps. You can automatically insert these into databases for GraphQL operations, as well as for parsing and formatting. Here are a few examples:

  • $ utils.time.nowISO8601 () $ utils.time.nowEpochSeconds () and $ utils.time.nowEpochMilliSeconds ()
  • $ util.time.nowFormatted () and $ util.time.parseFormattedToEpochMilliSeconds ()
  • $ util.time.epochMilliSecondsToSeconds () and $ util.time.epochMillisecondsToISO8601 ()

We also introduced a collection of utilities called $ utils.dynamodb to automatically map GraphQL input arguments to DynamoDB attributes. This is useful if you only want to work in a GraphQL schema and iterates quickly by typing by adding and removing fields. Instead of adding or removing the corresponding attributes in the mapping template, this helper expands and contracts if applicable, passing the values ​​to DynamoDB for persistence. Read more about this in the documentation.

Finally, you can also use $ utils.dynamodb.toS3Object () when using Amazon S3 and GraphQL with the AWS AppSync complex object function. This makes it easy to store content such as images or video with GraphQL. This creates an S3 link, a JSON persistence structure in DynamoDB with a reference to Amazon S3. The object can be uploaded or downloaded immediately. This new helper converts GraphQL query & # 39; s and mutations using S3Object types. It saves them with S3 link notation, so that other back-end systems and languages, such as Java, can use POJO methods to manage the same data.

See the complete list of supported tools & # 39; s and their descriptions for more information.

Get started with AWS AppSync today

View the & # 39; Getting started & # 39; documentation in the AWS AppSync Developer Guide, as well as some of the example apps online. We are excited to hear your feedback on these features and see what you are building with AWS AppSync. If you have any questions, you can contact us at any time on the AWS AppSync forum.

banner 728x90
    Resetting of file changes with git
    Resetting of file changes with git
    There are many different philosophies when it
    DDoS protection by Incapsula (sponsored)
    DDoS protection by Incapsula (sponsored)
    DDoS security is an incredibly important protection
    Long e-mail discussions: Be Gone !!
    Long e-mail discussions: Be Gone !!
    We've all been working on those long
    Changes to permissions for AWS Mobile Hub
    Changes to permissions for AWS Mobile Hub
    Until recently, when you first created an

    Leave a reply "New AWS AppSync functions and deletion on the whitelist"

    Must read×