Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

AppSync Transformer Construct for AWS CDK

build codecov dependencies Status npm

npm version PyPI version

Why This Package

In April 2020 I wrote a blog post 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

# 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

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

Tested:

Experimental:

Not Yet Supported:

Authentication

User Pool Authentication

# 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.

[
  { 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 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.

Versioning

I will attempt to align the major and minor version of this package with AWS CDK, but always check the release descriptions for compatibility.

I currently support GitHub package.json dependency version (prod)

Limitations

Contributing

See CONTRIBUTING for details

License

Distributed under Apache License, Version 2.0

Metadata

Release files for aws-cdk-appsync-transformer 1.63.0rc3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aws-cdk-appsync-transformer 1.63.0rc3
File Size Uploaded Provenance Actions
aws-cdk-appsync-transformer-1.63.0rc3.tar.gz 12.4 MB Without provenance Details for aws-cdk-appsync-transformer-1.63.0rc3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for aws-cdk-appsync-transformer 1.63.0rc3
File Interpreter ABI Platform Actions
aws_cdk_appsync_transformer-1.63.0rc3-py3-none-any.whl Python 3 none any Details for aws_cdk_appsync_transformer-1.63.0rc3-py3-none-any.whl

Total release size: 24.8 MB

Release files / aws-cdk-appsync-transformer-1.63.0rc3.tar.gz

Download URL aws-cdk-appsync-transformer-1.63.0rc3.tar.gz
Size 12.4 MB
Tags Source
SHA-256 checksum
How to use checksums
c325d248323dfd71731c0cfb7553953a6e8db8f21eebc56afe9d5c8fde12f06a
BLAKE2b-256 checksum
How to use checksums
2664a206b38931e1db3cfa5b6fc61badb74cf74ba6a0399f6764b94a207ab465
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.7.9

Release files / aws_cdk_appsync_transformer-1.63.0rc3-py3-none-any.whl

Download URL aws_cdk_appsync_transformer-1.63.0rc3-py3-none-any.whl
Size 12.4 MB
Tags Python 3
SHA-256 checksum
How to use checksums
4c9ba0e7b6869fc0259db57aa26f0f7ad59fd4815467938a49cf918521239854
BLAKE2b-256 checksum
How to use checksums
7e3a9b890358dfc8049d6899a7ff3d6cf1b7522ec70c0c94d5d95778cd310aae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.7.9

Security for aws-cdk-appsync-transformer 1.63.0rc3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page