Introducing AWS AppSync: serverless data driven apps with real-time and offline capabilities

of 22

Please download to get full document.

View again

All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
22 pages
0 downs
1. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Introducing AWS AppSync: Serverless data driven apps with real-time and offline capabilities…
  • 1. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Introducing AWS AppSync: Serverless data driven apps with real-time and offline capabilities Stefano Sandrini AWS Senior Solutions Architect
  • 2. Traditional Data Fetching Data ü Trivial to set up ü Standard HTTP Calls x Relationships x Lists with reduced information x Query support x Ordering and pagination x Notifications /posts /postInfo /postJustTitle /postsByAuthor /postNameStartsX /postByTag /commentsOnPost REST Endpoints
  • 3. Is There A Better Way ?
  • 4. GraphQL
  • 5. What Is GraphQL? Agnostic of underlying Data Store Optimized for network performance and flexibility Query language for your API and a runtime for fulfilling queries with existing data
  • 6. How does GraphQL work? type Query { getTodos: [Todo] } type Todo { id: ID! name: String description: String priority: Int duedate: String } Model data with application schema query { getTodos { id name priority } } Client requests what it needs { "id": "1", "name": "Get Milk", "priority": "1" }, { "id": "2", "name": "Go to gym", "priority": "5" },… Only that data is returned
  • 7. GraphQL Operations query { search(q: “harry potter”) { title } } Queries Read data mutation { create(title: “new book”) { id } } Mutations Write data subscription { onCreate { id title } } Subscriptions Listen for data
  • 8. GraphQL vs REST /posts /comments /authors REST API posts comments authors GraphQL API
  • 9. GraphQL vs REST Include vs Endpoint & Reduction in call Volumes /posts?include=title,authors /posts?include=title,authors,authors.firstname, authors.lastname posts { title authors { firstname lastname } } { ... “author”:{ “_links”: { “self”: } } ... } REST/RPC GraphQL Hypermedia
  • 10. GraphQL vs REST /graphql posts { title author } Posts (maxSize: 10) { title authorName content } posts { title authorName content } Posts (maxSize: 10) { title author { firstName lastName imageUrl } content } Posts (maxSize: 10) { title author { firstName lastName imageUrl(size:80) } content comments{ user text } }
  • 11. What is AWS AppSync? Managed Serverless GraphQL service Connect to data sources in your account Add data sync, real-time and offline capabilities GraphQL façade for any AWS service Conflict detection and resolution in the cloud Enterprise security features (IAM, Cognito, API keys)
  • 12. Why GraphQL with AppSync? Data Aggregation Bandwidth Optimization Rapid Prototyping Easily evolve APIs Client-defined Data Selection
  • 13. Apps you can build with AppSync Real Time Apps Dashboard Leaderboards Field Service Apps Geo Apps Apps with complex data structure and types Chat Apps
  • 14. AWS AppSync Data Sources
  • 15. AWS AppSync Resolvers
  • 16. AWS AppSync Request Resolvers
  • 17. AWS AppSync Authorization Rules type Post @model @auth( rules: [ {allow: owner, ownerField: "owner", mutations: [create, update, delete], queries: [get, list]}, ]) { id: ID! title: String! content: String! rating: Int owner: String } type Post @model @auth( rules: [ {allow: groups, groupsField: "groups"} ]) { id: ID! title: String! groups: String } get: If the record’s owner is not the same as the logged in user (via $ctx.identity.username), throw $util.unauthorized() get: In the response mapping template verify that the result’s groups attribute contains at least one of the caller’s claimed groups via $"cognito:groups")
  • 18. AWS AppSync Real-time data GraphQL subscriptions enable real-time communication AWS AppSync doubles as a pub-sub broker via MQTT over WebSockets type Mutation { publish: Message } type Subscription { subscribe: Message @aws_subscribe(mutations: [“publish”]) }
  • 19. Jane Version : 2 Updated Document Jane Version : 2 Updated Document Version : 3 Updated Document Version : 1 New Document Time John John Jane goes offline Jane comes back online Version : 4 Updated Document John Jane AWS AppSync Offline mutuation
  • 20. Conflict resolution in the cloud 1. Server wins 2. Silent reject 3. Custom logic (AWS Lambda) - Optimistic version check - Extend with your own checks Optional • Client callback for Conflict Resolution is still available as a fallback { "version" : "2017-02-28", "operation" : "PutItem", "key" : { "id" : { "S" : "1" } }, "condition" : { "expression" : "attribute_not_exists(id)" } } Example: Check that an ID doesn’t already exist: "condition" : { "expression" : "someExpression" "conditionalCheckFailedHandler" : { "strategy" : "Custom", "lambdaArn" : "arn:..." } } Run Lambda if version wrong: AWS AppSync Conflict Resolution and sync
  • 21. AWS AppSync Real-time demo
  • 22. Thank you! © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Stefano Sandrini
  • Related Search
    Similar documents
    View more...
    We Need Your Support
    Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

    Thanks to everyone for your continued support.

    No, Thanks

    We need your sign to support Project to invent "SMART AND CONTROLLABLE REFLECTIVE BALLOONS" to cover the Sun and Save Our Earth.

    More details...

    Sign Now!

    We are very appreciated for your Prompt Action!