{"id":13626460,"url":"https://github.com/kcwinner/cdk-appsync-transformer","last_synced_at":"2026-01-17T07:25:35.504Z","repository":{"id":37093601,"uuid":"306676190","full_name":"kcwinner/cdk-appsync-transformer","owner":"kcwinner","description":"AWS Amplify inspired CDK construct for creating directive based AppSync APIs","archived":false,"fork":false,"pushed_at":"2025-09-22T11:16:58.000Z","size":1183,"stargazers_count":131,"open_issues_count":2,"forks_count":23,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-09-30T07:07:35.518Z","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/kcwinner.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","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":"2020-10-23T15:29:10.000Z","updated_at":"2024-12-10T16:39:48.000Z","dependencies_parsed_at":"2024-04-18T12:51:29.885Z","dependency_job_id":"e948e1b3-ec25-46ca-92c8-0e569dc7a68d","html_url":"https://github.com/kcwinner/cdk-appsync-transformer","commit_stats":{"total_commits":96,"total_committers":7,"mean_commits":"13.714285714285714","dds":0.6458333333333333,"last_synced_commit":"59acdec8cc16ae1b81f2b5b6de849da33057b6a8"},"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"purl":"pkg:github/kcwinner/cdk-appsync-transformer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kcwinner%2Fcdk-appsync-transformer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kcwinner%2Fcdk-appsync-transformer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kcwinner%2Fcdk-appsync-transformer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kcwinner%2Fcdk-appsync-transformer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kcwinner","download_url":"https://codeload.github.com/kcwinner/cdk-appsync-transformer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kcwinner%2Fcdk-appsync-transformer/sbom","scorecard":{"id":553006,"data":{"date":"2025-08-11","repo":{"name":"github.com/kcwinner/cdk-appsync-transformer","commit":"59acdec8cc16ae1b81f2b5b6de849da33057b6a8"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.2,"checks":[{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Code-Review","score":0,"reason":"Found 2/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Dangerous-Workflow","score":0,"reason":"dangerous workflow patterns detected","details":["Warn: script injection with untrusted input ' github.event.pull_request.head.ref ': .github/workflows/build.yml:85"],"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":7,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: jobLevel 'contents' permission set to 'write': .github/workflows/build.yml:62","Info: found token with 'none' permissions: .github/workflows/build.yml:1","Info: found token with 'none' permissions: .github/workflows/build.yml:1","Warn: jobLevel 'contents' permission set to 'write': .github/workflows/build.yml:11","Warn: jobLevel 'contents' permission set to 'write': .github/workflows/release-cdk-v2.yml:13","Warn: jobLevel 'contents' permission set to 'write': .github/workflows/release-cdk-v2.yml:48","Info: jobLevel 'contents' permission set to 'read': .github/workflows/release-cdk-v2.yml:78","Info: jobLevel 'contents' permission set to 'read': .github/workflows/release-cdk-v2.yml:108","Info: jobLevel 'contents' permission set to 'read': .github/workflows/release.yml:78","Info: jobLevel 'contents' permission set to 'read': .github/workflows/release.yml:108","Warn: jobLevel 'contents' permission set to 'write': .github/workflows/release.yml:13","Warn: jobLevel 'contents' permission set to 'write': .github/workflows/release.yml:48","Warn: no topLevel permission defined: .github/workflows/build.yml:1","Warn: no topLevel permission defined: .github/workflows/pull-request-lint.yml:1","Warn: no topLevel permission defined: .github/workflows/release-cdk-v2.yml:1","Warn: no topLevel permission defined: .github/workflows/release.yml:1","Warn: no topLevel permission defined: .github/workflows/stale.yml:1"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Pinned-Dependencies","score":4,"reason":"dependency not pinned by hash detected -- score normalized to 4","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/kcwinner/cdk-appsync-transformer/build.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/build.yml:27: update your workflow using https://app.stepsecurity.io/secureworkflow/kcwinner/cdk-appsync-transformer/build.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:38: update your workflow using https://app.stepsecurity.io/secureworkflow/kcwinner/cdk-appsync-transformer/build.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:52: update your workflow using https://app.stepsecurity.io/secureworkflow/kcwinner/cdk-appsync-transformer/build.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:67: update your workflow using https://app.stepsecurity.io/secureworkflow/kcwinner/cdk-appsync-transformer/build.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:73: update your workflow using https://app.stepsecurity.io/secureworkflow/kcwinner/cdk-appsync-transformer/build.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:95: update your workflow using https://app.stepsecurity.io/secureworkflow/kcwinner/cdk-appsync-transformer/build.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:99: update your workflow using https://app.stepsecurity.io/secureworkflow/kcwinner/cdk-appsync-transformer/build.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:117: update your workflow using https://app.stepsecurity.io/secureworkflow/kcwinner/cdk-appsync-transformer/build.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:120: update your workflow using https://app.stepsecurity.io/secureworkflow/kcwinner/cdk-appsync-transformer/build.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:124: update your workflow using https://app.stepsecurity.io/secureworkflow/kcwinner/cdk-appsync-transformer/build.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/pull-request-lint.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/kcwinner/cdk-appsync-transformer/pull-request-lint.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release-cdk-v2.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/kcwinner/cdk-appsync-transformer/release-cdk-v2.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release-cdk-v2.yml:37: update your workflow using https://app.stepsecurity.io/secureworkflow/kcwinner/cdk-appsync-transformer/release-cdk-v2.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release-cdk-v2.yml:51: update your workflow using https://app.stepsecurity.io/secureworkflow/kcwinner/cdk-appsync-transformer/release-cdk-v2.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release-cdk-v2.yml:55: update your workflow using https://app.stepsecurity.io/secureworkflow/kcwinner/cdk-appsync-transformer/release-cdk-v2.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release-cdk-v2.yml:81: update your workflow using https://app.stepsecurity.io/secureworkflow/kcwinner/cdk-appsync-transformer/release-cdk-v2.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release-cdk-v2.yml:85: update your workflow using https://app.stepsecurity.io/secureworkflow/kcwinner/cdk-appsync-transformer/release-cdk-v2.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release-cdk-v2.yml:111: update your workflow using https://app.stepsecurity.io/secureworkflow/kcwinner/cdk-appsync-transformer/release-cdk-v2.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release-cdk-v2.yml:114: update your workflow using https://app.stepsecurity.io/secureworkflow/kcwinner/cdk-appsync-transformer/release-cdk-v2.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release-cdk-v2.yml:118: update your workflow using https://app.stepsecurity.io/secureworkflow/kcwinner/cdk-appsync-transformer/release-cdk-v2.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:111: update your workflow using https://app.stepsecurity.io/secureworkflow/kcwinner/cdk-appsync-transformer/release.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:114: update your workflow using https://app.stepsecurity.io/secureworkflow/kcwinner/cdk-appsync-transformer/release.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:118: update your workflow using https://app.stepsecurity.io/secureworkflow/kcwinner/cdk-appsync-transformer/release.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/kcwinner/cdk-appsync-transformer/release.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:37: update your workflow using https://app.stepsecurity.io/secureworkflow/kcwinner/cdk-appsync-transformer/release.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:51: update your workflow using https://app.stepsecurity.io/secureworkflow/kcwinner/cdk-appsync-transformer/release.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:55: update your workflow using https://app.stepsecurity.io/secureworkflow/kcwinner/cdk-appsync-transformer/release.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:81: update your workflow using https://app.stepsecurity.io/secureworkflow/kcwinner/cdk-appsync-transformer/release.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:85: update your workflow using https://app.stepsecurity.io/secureworkflow/kcwinner/cdk-appsync-transformer/release.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/stale.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/kcwinner/cdk-appsync-transformer/stale.yml/main?enable=pin","Warn: npmCommand not pinned by hash: .github/workflows/build.yml:24","Info:   0 out of  29 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   2 third-party GitHubAction dependencies pinned","Info:   8 out of   9 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 18 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"28 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-9j49-mfvp-vmhm","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-pfrx-2q88-qq97","Warn: Project is vulnerable to: GHSA-rc47-6667-2j5j","Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22","Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp","Warn: Project is vulnerable to: GHSA-896r-f27r-55mw","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-82v2-mx6x-wq7q","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-8hfj-j24r-96c4","Warn: Project is vulnerable to: GHSA-wc69-rhjr-hc9g","Warn: Project is vulnerable to: GHSA-r683-j2x4-v87g","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-4rq4-32rv-6wp6","Warn: Project is vulnerable to: GHSA-64g7-mvw6-v9qj","Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-20T11:27:14.060Z","repository_id":37093601,"created_at":"2025-08-20T11:27:14.060Z","updated_at":"2025-08-20T11:27:14.060Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28503856,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T06:57:29.758Z","status":"ssl_error","status_checked_at":"2026-01-17T06:56:03.931Z","response_time":85,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":"2024-08-01T21:02:19.501Z","updated_at":"2026-01-17T07:25:35.464Z","avatar_url":"https://github.com/kcwinner.png","language":"TypeScript","funding_links":[],"categories":["External Project Types","TypeScript"],"sub_categories":[],"readme":"# AppSync Transformer Construct for AWS CDK\n\n![build](https://github.com/kcwinner/cdk-appsync-transformer/workflows/Build/badge.svg)\n[![codecov](https://codecov.io/gh/kcwinner/cdk-appsync-transformer/branch/main/graph/badge.svg)](https://codecov.io/gh/kcwinner/cdk-appsync-transformer)\n[![dependencies Status](https://david-dm.org/kcwinner/cdk-appsync-transformer/status.svg)](https://david-dm.org/kcwinner/cdk-appsync-transformer)\n[![npm](https://img.shields.io/npm/dt/cdk-appsync-transformer)](https://www.npmjs.com/package/cdk-appsync-transformer)\n\n[![npm version](https://badge.fury.io/js/cdk-appsync-transformer.svg)](https://badge.fury.io/js/cdk-appsync-transformer)\n[![PyPI version](https://badge.fury.io/py/cdk-appsync-transformer.svg)](https://badge.fury.io/py/cdk-appsync-transformer)\n\n## Notice\n\nFor CDK versions \u003c 1.64.0 please use [aws-cdk-appsync-transformer](https://github.com/kcwinner/aws-cdk-appsync-transformer).\n\n## Why This Package\n\nIn April 2020 I wrote a [blog post](https://www.trek10.com/blog/appsync-with-the-aws-cloud-development-kit) on using the AWS Cloud Development Kit with AppSync. I wrote my own transformer in order to emulate AWS Amplify's method of using GraphQL directives in order to template a lot of the Schema Definition Language.\n\nThis package is my attempt to convert all of that effort into a separate construct in order to clean up the process.\n\n## How Do I Use It\n\n### Example Usage\n\nAPI With Default Values\n\n```ts\nimport { AppSyncTransformer } from 'cdk-appsync-transformer';\n...\nnew AppSyncTransformer(this, \"my-cool-api\", {\n    schemaPath: 'schema.graphql'\n});\n```\n\nschema.graphql\n\n```graphql\ntype Customer\n  @model\n  @auth(\n    rules: [\n      { allow: groups, groups: [\"Admins\"] }\n      { allow: private, provider: iam, operations: [read, update] }\n    ]\n  ) {\n  id: ID!\n  firstName: String!\n  lastName: String!\n  active: Boolean!\n  address: String!\n}\n\ntype Product\n  @model\n  @auth(\n    rules: [\n      { allow: groups, groups: [\"Admins\"] }\n      { allow: public, provider: iam, operations: [read] }\n    ]\n  ) {\n  id: ID!\n  name: String!\n  description: String!\n  price: String!\n  active: Boolean!\n  added: AWSDateTime!\n  orders: [Order] @connection\n}\n\ntype Order @model @key(fields: [\"id\", \"productID\"]) {\n  id: ID!\n  productID: ID!\n  total: String!\n  ordered: AWSDateTime!\n}\n```\n\n### [Supported Amplify Directives](https://docs.amplify.aws/cli/graphql-transformer/directives)\n\nTested:\n\n- [@model](https://docs.amplify.aws/cli/graphql-transformer/directives#model)\n- [@auth](https://docs.amplify.aws/cli/graphql-transformer/directives#auth)\n- [@connection](https://docs.amplify.aws/cli/graphql-transformer/directives#connection)\n- [@key](https://docs.amplify.aws/cli/graphql-transformer/directives#key)\n- [@function](https://docs.amplify.aws/cli/graphql-transformer/directives#function)\n  - These work differently here than they do in Amplify - see [Functions](#functions) below\n\nExperimental:\n\n- [@versioned](https://docs.amplify.aws/cli/graphql-transformer/directives#versioned)\n- [@http](https://docs.amplify.aws/cli/graphql-transformer/directives#http)\n- [@ttl](https://github.com/flogy/graphql-ttl-transformer)\n  - Community directive transformer\n\nNot Yet Supported:\n\n- [@searchable](https://docs.amplify.aws/cli/graphql-transformer/directives#searchable)\n- [@predictions](https://docs.amplify.aws/cli/graphql-transformer/directives#predictions)\n\n### Custom Transformers \u0026 Directives\n\n_This is an advanced feature_\n\nIt is possible to add pre/post custom transformers that extend the Amplify ITransformer. To see a simple example please look at [mapped-transformer.ts](./test/mappedTransformer/mapped-transformer.ts) in the tests section.\n\nThis allows you to modify the data either before or after the [cdk-transformer](./src/transformer/cdk-transformer.ts) is run.\n\n_Limitation:_ Due to some limitations with `jsii` we are unable to export the ITransformer interface from `graphql-transformer-core` to ensure complete type safety. Instead, there is a validation method that will check for `name`, `directive` and `typeDefinitions` members in the transformers that are passed in.\n\n```ts\nimport { PreTransformer, PostTransformer } from \"./customTransformers\";\nnew AppSyncTransformer(this, \"my-cool-api\", {\n  schemaPath: \"schema.graphql\",\n  preCdkTransformers: [new PreTransformer()],\n  postCdkTransformers: [new PostTransformer()],\n});\n```\n\n#### Custom VTL Transformer\n\nCan be used to create custom [NONE](https://docs.aws.amazon.com/appsync/latest/devguide/resolver-mapping-template-reference-none.html) datasource resolvers.This allows for custom or special logic to be used and added via a transformer.\n\nExample:\n\n```graphql\ntype Thing {\n  fooBar: String\n}\n\ntype Query {\n  listThingCustom: Thing\n    @custom(request: \"test/custom-resolvers/Test/request.vtl\", response: \"test/custom-resolvers/Test/response.vtl\")\n}\n```\n\nThe above will generate a `Query.listThingCustom` request and response resolver.\nYou can customize the location of custom resolvers using the `customVtlTransformerRootDirectory` property.\n\n### Overriding generated vtl\n\n_This is an advanced feature_\n\nYou can override generated request and response mapping templates using the `overrideResolver` convenience method.\n\n```ts\nconst appsyncTransformer = new AppSyncTransformer(this, \"my-cool-api\", {\n  schemaPath: \"schema.graphql\",\n});\n\n// You can override the just the request, just the response, or BOTH\nappsyncTransformer.overrideResolver({\n  typeName: 'Query',\n  fieldName: 'listThings',\n  requestMappingTemplateFile: path.join(process.cwd(), 'custom-resolvers', 'Things', 'request.vtl'),\n  responseMappingTemplateFile: path.join(process.cwd(), 'custom-resolvers', 'Things', 'response.vtl'),\n});\n```\n\n### Authentication\n\nUser Pool Authentication\n\n```ts\nconst userPool = new UserPool(this, 'my-cool-user-pool', {\n    ...\n})\n...\nconst userPoolClient = new UserPoolClient(this, `${id}-client`, {\n    userPool: this.userPool,\n    ...\n})\n...\nnew AppSyncTransformer(this, \"my-cool-api\", {\n    schemaPath: 'schema.graphql',\n    authorizationConfig: {\n        defaultAuthorization: {\n            authorizationType: AuthorizationType.USER_POOL,\n            userPoolConfig: {\n                userPool: userPool,\n                appIdClientRegex: userPoolClient.userPoolClientId,\n                defaultAction: UserPoolDefaultAction.ALLOW\n            }\n        }\n    }\n});\n```\n\n#### IAM\n\n##### Unauth Role\n\nYou can grant access to the `public` policies generated from the `@auth` transformer by using `appsyncTransformer.grantPublic(...)`. In the example below you can see we give public iam read access for the Product type. This will generate permissions for `listProducts`, `getProduct` and `Product` (to get all the fields). We then attach it to our `publicRole` using the grantPublic method.\n\nExample:\n```graphql\ntype Product\n    @model\n    @auth(rules: [\n        { allow: groups, groups: [\"Admins\"] },\n        { allow: public, provider: iam, operations: [read] }\n    ])\n    @key(name: \"productsByName\", fields: [\"name\", \"added\"], queryField: \"productsByName\") {\n        id: ID!\n        name: String!\n        description: String!\n        price: String!\n        active: Boolean!\n        added: AWSDateTime!\n        orders: [Order] @connection\n}\n```\n\n```ts\nconst identityPool = new CfnIdentityPool(stack, 'test-identity-pool', {\n    identityPoolName: 'test-identity-pool',\n    cognitoIdentityProviders: [\n      {\n        clientId: userPoolClient.userPoolClientId,\n        providerName: `cognito-idp.${stack.region}.amazonaws.com/${userPool.userPoolId}`,\n      },\n    ],\n    allowUnauthenticatedIdentities: true,\n  });\n\nconst publicRole = new Role(stack, 'public-role', {\n  assumedBy: new WebIdentityPrincipal('cognito-identity.amazonaws.com')\n    .withConditions({\n      'StringEquals': { 'cognito-identity.amazonaws.com:aud': `${identityPool.ref}` },\n      'ForAnyValue:StringLike': { 'cognito-identity.amazonaws.com:amr': 'unauthenticated' },\n    }),\n});\n\nappSyncTransformer.grantPublic(publicRole);\n```\n\n##### Auth Role\n\nYou can grant access to the `private` policies generated from the `@auth` transformer by using `appsyncTransformer.grantPrivate(...)`. In the example below you can see we give private iam read and update access for the Customer type. This will generate permissions for `listCustomers`, `getCustomer`, `updateCustomer` and `Customer` (to get all the fields). We then attach it to our `privateFunction` using the grantPrivate method. *You could also use an identity pool as in the unauth example above, I just wanted to show a varied range of use*\n\n```graphql\ntype Customer \n    @model\n    @auth(rules: [\n        { allow: groups, groups: [\"Admins\"] },\n        { allow: private, provider: iam, operations: [read, update] }\n    ]) {\n        id: ID!\n        firstName: String!\n        lastName: String!\n        active: Boolean!\n        address: String!\n}\n```\n\n```ts\nconst privateFunction = new Function(stack, 'test-function', {\n  runtime: Runtime.NODEJS_12_X,\n  code: Code.fromInline('export function handler() { }'),\n  handler: 'handler',\n});\n\nappSyncTransformer.grantPrivate(privateFunction);\n```\n\n### Functions\n\n#### Directive Example\n\n```graphql\ntype Query {\n  listUsers: UserConnection @function(name: \"myFunction\")\n  getUser(id: ID!): User @function(name: \"myFunction\")\n}\n```\n\nThere are two ways to add functions as data sources (and their resolvers)\n\n#### Construct Convenience Method\n\n```ts\nconst myFunction = new Function(...);\n\n// first argument is the name in the @function directive\nappsyncTransformer.addLambdaDataSourceAndResolvers('myFunction', 'unique-id', myFunction, {\n  name: 'lambdaDatasourceName'\n})\n```\n\n`addLambdaDataSourceAndResolvers` does the same thing as the manual version below. However, if you want to customize mapping templates you will have to bypass this and set up the data source and resolvers yourself\n\n#### Manually\n\nFields with the `@function` directive will be accessible via `appsyncTransformer.functionResolvers`. It will return a map like so:\n\n```ts\n{\n  'user-function': [\n    { typeName: 'Query', fieldName: 'listUsers' },\n    { typeName: 'Query', fieldName: 'getUser' },\n    { typeName: 'Mutation', fieldName: 'createUser' },\n    { typeName: 'Mutation', fieldName: 'updateUser' }\n  ]\n}\n```\n\nYou can grab your function resolvers via the map and assign them your own function(s). Example might be something like:\n\n```ts\nconst userFunction = new Function(...);\nconst userFunctionDataSource = appsyncTransformer.appsyncAPI.addLambdaDataSource('some-id', userFunction);\n\nconst dataSourceMap = {\n  'user-function': userFunctionDataSource\n};\n\nfor (const [functionName, resolver] of Object.entries(appsyncTransformer.functionResolvers)) {\n  const dataSource = dataSourceMap[functionName];\n  new Resolver(this.nestedAppsyncStack, `${resolver.typeName}-${resolver.fieldName}-resolver`, {\n    api: appsyncTransformer.appsyncAPI,\n    typeName: resolver.typeName,\n    fieldName: resolver.fieldName,\n    dataSource: dataSource,\n    requestMappingTemplate: resolver.defaultRequestMappingTemplate,\n    responseMappingTemplate: resolver.defaultResponseMappingTemplate // This defaults to allow errors to return to the client instead of throwing\n  });\n}\n```\n\n### Table Name Map\n\nOften you will need to access your table names in a lambda function or elsewhere. The cdk-appsync-transformer will return these values as a map of table names to cdk tokens. These tokens will be resolved at deploy time. They can be accessed via `appSyncTransformer.tableNameMap`.\n\n```ts\n{\n  CustomerTable: '${Token[TOKEN.1300]}',\n  ProductTable: '${Token[TOKEN.1346]}',\n  OrderTable: '${Token[TOKEN.1392]}',\n  BlogTable: '${Token[TOKEN.1442]}',\n  PostTable: '${Token[TOKEN.1492]}',\n  CommentTable: '${Token[TOKEN.1546]}',\n  UserTable: '${Token[TOKEN.1596]}'\n}\n```\n\n### Table Map\n\nYou may need to access your dynamo table L2 constructs. These can be accessed via `appSyncTransformer.tableMap`.\n\n### Custom Table Names\n\nIf you do not like autogenerated names for your Dynamo tables you can pass in props to specify them. Use the `tableKey` value derived from the `@model` directive. Example, if you have `type Foo @model` you would use `FooTable` as the key value. \n```ts\nconst appSyncTransformer = new AppSyncTransformer(stack, 'test-transformer', {\n  schemaPath: testSchemaPath,\n  tableNames: {\n    CustomerTable: customerTableName,\n    OrderTable: orderTableName\n  },\n});\n```\n\n### DynamoDB Streams\n\nThere are two ways to enable DynamoDB streams for a table. The first version is probably most preferred. You pass in the `@model` type name and the StreamViewType as properties when creating the AppSyncTransformer. This will also allow you to access the `tableStreamArn` property of the L2 table construct from the `tableMap`.\n\n```ts\nconst appSyncTransformer = new AppSyncTransformer(stack, 'test-transformer', {\n  schemaPath: testSchemaPath,\n  dynamoDbStreamConfig: {\n    Order: StreamViewType.NEW_IMAGE,\n    Blog: StreamViewType.NEW_AND_OLD_IMAGES\n  }\n});\n\nconst orderTable = appSyncTransformer.tableMap.OrderTable;\n// Do something with the table stream arn - orderTable.tableStreamArn\n```\n\nA convenience method is also available. It returns the stream arn because the L2 Table construct does not seem to update with the value since we are updating the underlying CfnTable. Normally a Table construct must pass in the stream specification as a prop\n\n```ts\nconst streamArn = appSyncTransformer.addDynamoDBStream({\n  modelTypeName: 'Order',\n  streamViewType: StreamViewType.NEW_IMAGE,\n});\n\n// Do something with the streamArn\n```\n\n### DataStore Support\n\n1. Pass `syncEnabled: true` to the `AppSyncTransformerProps`\n1. Generate necessary exports (see [Code Generation](#code-generation) below)\n\n### Cfn Outputs\n\n- `appsyncGraphQLEndpointOutput` - the appsync graphql endpoint\n\n### Code Generation\n\nI've written some helpers to generate code similarly to how AWS Amplify generates statements and types. You can find the code [here](https://github.com/kcwinner/advocacy/tree/master/cdk-amplify-appsync-helpers).\n\n## Versioning\n\nI will _attempt_ to align the major and minor version of this package with [AWS CDK], but always check the release descriptions for compatibility.\n\nI currently support [![GitHub package.json dependency version (prod)](https://img.shields.io/github/package-json/dependency-version/kcwinner/cdk-appsync-transformer/@aws-cdk/core)](https://github.com/aws/aws-cdk)\n\n## Contributing\n\nSee [CONTRIBUTING](CONTRIBUTING.md) for details\n\n## License\n\nDistributed under [Apache License, Version 2.0](LICENSE)\n\n## References\n\n- [aws cdk](https://aws.amazon.com/cdk)\n- [amplify-cli](https://github.com/aws-amplify/amplify-cli)\n- [Amplify Directives](https://docs.amplify.aws/cli/graphql-transformer/directives)\n\n\n# Sponsors\n\n## [Stedi](https://www.stedi.com/)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkcwinner%2Fcdk-appsync-transformer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkcwinner%2Fcdk-appsync-transformer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkcwinner%2Fcdk-appsync-transformer/lists"}