{"id":23780817,"url":"https://github.com/iwatakeshi/aws-lambda-appsync","last_synced_at":"2025-09-06T00:32:27.749Z","repository":{"id":40794071,"uuid":"241752407","full_name":"iwatakeshi/aws-lambda-appsync","owner":"iwatakeshi","description":"Utilities to simplify GraphQL operations in a lambda function for Appsync","archived":false,"fork":false,"pushed_at":"2023-01-06T02:33:58.000Z","size":564,"stargazers_count":7,"open_issues_count":7,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-22T00:36:08.656Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/iwatakeshi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-02-19T23:50:43.000Z","updated_at":"2023-05-01T13:56:16.000Z","dependencies_parsed_at":"2023-02-05T03:16:27.778Z","dependency_job_id":null,"html_url":"https://github.com/iwatakeshi/aws-lambda-appsync","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iwatakeshi%2Faws-lambda-appsync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iwatakeshi%2Faws-lambda-appsync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iwatakeshi%2Faws-lambda-appsync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iwatakeshi%2Faws-lambda-appsync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iwatakeshi","download_url":"https://codeload.github.com/iwatakeshi/aws-lambda-appsync/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232071643,"owners_count":18468551,"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":[],"created_at":"2025-01-01T11:17:06.548Z","updated_at":"2025-01-01T11:17:07.245Z","avatar_url":"https://github.com/iwatakeshi.png","language":"TypeScript","readme":"# aws-lambda-appsync\nUtilities to simplify GraphQL operations in a Lambda function for Appsync\n\nCurrently, there are two ways provided that will allow you to use AppSync in a Lambda function.\n\nThe implementations are based on two blog posts:\n\n* [Using Cognito User Pool](https://blog.floom.app/post/aws-appsync-with-lambda)\n* [Using IAM](https://docs.aws.amazon.com/appsync/latest/devguide/building-a-client-app-node.html)\n\n\n**Note**:\n\nThere will be tests that need to be done. However, this library simply wraps existing libraries to reduce the boilerplate required to perform GraphQL operations. Thus, please use this library with caution if you plan to use in production (until I can get the tests done).\n\n## Usage\n\n```bash\n# Yarn\nyarn add @iwatakeshi/aws-lambda-appsync\n\n# NPM\nnpm install --save @iwatakeshi/aws-lambda-appsync\n```\n\n\n```ts\nimport { createIAMAppSyncClient, createCognitoUserPoolAppSyncClient } from '@iwatakeshi/aws-lambda-appsync'\n\n// Create a client using IAM\nconst client = createIAMAppSyncClient({\n  url: '...',\n  region: process.env.REGION,\n  credentials: {\n    accessKeyId: process.env.ACCESS_KEY_ID,\n    secretAccessKey: process.env.SECRET_ACCESS_KEY\n  }\n})\n\n// Create a client using Cognito User Pool\nconst client = createCognitoUserPoolAppSyncClient({\n  url: '...',\n  region: process.env.REGION,\n  clientId: process.env.CLIENT_ID,\n  userPoolId: process.env.USER_POOL_ID,\n  authParameters: {\n    username: process.env.ADMIN_USERNAME,\n    password: process.env.ADMIN_PASSWORD\n  },\n  auth: {\n    // Optional, but can be overridden,\n    jwtToken: (provider, options) =\u003e {\n      let credentials, expired = new Date('01-01-1970')\n      return async () =\u003e {\n        // Check if we already have credentials or if credentials are expired\n        if (!credentials || expired \u003c new Date()) {\n          // Get new credentials (import 'getCredentials' from @iwatakeshi/aws-lambda-appsync/lib/utils/cognito)\n          credentials = await getCredentials(provider, options)\n         // ...\n        }\n\n        return credentials?.AuthenticationResult?.IdToken\n      }\n    }\n  }\n})\n\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiwatakeshi%2Faws-lambda-appsync","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiwatakeshi%2Faws-lambda-appsync","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiwatakeshi%2Faws-lambda-appsync/lists"}