This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const UserBlockFunction = () => { | |
return ( | |
<Connect query={graphqlOperation('{ me { id name } }')}> | |
{(response) => { | |
if (response.loading) { | |
return (<LoadingIndicator loading={response.loading}/>); | |
} else if (response.data && response.data.me) { | |
return (<UserBlock name={response.data.me.name}/>); | |
} else { | |
return (<ErrorIndicator errors={response.errors}/>); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async componentWillMount() { | |
try { | |
const result = await API.graphql(graphqlOperation('{ me { id name } }')); | |
console.log('componentWillMount: result = ', result); | |
this.setState({ loading: false, data: result.data.me }); | |
} catch (err) { | |
this.setState({ loading: false, errors: [ err.message ] }); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const AWS = require('aws-sdk'); | |
const process = require('process'); | |
AWS.config.update({ | |
accessKeyId: process.env.AWS_ACCESS_KEY_ID, | |
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY, | |
sessionToken: process.env.AWS_SESSION_TOKEN, | |
region: process.env.AWS_REGION | |
}); | |
const s3 = new AWS.S3(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
custom: | |
appSync: | |
dataSources: | |
- type: AWS_LAMBDA | |
name: ProfilePictures | |
description: Lambda function for the ProfilePictures | |
config: | |
lambdaFunctionArn: { Fn::GetAtt: [ ProfilePictureResolverLambdaFunction, Arn ]} | |
iamRoleStatements: | |
- Effect: Allow |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSAppSyncS3LambdaIAMRole: | |
Type: AWS::IAM::Role | |
Properties: | |
RoleName: ${self:custom.api}-AWSAppSyncS3LambdaIAMRole | |
AssumeRolePolicyDocument: | |
Version: "2012-10-17" | |
Statement: | |
- Effect: Allow | |
Principal: | |
Service: "lambda.amazonaws.com" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
profilePictureResolver: | |
handler: graphql.profilePictureResolver | |
name: ${self:custom.api}-profilePictureResolver | |
description: AppSync Resolver for User.profilePicture | |
runtime: nodejs8.10 | |
role: AWSAppSyncS3LambdaIAMRole | |
environment: | |
S3_BUCKET: { Fn::GetAtt: [ FileStorage, Arn ]} | |
S3_URL: { Fn::GetAtt: [ FileStorage, WebsiteURL ]} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UnauthRole: | |
Type: AWS::IAM::Role | |
Properties: | |
RoleName: ${self:custom.api}-unauth | |
AssumeRolePolicyDocument: | |
Version: "2012-10-17" | |
Statement: | |
- Effect: Allow | |
Principal: | |
Federated: cognito-identity.amazonaws.com |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FileStorage: | |
Type: AWS::S3::Bucket | |
Properties: | |
CorsConfiguration: | |
CorsRules: | |
- AllowedOrigins: | |
- '*' | |
AllowedHeaders: | |
- '*' | |
AllowedMethods: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#set($items = []) | |
#foreach($entry in $context.result.hits.hits) | |
$util.qr($items.add($entry.get("_source"))) | |
#end | |
{ | |
"items": $util.toJson($items) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#set($query = { | |
"bool": { | |
"must": [ | |
{ "match": { "typeName": "LOCATION" } } | |
] | |
} | |
}) | |
#if (! $util.isNull($context.args.byGPS )) | |
$util.qr($query.bool.put("filter", { |