{"id":13532628,"url":"https://github.com/dabit3/appsync-lambda-ai","last_synced_at":"2025-11-17T15:27:47.641Z","repository":{"id":73190373,"uuid":"133958598","full_name":"dabit3/appsync-lambda-ai","owner":"dabit3","description":"Demo of using a GraphQL resolver to hit a lambda function, then hit a few AI services, and return the response.","archived":false,"fork":false,"pushed_at":"2020-02-23T14:25:26.000Z","size":808,"stargazers_count":47,"open_issues_count":0,"forks_count":10,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-05-05T22:54:11.432Z","etag":null,"topics":["ai","graphql","react","react-native","reactjs","sythesization","translation"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dabit3.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-18T13:33:40.000Z","updated_at":"2025-03-30T19:07:56.000Z","dependencies_parsed_at":"2023-05-23T01:00:26.089Z","dependency_job_id":null,"html_url":"https://github.com/dabit3/appsync-lambda-ai","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dabit3%2Fappsync-lambda-ai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dabit3%2Fappsync-lambda-ai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dabit3%2Fappsync-lambda-ai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dabit3%2Fappsync-lambda-ai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dabit3","download_url":"https://codeload.github.com/dabit3/appsync-lambda-ai/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253714039,"owners_count":21952089,"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":["ai","graphql","react","react-native","reactjs","sythesization","translation"],"created_at":"2024-08-01T07:01:12.444Z","updated_at":"2025-11-17T15:27:42.619Z","avatar_url":"https://github.com/dabit3.png","language":"JavaScript","funding_links":[],"categories":["Example Projects"],"sub_categories":["Other blogs \u0026 tutorials"],"readme":"# AI Enabled GraphQL with AWS AppSync\n\nThis app demonstrates how you can use a Lambda function as an AWS AppSync datasource to perform really cool operations and return the result in a GraphQL query. In this example, we build an app that allows someone to put the text they would like to translate into the app, the app then returns the translation into voice for the user to play back.\n\n![](https://s3.amazonaws.com/aws-mobile-hub-images/lambda_appsync.jpeg)\n\n## Getting Started\n\n### React Native setup\n\n1. clone the project   \n\n```bash\ngit clone https://github.com/dabit3/appsync-lambda-ai.git\n```\n\n2. change directories into the project \u0026 install depencies   \n\n```bash\ncd appsync-lambda-ai\nyarn || npm install\n```\n\n### Creating an S3 bucket\n\n1. Visit [https://s3.console.aws.amazon.com/](https://s3.console.aws.amazon.com/) and click __Create bucket__\n\n2. Give the bucket a name and choose defaults for all other options\n\n3. Update line 46 in App.js to use the bucket name you just created (replace `YOURBUCKETNAME` and `REGION`):\n\n```js\nconst mp3Url = `https://s3-REGION.amazonaws.com/YOURBUCKETNAME/${sentence}`\n```\n\n### Setting up the Lambda function\n\n1. In the AWS dashboard, go to the [Lambda console](https://console.aws.amazon.com/lambda/)\n\n2. Create a new function by clicking on __Create Function__\n\n3. Give the function a name, choose the runtime as Node.js 12.x, choose __Create a custom role__ for the role, give the role a name of __lambda_ai_role__ \u0026 click __Allow__.\n\n4. Click __Create Function__   \n\n5. Next, we need to add permissions to the Lambda function in order to access other services (such as S3, Polly, \u0026 Translate). To do so, go to the IAM console, go to __Roles__, find \u0026 choose the __lambda_ai_role__, and add the following policies:\n\n- AmazonS3FullAccess\n- AmazonPollyFullAccess\n- TranslateReadOnly\n\n6. Next, we need to update and add the actual lambda function we will be running! In the _lambda_ folder of this project, there is a lambda function (index.js) \u0026 a package.json file. In `lambda/index.js` on line 8, replace `YOURBUCKETNAME` with the bucket name you used when you created the S3 bucket  and the `REGION` where this project lives.\n\n7. Finally, from within the lambda directory install the dependencies and then zip the folder into a zip file using the following command:\n\n```bash\nzip -r ../translate.zip *\n```\n\nUpload the zip file to Lambda as the function code and click __Save__\n\n### AWS AppSync Setup\n\n1. Create a new AWS ApppSync API, choose custom schema   \n\n2. Define the following schema   \n\n```\ntype Query {\n  getTranslatedSentence(sentence: String!, code: String!): TranslatedSentence\n}\n\ntype TranslatedSentence {\n  sentence: String!\n}\n```\n\n3. Create a lambda function data source   \n- Click __Data Sources__\n- Click __NEW__\n- Give the data source a name, choose __AWS Lambda Function__ as the Data source type\n- For the region, choose the region where you created the Lamba function\n- For the Function ARN, choose the Lambda function you would like to use\n- For the Role, choose __New Role__\n\n4. Add a resolver to the __getTranslatedSentence__ query.   \n- Click on Schema in the left menu\n- On the Right (under Data Types), click on __Attach__ next to the `getTranslatedSentence` field.\n- For the Data Source name, choose the new data source we just created\n- Click __Save__\n\n5. Add AppSync configuration to the project   \n\nNext, we need to edit the aws-exports.js file to specify our AppSync configuration. In the root directory of the React Native project, update aws-exports.js with your AppSync credentials:\n\n```js\nconst awsmobile = {\n  'aws_appsync_graphqlEndpoint': 'https://xxxxxx.appsync-api.us-east-1.amazonaws.com/graphql',\n  'aws_appsync_region': 'us-east-1',\n  'aws_appsync_authenticationType': 'API_KEY',\n  'aws_appsync_apiKey': 'da2-xxxxxxxxxxxxxxxxxxxxxxxxxx',\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdabit3%2Fappsync-lambda-ai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdabit3%2Fappsync-lambda-ai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdabit3%2Fappsync-lambda-ai/lists"}