Skip to content

Instantly share code, notes, and snippets.

View antonioftamura's full-sized avatar

Antonio Jose Figueiredo Tamura Junior antonioftamura

  • Adelaide
View GitHub Profile
@antonioftamura
antonioftamura / CustomResources.json
Last active June 29, 2020 07:41
CustomResources.json
{
"Resources":{
"LambdaResolverDataSource":{
"Type":"AWS::AppSync::DataSource",
"Properties":{
"ApiId":{
"Ref":"AppSyncApiId"
},
"Name":"LambdaResolverFunction",
"Type":"AWS_LAMBDA",
@antonioftamura
antonioftamura / index.js
Last active June 29, 2020 05:36
index.js mocking
exports.handler = async (event, context, callback) => {
switch(event.field) {
case "getTodo":
const todo = {"id": "1", "name": "My TODO", "description": "My first TODO"};
callback(null, todo);
break;
// Add any methods that you want here.
default:
callback("Unknown field, unable to resolve" + event.field, null);
break;
@antonioftamura
antonioftamura / Query.getTodo.res.vtl
Created June 29, 2020 05:24
Query.getTodo.res.vtl
$utils.toJson($context.result)
@antonioftamura
antonioftamura / Query.getTodo.req.vtl
Created June 29, 2020 05:23
Query.getTodo.req.vtl
{
"version": "2017-02-28",
"operation": "Invoke",
"payload": {
"field": "getTodo",
"arguments": $utils.toJson($context.arguments)
}
}
@antonioftamura
antonioftamura / index.js
Last active September 30, 2022 17:35
index.js
exports.handler = async (event, context, callback) => {
// Simple Postgres lib that supports async calls
const { Pool } = require('pg');
const pool = new Pool();
switch(event.field) {
case "getTodo":
var id = event.arguments.id;
const querySelect = 'SELECT * FROM todo WHERE id = $1';
@antonioftamura
antonioftamura / schema.graphql
Last active June 29, 2020 04:29
schema.graphql
schema {
query: Query
mutation: Mutation
}
type Query {
getTodo(id:ID!): Todo
allTodos: [Todo]
}