AWS Amplify inspired CDK construct for creating @directive based AppSync APIs
Project description
AppSync Transformer Construct for AWS CDK
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 TypeScript Usage
stack.ts
# 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
Unauth Role: TODO
Auth Role: Unsupported (for now?). Authorized roles (Lambda Functions, EC2 roles, etc) are required to setup their own role permissions.
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.
Contributing
See CONTRIBUTING for details
License
Distributed under Apache License, Version 2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for aws-cdk-appsync-transformer-1.49.1a0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86809f651e8c16cbdbbf4d80bd4c8fb19b13c1e2743576032630d2a7fc651ad6 |
|
MD5 | c5bda1d629cdbe68585528187f32b2e0 |
|
BLAKE2b-256 | 78621464ed14283c61c647d5b4ed838787c96602d5652c0060a18d37439f7abd |
Hashes for aws_cdk_appsync_transformer-1.49.1a0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 650a63123eb16103052e1d1c5d7ea383b9ee2cb57d0a7188967a4bb249ba20dc |
|
MD5 | e70ec2fb20e3018e4f2a89a451634459 |
|
BLAKE2b-256 | 36ed12f2c3755001f3948599febea1161232ddb3ea67826b63d3cfe81fc75839 |