aws-appsync

How return JSON object from DynamoDB with appsync?

一世执手 提交于 2019-12-01 00:07:37
How I can get JSON object in response from DynamoDB ? I store data in DB as array of object in format JSON. I have next mapping template request { "version": "2017-02-28", "operation": "PutItem", "key": { "userId": { "S": "$context.identity.username" } }, #set( $attrs = $util.dynamodb.toMapValues($ctx.args)) #set( $attrs.categories = $util.dynamodb.toDynamoDB($ctx.args.categories)) "attributeValues": $util.toJson($attrs) } and mapping template response #set( $result = $ctx.result) #set( $result.categories = $util.parseJson($ctx.result.categories)) $util.toJson($result) but I got response in

AWS Cognito/Amplify - have new user sign ups be automatically add to a user group

六眼飞鱼酱① 提交于 2019-11-30 11:55:50
问题 I am using AWS Amplify library to sign up and perform Auth for an AppSync project. This uses Cognito. However, when a new user signs up via Amplify/Cognito, the new user isn't assigned to any specific group in the cognito pool. I am using the Amplify higher order component for login/signup. import { withAuthenticator } from 'aws-amplify-react'; which I wrap over a component class Authenticator extends React.Component { //... basically empty component, only exists so I can wrap it w/ the HOC }

AppSync: Get user information in $context when using AWS_IAM auth

一笑奈何 提交于 2019-11-30 02:14:59
In AppSync, when you use Cognito User Pools as your auth setting your identity you get identity: { sub: 'bcb5cd53-315a-40df-a41b-1db02a4c1bd9', issuer: 'https://cognito-idp.us-west-2.amazonaws.com/us-west-2_oicu812', username: 'skillet', claims: { sub: 'bcb5cd53-315a-40df-a41b-1db02a4c1bd9', aud: '7re1oap5fhm3ngpje9r81vgpoe', email_verified: true, event_id: 'bb65ba5d-4689-11e8-bee7-2d0da8da81ab', token_use: 'id', auth_time: 1524441800, iss: 'https://cognito-idp.us-west-2.amazonaws.com/us-west-2_oicu812', 'cognito:username': 'skillet', exp: 1524459387, iat: 1524455787, email: 'myemail@nope.com'

How to upload an image to AWS S3 using GraphQL?

♀尐吖头ヾ 提交于 2019-11-29 18:35:51
问题 I'm uploading a base64 string but the GraphQL gets hung. If I slice the string to less than 50,000 characters it works. After 50,000 characters, graphQL never makes it to the resolve function, yet does not give an error. On the smaller strings, it works just fine. const file = e.target.files[0]; const reader = new FileReader(); reader.readAsDataURL(file); reader.onloadend = () => { const imageArray = reader.result; this.context.fetch('/graphql', { body: JSON.stringify({ query: `mutation

How to upload file to AWS S3 using AWS AppSync

北战南征 提交于 2019-11-28 05:27:24
Following this docs/tutorial in AWS AppSync Docs. It states: With AWS AppSync you can model these as GraphQL types. If any of your mutations have a variable with bucket, key, region, mimeType and localUri fields, the SDK will upload the file to Amazon S3 for you. However, I cannot make my file to upload to my s3 bucket. I understand that tutorial missing a lot of details. More specifically, the tutorial does not say that the NewPostMutation.js needs to be changed. I changed it the following way: import gql from 'graphql-tag'; export default gql` mutation AddPostMutation($author: String!,

How to upload file to AWS S3 using AWS AppSync

徘徊边缘 提交于 2019-11-27 00:45:50
问题 Following this docs/tutorial in AWS AppSync Docs. It states: With AWS AppSync you can model these as GraphQL types. If any of your mutations have a variable with bucket, key, region, mimeType and localUri fields, the SDK will upload the file to Amazon S3 for you. However, I cannot make my file to upload to my s3 bucket. I understand that tutorial missing a lot of details. More specifically, the tutorial does not say that the NewPostMutation.js needs to be changed. I changed it the following