Skip to content

teamplanes/AppSync-Cheatsheet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 

Repository files navigation

AppSync Cheatsheet

Mapping (VTL)

Context

{
   "arguments" : { ... },
   "source" : { ... },
   "result" : { ... }, ## Only present in the response
   "identity" : { ... }
}

identity

If you are using Cognito for authentication your itentity object will look like:

{
    "sub" : "uuid", ## <- Main user UUID
    "issuer" : "string",
    "username" : "string"
    "claims" : { ... },
    "sourceIp" : "x.x.x.x",
    "defaultAuthStrategy" : "string"
}

Examples for reference

List all items

Request

    {
      "version" : "2017-02-28",
      "operation" : "Scan"
    }
  

Response

    $util.toJson($ctx.result.items)
  

Getting sub-list of resources for a parent type

Lets say you have schema:

    type List {
      id: ID,
      items: [Item]
    }
    type Item {
      id: ID,
      listId: ID,
      text: String
    }
  

In order to map your items to your type list, you'll do the following:

Request

    {
      "version" : "2017-02-28",
      "operation" : "Scan",
      "filter" : {
          "expression" : "listId = :listId",
          "expressionValues" : {
              ":listId" : { "S" : "${context.source.id}" }
          }
      }
    }
  

Response

    $util.toJson($ctx.result.items)
  

About

WIP: Cheatsheet for everything AppSync

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published