All Projects → sbstjn → appsync-resolvers

sbstjn / appsync-resolvers

Licence: MIT License
AWS AppSync Resolvers for GraphQL using AWS Lambda functions in Go.

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to appsync-resolvers

go-appsync-graphql-cloudformation
AWS AppSync GraphQL API Proxy with Lambda, CloudFormation, and SAM
Stars: ✭ 28 (-24.32%)
Mutual labels:  lambda, appsync
aws-serverless-fullstack-swift-apple-carplay-example
This application demonstrates a full-stack Apple CarPlay app that uses Swift for both the UI and the backend services in AWS. The app accesses Lambda functions written in Swift and deployed from Docker images. The app accesses Amazon Location Service and a 3rd party weather api to display information in the vicinity of the user.
Stars: ✭ 84 (+127.03%)
Mutual labels:  lambda, appsync
twitter
A serverless social network that's under development with some cool stuff, such as Serverless Framework, AppSync, GraphQL, Lambda, DynamoDB, Cognito, Kinesis Firehose, and Algolia ☁️
Stars: ✭ 29 (-21.62%)
Mutual labels:  lambda, appsync
Jamstack Cms
Modern full stack CMS. Built with Gatsby, GraphQL, AWS Amplify, and Serverless technologies.
Stars: ✭ 702 (+1797.3%)
Mutual labels:  lambda, appsync
Aws Serverless Appsync Loyalty
Unicorn Loyalty: E-Commerce Serverless GraphQL Loyalty Sample App
Stars: ✭ 110 (+197.3%)
Mutual labels:  lambda, appsync
Appsync Resolvers Example
Example project for AppSync, GraphQL, and AWS Lambda resolvers using Go.
Stars: ✭ 50 (+35.14%)
Mutual labels:  lambda, appsync
Aws Serverless Ecommerce Platform
Serverless Ecommerce Platform is a sample implementation of a serverless backend for an e-commerce website. This sample is not meant to be used as an e-commerce platform as-is, but as an inspiration on how to build event-driven serverless microservices on AWS.
Stars: ✭ 469 (+1167.57%)
Mutual labels:  lambda, appsync
Aws Serverless Appsync App
This workshop shows you how to build a Web Application that demonstrates how easy it is to create data driven web applications all with no servers. You will build a serverless web application that lets users search for popular tourist destinations. The application will use AWS AppSync and the AWS Serverless platform to provide real-time weather analysis of the indexed destinations.
Stars: ✭ 162 (+337.84%)
Mutual labels:  lambda, appsync
shim
HTTP Handler shim for Go projects running on AWS Lambda
Stars: ✭ 64 (+72.97%)
Mutual labels:  lambda, router
spirit-router
fast router for spirit
Stars: ✭ 28 (-24.32%)
Mutual labels:  router
koa-rest-router
Most powerful, flexible and composable router for building enterprise RESTful APIs easily!
Stars: ✭ 67 (+81.08%)
Mutual labels:  router
svelte-router
Router component for Svelte
Stars: ✭ 63 (+70.27%)
Mutual labels:  router
node-lambda-babel-template
A minimal template for an ES2015+ Node.js app running on AWS Lambda (w/ babel and webpack).
Stars: ✭ 40 (+8.11%)
Mutual labels:  lambda
super-serverless-sample
Backend serverless que simula o sistema de votação do BBB
Stars: ✭ 30 (-18.92%)
Mutual labels:  lambda
serverless-ts-template
Serverless Typescript Template
Stars: ✭ 13 (-64.86%)
Mutual labels:  lambda
serverless-ninja
Code repository of AWS Serverless Ninja Guidebook 👹 👹 👹
Stars: ✭ 40 (+8.11%)
Mutual labels:  lambda
tarojs-router-next
Taro 小程序路由库/自动生成带参数类型提示的路由方法/允许传递任意类型、任意大小的参数数据/同步的路由方法调用/koa体验一致的路由中间件
Stars: ✭ 166 (+348.65%)
Mutual labels:  router
pinboard-backup
This backs up Pinboard bookmarks to DynamoDB.
Stars: ✭ 17 (-54.05%)
Mutual labels:  lambda
linqjs
use linq and lambda in javascript on es6, can use linq function in an Object or an Array or a String value | 一个方便对数组、字典、树形数据进行操作、筛选等操作的工具库
Stars: ✭ 17 (-54.05%)
Mutual labels:  lambda
Router
The Hoa\Router library.
Stars: ✭ 29 (-21.62%)
Mutual labels:  router

AppSync GraphQL Resolvers w/ Go in AWS Lambda

Current Release MIT License Read Tutorial Code Example

Easily create AWS AppSync resolvers with AWS Lambda using Go. See appsync-resolvers-example for an example project with custon Field and Query resolvers and how to set up, maintain, and deploy a working GraphQL API using the Serverless Application Model and without any third-party frameworks.

See Serverless GraphQL with AWS AppSync and Lambda on sbstjn.com for a detailed guide how to set up and configure this project. Or just run make configure build package deploy and you are ready to go …

Usage

Installation

$ > go get github.com/sbstjn/appsync-resolvers

Resolvers

import (
    "github.com/sbstjn/appsync-resolvers"
)

type personArguments struct {
    ID int `json:"id"`
}

func resolvePeople() (people, error) {
    return dataPeople, nil
}

func resolvePerson(p personArguments) (*person, error) {
    return dataPeople.byID(p.ID)
}

func resolveFriends(p person) (people, error) {
    return p.getFriends()
}

var (
    r = resolvers.New()
)

func init() {
    r.Add("query.people", resolvePeople)
    r.Add("query.person", resolvePerson)
    r.Add("field.person.friends", resolveFriends)
}

func main() {
    lambda.Start(r.Handle)
}

AppSync Configuration

Resolver lookup is based on a resolve property in your RequestMappingTemplate, which can be configured using the AWS Console or CloudFormation as well. This approach works fine with the recommended AWS setup for multiple custom resolvers and AWS Lambda data sources:

AppSyncDataSource:
  Type: AWS::AppSync::DataSource
  Properties:
    ApiId: !GetAtt [ AppSyncAPI, ApiId ]
    Name: resolver
    Type: AWS_LAMBDA
    LambdaConfig:
      LambdaFunctionArn: !GetAtt [ Lambda, Arn ]
    ServiceRoleArn: !GetAtt [ Role, Arn ]

AppSyncResolverPeople:
  Type: AWS::AppSync::Resolver
  Properties:
    ApiId: !GetAtt [ AppSyncAPI, ApiId ]
    TypeName: Query
    FieldName: people
    DataSourceName: !GetAtt [ AppSyncDataSource, Name ]
    RequestMappingTemplate: '{ "version" : "2017-02-28", "operation": "Invoke", "payload": { "resolve": "query.people", "context": $utils.toJson($context) } }'
    ResponseMappingTemplate: $util.toJson($context.result)

AppSyncResolverPerson:
  Type: AWS::AppSync::Resolver
  Properties:
    ApiId: !GetAtt [ AppSyncAPI, ApiId ]
    TypeName: Query
    FieldName: person
    DataSourceName: !GetAtt [ AppSyncDataSource, Name ]
    RequestMappingTemplate: '{ "version" : "2017-02-28", "operation": "Invoke", "payload": { "resolve": "query.person", "context": $utils.toJson($context) } }'
    ResponseMappingTemplate: $util.toJson($context.result)

AppSyncResolverFriends:
  Type: AWS::AppSync::Resolver
  Properties:
    ApiId: !GetAtt [ AppSyncAPI, ApiId ]
    TypeName: Person
    FieldName: friends
    DataSourceName: !GetAtt [ AppSyncDataSource, Name ]
    RequestMappingTemplate: '{ "version" : "2017-02-28", "operation": "Invoke", "payload": { "resolve": "field.person.friends", "context": $utils.toJson($context) } }'
    ResponseMappingTemplate: $util.toJson($context.result)

Head over to appsync-resolvers-example for an example project and how simple it can be to set up, maintain, and deploy a serverless GraphQL API with AWS AppSync using the Serverless Application Model.

License

Feel free to use the code, it's released using the MIT license.

Contribution

You are welcome to contribute to this project! 😘

To make sure you have a pleasant experience, please read the code of conduct. It outlines core values and beliefs and will make working together a happier experience.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].