{"id":13532864,"url":"https://github.com/sbstjn/appsync-resolvers","last_synced_at":"2025-04-21T22:33:27.056Z","repository":{"id":33827713,"uuid":"135733558","full_name":"sbstjn/appsync-resolvers","owner":"sbstjn","description":"AWS AppSync Resolvers for GraphQL using AWS Lambda functions in Go.","archived":false,"fork":false,"pushed_at":"2022-04-01T16:25:15.000Z","size":99,"stargazers_count":42,"open_issues_count":5,"forks_count":14,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-01T16:24:19.559Z","etag":null,"topics":["appsync","appsync-router","aws","go","golang","graphql","lambda","router"],"latest_commit_sha":null,"homepage":"https://sbstjn.com/serverless-graphql-with-appsync-and-lambda.html","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sbstjn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-01T15:20:43.000Z","updated_at":"2023-07-20T16:08:37.000Z","dependencies_parsed_at":"2022-08-07T23:16:32.265Z","dependency_job_id":null,"html_url":"https://github.com/sbstjn/appsync-resolvers","commit_stats":null,"previous_names":["sbstjn/appsync-router"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbstjn%2Fappsync-resolvers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbstjn%2Fappsync-resolvers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbstjn%2Fappsync-resolvers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbstjn%2Fappsync-resolvers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sbstjn","download_url":"https://codeload.github.com/sbstjn/appsync-resolvers/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250145310,"owners_count":21382391,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["appsync","appsync-router","aws","go","golang","graphql","lambda","router"],"created_at":"2024-08-01T07:01:14.398Z","updated_at":"2025-04-21T22:33:22.045Z","avatar_url":"https://github.com/sbstjn.png","language":"Go","funding_links":[],"categories":["Tooling"],"sub_categories":[],"readme":"# AppSync GraphQL Resolvers w/ Go in AWS Lambda\n\n[![Current Release](https://badgen.now.sh/github/release/sbstjn/appsync-resolvers)](https://github.com/sbstjn/appsync-resolvers/releases)\n[![MIT License](https://badgen.now.sh/badge/License/MIT/blue)](https://github.com/sbstjn/appsync-resolvers/blob/master/LICENSE.md)\n[![Read Tutorial](https://badgen.now.sh/badge/Read/Tutorial/orange)](https://sbstjn.com/serverless-graphql-with-appsync-and-lambda.html)\n[![Code Example](https://badgen.now.sh/badge/Code/Example/cyan)](https://github.com/sbstjn/appsync-resolvers-example)\n\nEasily 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.\n\nSee [Serverless GraphQL with AWS AppSync and Lambda](https://sbstjn.com/serverless-graphql-with-appsync-and-lambda.html) on [sbstjn.com](https://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 …\n\n\n## Usage\n\n### Installation\n\n```\n$ \u003e go get github.com/sbstjn/appsync-resolvers\n```\n\n### Resolvers\n\n```go\nimport (\n    \"github.com/sbstjn/appsync-resolvers\"\n)\n\ntype personArguments struct {\n    ID int `json:\"id\"`\n}\n\nfunc resolvePeople() (people, error) {\n    return dataPeople, nil\n}\n\nfunc resolvePerson(p personArguments) (*person, error) {\n    return dataPeople.byID(p.ID)\n}\n\nfunc resolveFriends(p person) (people, error) {\n    return p.getFriends()\n}\n\nvar (\n    r = resolvers.New()\n)\n\nfunc init() {\n    r.Add(\"query.people\", resolvePeople)\n    r.Add(\"query.person\", resolvePerson)\n    r.Add(\"field.person.friends\", resolveFriends)\n}\n\nfunc main() {\n    lambda.Start(r.Handle)\n}\n```\n\n### AppSync Configuration\n\nResolver 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:\n\n```yaml\nAppSyncDataSource:\n  Type: AWS::AppSync::DataSource\n  Properties:\n    ApiId: !GetAtt [ AppSyncAPI, ApiId ]\n    Name: resolver\n    Type: AWS_LAMBDA\n    LambdaConfig:\n      LambdaFunctionArn: !GetAtt [ Lambda, Arn ]\n    ServiceRoleArn: !GetAtt [ Role, Arn ]\n\nAppSyncResolverPeople:\n  Type: AWS::AppSync::Resolver\n  Properties:\n    ApiId: !GetAtt [ AppSyncAPI, ApiId ]\n    TypeName: Query\n    FieldName: people\n    DataSourceName: !GetAtt [ AppSyncDataSource, Name ]\n    RequestMappingTemplate: '{ \"version\" : \"2017-02-28\", \"operation\": \"Invoke\", \"payload\": { \"resolve\": \"query.people\", \"context\": $utils.toJson($context) } }'\n    ResponseMappingTemplate: $util.toJson($context.result)\n\nAppSyncResolverPerson:\n  Type: AWS::AppSync::Resolver\n  Properties:\n    ApiId: !GetAtt [ AppSyncAPI, ApiId ]\n    TypeName: Query\n    FieldName: person\n    DataSourceName: !GetAtt [ AppSyncDataSource, Name ]\n    RequestMappingTemplate: '{ \"version\" : \"2017-02-28\", \"operation\": \"Invoke\", \"payload\": { \"resolve\": \"query.person\", \"context\": $utils.toJson($context) } }'\n    ResponseMappingTemplate: $util.toJson($context.result)\n\nAppSyncResolverFriends:\n  Type: AWS::AppSync::Resolver\n  Properties:\n    ApiId: !GetAtt [ AppSyncAPI, ApiId ]\n    TypeName: Person\n    FieldName: friends\n    DataSourceName: !GetAtt [ AppSyncDataSource, Name ]\n    RequestMappingTemplate: '{ \"version\" : \"2017-02-28\", \"operation\": \"Invoke\", \"payload\": { \"resolve\": \"field.person.friends\", \"context\": $utils.toJson($context) } }'\n    ResponseMappingTemplate: $util.toJson($context.result)\n```\n\nHead 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].\n\n## License\n\nFeel free to use the code, it's released using the [MIT license](LICENSE.md).\n\n## Contribution\n\nYou are welcome to contribute to this project! 😘 \n\nTo make sure you have a pleasant experience, please read the [code of conduct](CODE_OF_CONDUCT.md). It outlines core values and beliefs and will make working together a happier experience.\n\n[appsync-resolvers-example]: https://github.com/sbstjn/appsync-resolvers-example\n[Serverless Application Model]: https://github.com/awslabs/serverless-application-model\n[AWS setup]: https://docs.aws.amazon.com/appsync/latest/devguide/tutorial-lambda-resolvers.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsbstjn%2Fappsync-resolvers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsbstjn%2Fappsync-resolvers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsbstjn%2Fappsync-resolvers/lists"}