Skip to content

appsyncgen is a CLI for generating AWS AppSync JavaScript Resolvers based on Amazon DynamoDB single-table design.

License

Notifications You must be signed in to change notification settings

tkasuz/appsyncgen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

appsyncgen Go Report Card Go Reference lint status

appsyncgen is a CLI for generating AWS AppSync JavaScript Resolvers based on Amazon DynamoDB single-table design.

appsyncgen is inspired by AWS Amplify CLI

Overview

appsyncgen is a CLI providing some useful capability to develop GraphQL API with AppSync JavaScript Resolver using Amazon DynamoDB single table.

appsyncgen provides:

  • Generate JS resolvers from schema.graphql.
  • Support some directive supported by AWS Amplify (@auth, @hasOne, @hasMany, @manyToMany).
  • @auth directive supports multiple providers (apiKey, oidc, iam, lambda, userPools) which provide resolver-level authorization.
  • Export resolver list by JSON so that you can easily implement CDK stack.
  • Generate CloudFormation Template automatically.
  • Generate Pipeline resolvers for your queries and mutations so that you can slot in your custom business logic between generated resolvers.
  • Optimistic locking with version number for update resolver
  • TypeScript support is coming soon.

Concepts

AWS Amplify CLI is really powerful tool to generate AppSync resolvers using multi-table Amazon DynamoDB, but sometimes building complicated logic is not easy with VTL. appsyncgen helps us generate JavaScript Resolver, which should make it easier to edit auto-generated code. Additionally appsyncgen generate resolvers based on Amazon DynamoDB single-table design, so that you don't need to consider DynamoDB key design by yourself.

Installing

go install github.com/kopkunka55/appsyncgen@latest

For Mac OS

brew tap kopkunka55/appsyncgen
brew install kopkunka55/appsyncgen/appsyncgen

Usage

All you need is schema.graphql which includes only basic types. Mutation/Query/Subscription and some supplemental types will be added.

type Message
@auth (rules: [
    {provider: apiKey},
])
{
    body: String!
    from: User! @hasOne
}

enum Role {
  ADMIN
  READER
  EDITOR
}

type User
@auth (rules: [
    {provider: apiKey, operations: [create, update, delete, read]},
])
{
    name: String!
    chats: [Chat]! @manyToMany
    profilePicture: String
    roles: Role!
}

type Chat
@auth (rules: [
    {provider: apiKey}
])
{
    name: String!
    members: [User] @manyToMany
    messages: [Message] @hasMany
}
appsyncgen generate --output='./resolvers' --schema='./schema.graphql' --name='appsyncgen'

License

The source code for the site is licensed under the MIT license, which you can find in the LICENSE file.

About

appsyncgen is a CLI for generating AWS AppSync JavaScript Resolvers based on Amazon DynamoDB single-table design.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages