aws-cdk-appsync-transformer-1.63.0rc3
توضیحات
AWS Amplify inspired CDK construct for creating @directive based AppSync APIs
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | aws-cdk-appsync-transformer-1.63.0rc3 |
| نام | aws-cdk-appsync-transformer |
| نسخه کتابخانه | 1.63.0rc3 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Ken Winner |
| ایمیل نویسنده | - |
| آدرس صفحه اصلی | https://github.com/kcwinner/appsync-transformer-construct.git |
| آدرس اینترنتی | https://pypi.org/project/aws-cdk-appsync-transformer/ |
| مجوز | Apache-2.0 |
# AppSync Transformer Construct for AWS CDK

[](https://codecov.io/gh/kcwinner/aws-cdk-appsync-transformer)
[](https://david-dm.org/kcwinner/aws-cdk-appsync-transformer)
[](https://www.npmjs.com/package/aws-cdk-appsync-transformer)
[](https://badge.fury.io/js/aws-cdk-appsync-transformer)
[](https://badge.fury.io/py/aws-cdk-appsync-transformer)
<!-- [](https://badge.fury.io/nu/Kcwinner.AWSCDKAppSyncTransformer)
[](https://repo1.maven.org/maven2/io/github/kcwinner/AWSCDKAppSyncTransformer/) -->
## Why This Package
In 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.
This package is my attempt to convert all of that effort into a separate construct in order to clean up the process.
## How Do I Use It
### Example Usage
API With Default Values
```python
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
from aws_cdk_appsync_transformer import AppSyncTransformer
AppSyncTransformer(self, "my-cool-api",
schema_path="schema.graphql"
)
```
schema.graphql
```graphql
type Customer @model
@auth(rules: [
{ allow: groups, groups: ["Admins"] },
{ allow: private, provider: iam, operations: [read, update] }
]) {
id: ID!
firstName: String!
lastName: String!
active: Boolean!
address: String!
}
type Product @model
@auth(rules: [
{ allow: groups, groups: ["Admins"] },
{ allow: public, provider: iam, operations: [read] }
]) {
id: ID!
name: String!
description: String!
price: String!
active: Boolean!
added: AWSDateTime!
orders: [Order] @connection
}
type Order @model
@key(fields: ["id", "productID"]) {
id: ID!
productID: ID!
total: String!
ordered: AWSDateTime!
}
```
### [Supported Amplify Directives](https://docs.amplify.aws/cli/graphql-transformer/directives)
Tested:
* [@model](https://docs.amplify.aws/cli/graphql-transformer/directives#model)
* [@auth](https://docs.amplify.aws/cli/graphql-transformer/directives#auth)
* [@connection](https://docs.amplify.aws/cli/graphql-transformer/directives#connection)
Experimental:
* [@key](https://docs.amplify.aws/cli/graphql-transformer/directives#key)
* [@versioned](https://docs.amplify.aws/cli/graphql-transformer/directives#versioned)
* [@function](https://docs.amplify.aws/cli/graphql-transformer/directives#function)
* These work differently here than they do in Amplify - see [Functions](#functions) below
Not Yet Supported:
* [@searchable](https://docs.amplify.aws/cli/graphql-transformer/directives#searchable)
* [@predictions](https://docs.amplify.aws/cli/graphql-transformer/directives#predictions)
* [@http](https://docs.amplify.aws/cli/graphql-transformer/directives#http)
### Authentication
User Pool Authentication
```python
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
user_pool = UserPool(self, "my-cool-user-pool", ...
)
user_pool_client = UserPoolClient(self, f"{id}-client",
user_pool=self.user_pool, ...
)
AppSyncTransformer(self, "my-cool-api",
schema_path="schema.graphql",
authorization_config={
"default_authorization": {
"authorization_type": AuthorizationType.USER_POOL,
"user_pool_config": {
"user_pool": user_pool,
"app_id_client_regex": user_pool_client.user_pool_client_id,
"default_action": UserPoolDefaultAction.ALLOW
}
}
}
)
```
#### IAM
Unauth Role: TODO
Auth Role: Unsupported (for now?). Authorized roles (Lambda Functions, EC2 roles, etc) are required to setup their own role permissions.
### Functions
Fields with the `@function` directive will be accessible via `api.outputs.FUNCTION_RESOLVERS`. It will return an array like below.Currently these are not named and do not specify a region. There are improvements that can be made here but this simple way has worked for me so I've implemented it first. Typically I send all `@function` requests to one Lambda Function and have it route as necessary.
```js
[
{ typeName: 'Query', fieldName: 'listUsers' },
{ typeName: 'Query', fieldName: 'getUser' },
{ typeName: 'Mutation', fieldName: 'createUser' },
{ typeName: 'Mutation', fieldName: 'updateUser' }
]
```
### DataStore Support
1. Pass `syncEnabled: true` to the `AppSyncTransformerProps`
2. Generate necessary exports (see [Code Generation](#code-generation) below)
### Code Generation
I'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).
## Versioning
I will *attempt* to align the major and minor version of this package with [AWS CDK](https://aws.amazon.com/cdk), but always check the release descriptions for compatibility.
I currently support [](https://github.com/aws/aws-cdk)
## Limitations
*
## Contributing
See [CONTRIBUTING](CONTRIBUTING.md) for details
## License
Distributed under [Apache License, Version 2.0](LICENSE)
نیازمندی
| مقدار | نام |
|---|---|
| ==1.63.0 | aws-cdk.aws-appsync |
| ==1.63.0 | aws-cdk.aws-cognito |
| ==1.63.0 | aws-cdk.aws-dynamodb |
| ==1.63.0 | aws-cdk.aws-iam |
| ==1.63.0 | aws-cdk.aws-lambda |
| ==1.63.0 | aws-cdk.core |
| <4.0.0,>=3.0.4 | constructs |
| <2.0.0,>=1.12.0 | jsii |
| >=0.0.3 | publication |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.6 | Python |
نحوه نصب
نصب پکیج whl aws-cdk-appsync-transformer-1.63.0rc3:
pip install aws-cdk-appsync-transformer-1.63.0rc3.whl
نصب پکیج tar.gz aws-cdk-appsync-transformer-1.63.0rc3:
pip install aws-cdk-appsync-transformer-1.63.0rc3.tar.gz