appsyncgen

command module
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 22, 2023 License: MIT Imports: 5 Imported by: 0

README

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.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL