1. 程式人生 > >New AWS AppSync features and whitelist removal

New AWS AppSync features and whitelist removal

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

  • Ability to autogenerate a GraphQL schema and resolvers from an existing Amazon DynamoDB table
  • Android support for offline queries and mutations
  • Interface and union support in GraphQL schemas
  • A “local” resolver to perform data transformations or publish actions using subscriptions
  • Ability to access request headers, including custom headers, within a GraphQL resolver
  • Resolver helper functions for common tasks
  • AWS CloudTrail support

For more details on these features please reference the AWS AppSync documentation.

In addition to the above features, whitelist-only access for using the AWS AppSync Preview has been removed. Now anyone with an AWS account can begin trying out GraphQL with AWS AppSync today. You can get started by using the AWS AppSync console.

Autogenerate GraphQL from DynamoDB

For the launch of AWS AppSync, we included the functionality to write a GraphQL schema and provision DynamoDB tables with resolvers automatically. If you have existing DynamoDB tables, or wish to create tables first then “connect” them to a GraphQL API, AWS AppSync now supports this capability without you needing 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 from it, including offline and realtime functionality.

To do this, navigate to the Datasources section of your GraphQL API in the AWS AppSync console, choose New, and add a friendly name. Use a data source type of Amazon DynamoDB, and choose the table you wish to import. Select the toggle at the bottom to “Automatically generate GraphQL” and two editors will be exposed. The top editor is for customizing the type which will hold data from the DynamoDB table and the bottom editor is a read-only view of the GraphQL schema which will be merged. You can change the type name in the top editor as well as any DynamoDB non-key attributes that you wish to be included in the GraphQL type.

You’ll see CRUDL + Query operations translated to GraphQL types, queries, mutations, and subscriptions. The queries and mutations were created in your schema, and account for both primary and sort keys from the DynamoDB table (if the keys are present) as well any Secondary Indices. Resolvers are automatically set up for you. You can later customize them for your needs, if necessary. If you navigate to the Queries tab of the AWS AppSync console, you can run GraphQL queries or mutations against your table.

Android support and custom headers

AWS AppSync is a GraphQL-compliant service, and any GraphQL-compliant client can use an endpoint. Because AWS AppSync uses GraphQL over HTTP, you can also pass in custom headers. As of today’s launch, these are available in your resolvers. For example, you can simply send a GraphQL mutation using curl if you provide an API key, as well as an extra header:

curl -XPOST -H "Content-Type:application/graphql" -H "custom:mytest" \
-H "x-api-key:<API_KEY> -d '{"query" : "query { getInfo(){id name }"}' \
https://<ENDPOINT>/graphql

The customheader will be available in your resolver through$context.request.headers.custom

Speaking of GraphQL-compliant clients, at re:Invent, we launched full support for iOS and JavaScript clients. This includes web (React, Vue, and so on) and hybrid (React Native, Ionic) technologies. Today we’re launching an additional SDK that enables customers using the Apollo client for Android to leverage all the authorization features 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)
    .build();

Offline storage, including mutations and persistance across application crashes, is fully supported with the SDK. To learn more please see the tutorial documentation.

Local resolvers

Real-time database functionality in AWS AppSync is provided with GraphQL subscriptions. In fact, any data source in AWS AppSync can use subscriptions, and can trigger subscription notifications to clients as a response to a mutation. However, many customers are building post-processing or out-of-band systems that might alter data independently. Yet they still want to trigger a GraphQL subscription notification without actually changing data.

To help customers with this, we’ve introduced a new data source called “None”, which can be attached to a “local resolver”. When you define a field in your GraphQL schema and use this local resolver, the resolver processes the request and response-mapping template logic without leaving AWS AppSync, and returns results to the caller.

The local resolver opens up some interesting use cases. First, you can use the @aws_subscribe() directive on a mutation with this resolver to publish data to clients without actually making changes to a database. For example, a Lambda function could invoke GraphQL mutations to AWS AppSync in response to some event that takes place, such as processing data that’s uploaded to an S3 bucket. Second, you can still use Velocity Template Language (VTL) to perform logic on data that’s passed to the resolver. Because VTL is a logic-full language, this could be for mathematical computations, string operations over lists and maps, or formatting fields of a GraphQL type that are children in a query that returns values from DynamoDB.

Resolver helper functions

We’re also continuing to make writing business logic easier for developers who need to customize resolver mapping templates in the GraphQL engine.

First, we’ve added a comprehensive programming guide to the AWS AppSync documentation. New features like importing existing DynamoDB tables or creating resources from a GraphQL schema reduce the need for editing resolvers. However, use cases like authorization checks, server-side validation and data generation, and input validation require the ability for customers to be able edit the logic. The programming guide aims to give a “cookbook-style” tutorial on using the VTL language with GraphQL so that these use cases become easier.

Secondly, we’ve added a variety of new utilities to make it easier to perform logic, generate data, and validate. There are also utilities for automatically mapping data to and from DynamoDB tables. This should allow you to add or remove fields from user types in a GraphQL schema without even needing to edit a resolver.

  • $utils.isNull(), $utils.isNullOrEmpty() for data validation conditionals
  • $utils.list.copyAndRemoveAll(), $utils.list.copyAndRetainAll() and related key operations for filtering/mapping over Lists
  • $utils.validate() and $utils.matches() to perform conditional checks, provide error messages, and regular expression matching
  • $utils.typeOf(), $utils.isMap(), $utils.isList(), $utils.isString(), $utils.isNumber()

Also there are several new utilities for generating server time stamps. You can auto-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’ve also introduced a collection of utilities, called $utils.dynamodb to automatically map GraphQL input arguments to DynamoDB attributes. This is helpful when you just want to work in a GraphQL schema and are quickly iterating on types by adding and removing fields. Instead of needing to also add or remove the corresponding attributes inside the mapping template, this helper expands and contracts as appropriate, passing the values to DynamoDB for persistence. Read more about this in the documentation.

Finally, you can also use $utils.dynamodb.toS3Object() when you use Amazon S3 and GraphQL with the AWS AppSync complex object feature. This makes it easy to store content, such as images or video, with GraphQL. This creates an S3 link, which is a persistence JSON structure in DynamoDB with a reference pointer to Amazon S3. The object can be directly uploaded or downloaded. This new helper converts GraphQL queries and mutations by using S3Object types. It stores them with S3 link notation so that other backend systems and languages, like Java, can use POJO methods to manage the same data.

Get started with AWS AppSync today

Check out the getting started documentation in the AWS AppSync Developer Guide, as well as some of the sample apps online. We’re excited to hear your feedback on these features and see what you’re building with AWS AppSync. If you have any questions, you can connect with us any time on the AWS AppSync forum.

相關推薦

New AWS AppSync features and whitelist removal

At AWS re:Invent 2017, we announced AWS AppSync, which is a managed GraphQL service with offline and real-time data capabilities. Based on custome

AWS AppSync region expansion and new features for API keys

AWS AppSync, a managed GraphQL service with offline and real-time data capabilities, recently launched a set of new features. Following up on thes

AWS Announces New Amazon SageMaker Capabilities and Enhancements

Amazon Web Services recently announced that users now have the ability to build an Amazon SageMaker notebook from the AWS Glue Console and then connect it

AWS AppSync releases new guided API builder

Today, we’re launching a new guided API builder for AWS AppSync. Before today, knowing GraphQL was a prerequisite for building an AWS AppSync API

new features and finally available on PyPI! | The No Title® Tech Blog

Here are some highlights:A new big feature: “convert big PNG files to JPG format”, with an option to convert all PNG files.Added a new option to set backgr

Count Files v1.4 – new features and finally available on PyPI!

The latest release of this file counting command-line utility has just been released. It is a platform independent (pure Python) package that makes it easy

New AWS Public Data Sets – TCGA and ICGC

My colleagues Angel Pizarro and Ariel Gold wrote the incredibly interesting guest post below. — Jeff; Today we are please

Introducing AWS AppSync – Build data-driven apps with real-time and off-line capabilities

In this day and age, it is almost impossible to do without our mobile devices and the applications that help make our lives easier. As our depende

Highlights of Products with Major New Features and Enhancements--強調產品的主要新特性和增強功能

Highlights of Products with Major New Features and Enhancements 強調產品的主要新特性和增強功能 This section highlights some of the major new features and enhancements in

AWS CSAA -- 04 AWS Object Storage and CDN - S3 Glacier and CloudFront(一)

ron 圖片 buck storage gpo eat img bsp reat 013 S3 - 101 014 Create an S3 Bucket - Lab AWS CSAA -- 04 AWS Object Storage and CDN - S3 Gla

Microsoft Azure Features and Services Introduction

Microsoft Azure TraiJuly 1, 2017& Sep 9,2017 I introduced the Azure function and service for the incubator of the Microsoft Incubator in Fuzhou. The

Linear classifiers do not share parameters among features and classes

一、概述 標題來自Bag of Tricks for Efficient Text Classification,就是fasttext這篇文章 二、簡析 1、解析 下述截圖來自:https://datascience.stackexchange.com/questions

Adaptive Bilateral Filter for Sharpness Enhancement and Noise Removal 閱讀理解

        ABF則是一直新的基於訓練的影象恢復演算法,它的範圍是處理適合數碼攝影的圖片,不考慮那些嚴重退化的影象。影象恢復演算法的廣泛應用的成功將取決於演算法開發的退化模型的一般程度,以及演算法的整體結構對偏離假設的退化模型的程度有多強。 &nb

Researchers Discover Two New Chinese Dinosaurs: Bannykus and Xiyunyk oowebdesign us

www.inhandnetworks.com Bannykus restoration (Image by SHI Aijuan) Digit reduction occurs many times in tetrapod evolution, and the most famous

Adaptive Bilateral Filter for Sharpness Enhancement and Noise Removal 閱讀理解

        ABF則是一直新的基於訓練的影象恢復演算法,它的範圍是處理適合數碼攝影的圖片,不考慮那些嚴重退化的影象。影象恢復演算法的廣泛應用的成功將取決於演算法開發的退化模型的一般程度,以及演算法的整體結構對偏離假設的退化模型的程度有多強。        ABF通過增加

Announcing Amplify's New Machine Learning Capabilities and Guided A/B… Outreach

The pressure and expectation of sales reps to be more efficient and effective at their trade, more focused on higher profitability, and more reliant on dat

Crafting a New Reality for Education and Career Decisions: Lead With UX

Written by: Daniel Salcius | Photo by: Ferdinand StohrCrafting a New Reality for Education and Career Decisions: Lead With UXThe take-away feeling an end u