All Projects → hirochachacha → Graphql Auto Transformer

hirochachacha / Graphql Auto Transformer

Licence: apache-2.0
A custom transformer of the amplify-cli. It can control accessibility of auto generated fields.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Graphql Auto Transformer

Aws Mobile Appsync Events Starter React
GraphQL starter application with Realtime and Offline functionality using AWS AppSync
Stars: ✭ 337 (+987.1%)
Mutual labels:  graphql, appsync, aws
Aws Appsync Community
The AWS AppSync community
Stars: ✭ 356 (+1048.39%)
Mutual labels:  graphql, appsync, aws
Aws Mobile Appsync Sdk Ios
iOS SDK for AWS AppSync.
Stars: ✭ 231 (+645.16%)
Mutual labels:  graphql, appsync, aws
Aws Serverless Appsync Loyalty
Unicorn Loyalty: E-Commerce Serverless GraphQL Loyalty Sample App
Stars: ✭ 110 (+254.84%)
Mutual labels:  graphql, appsync, aws
Serverless
This is intended to be a repo containing all of the official AWS Serverless architecture patterns built with CDK for developers to use. All patterns come in Typescript and Python with the exported CloudFormation also included.
Stars: ✭ 1,048 (+3280.65%)
Mutual labels:  graphql, appsync, aws
Aws Mobile Appsync Chat Starter Angular
GraphQL starter progressive web application (PWA) with Realtime and Offline functionality using AWS AppSync
Stars: ✭ 449 (+1348.39%)
Mutual labels:  graphql, appsync, aws
Aws Mobile Appsync Events Starter React Native
GraphQL starter application with Realtime and Offline functionality using AWS AppSync
Stars: ✭ 134 (+332.26%)
Mutual labels:  graphql, appsync, aws
Appsync Resolvers Example
Example project for AppSync, GraphQL, and AWS Lambda resolvers using Go.
Stars: ✭ 50 (+61.29%)
Mutual labels:  graphql, appsync, aws
Moviesapp
React Native Movies App: AWS Amplify, AWS AppSync, AWS Cognito, GraphQL, DynamoDB
Stars: ✭ 78 (+151.61%)
Mutual labels:  graphql, appsync, aws
Aws Mobile Appsync Sdk Js
JavaScript library files for Offline, Sync, Sigv4. includes support for React Native
Stars: ✭ 806 (+2500%)
Mutual labels:  graphql, appsync, aws
Cookiecutter Django Vue Graphql Aws
A highly opinionated Cookiecutter template that fuses together Django, Vue.js, GraphQL, and AWS into one full-stack web application.
Stars: ✭ 213 (+587.1%)
Mutual labels:  graphql, aws
Graphql Recipes
A list of GraphQL recipes that, when used with the Amplify CLI, will deploy an entire AWS AppSync GraphQL backend.
Stars: ✭ 137 (+341.94%)
Mutual labels:  graphql, aws
Aws App Sync
Easily Deploy AWS AppSync GraphQL APIs Using Serverless Framework Components
Stars: ✭ 261 (+741.94%)
Mutual labels:  graphql, aws
Aws Lambda Graphql
Use AWS Lambda + AWS API Gateway v2 for GraphQL subscriptions over WebSocket and AWS API Gateway v1 for HTTP
Stars: ✭ 313 (+909.68%)
Mutual labels:  graphql, aws
Serverless Prisma
AWS Serverless Prisma Boilerplate
Stars: ✭ 126 (+306.45%)
Mutual labels:  graphql, aws
Bootcamp 2020
Learn to Build Modern Full Stack Serverless Multi-Tenant SaaS Apps and APIs
Stars: ✭ 369 (+1090.32%)
Mutual labels:  graphql, aws
Aws Serverless Ecommerce Platform
Serverless Ecommerce Platform is a sample implementation of a serverless backend for an e-commerce website. This sample is not meant to be used as an e-commerce platform as-is, but as an inspiration on how to build event-driven serverless microservices on AWS.
Stars: ✭ 469 (+1412.9%)
Mutual labels:  appsync, aws
Practical.cleanarchitecture
Asp.Net Core 5 Clean Architecture (Microservices, Modular Monolith, Monolith) samples (+Blazor, Angular 11, React 17, Vue 2.6), Domain-Driven Design, CQRS, Event Sourcing, SOLID, Asp.Net Core Identity Custom Storage, Identity Server 4 Admin UI, Entity Framework Core, Selenium E2E Testing, SignalR Notification, Hangfire Tasks Scheduling, Health Checks, Security Headers, ...
Stars: ✭ 639 (+1961.29%)
Mutual labels:  graphql, aws
Awesome Aws Appsync
Curated list of AWS AppSync Resources
Stars: ✭ 594 (+1816.13%)
Mutual labels:  graphql, appsync
Conference App In A Box
Full stack & cross platform app customizable & themeable for any event or conference.
Stars: ✭ 693 (+2135.48%)
Mutual labels:  graphql, aws

graphql-auto-transformer

A custom transformer of the amplify-cli. It can control accessibility of auto generated fields.

directive @auto(creatable: Boolean = false, updatable: Boolean = false) on FIELD_DEFINITION

Motivation

If you are familiar with amplify-cli, you know several fields of object are generated by some directives. For example, @model generates createdAt and updatedAt, @versioned generates version, @auth generates owner and so on. Currently, the official way to access these fields from GraphQL API is to define these types as nullable types.

type Post @model {
  id: ID!
  text: String
  createdAt: AWSDateTime
}

However above solution isn't ideal because users can modify createdAt at any time.

input CreatePostInput {
  id: ID
  text: String
  createdAt: AWSDateTime
}

input UpdatePostInput {
  id: ID!
  text: String
  createdAt: AWSDateTime
}

We want to strip createdAt field from CreatePostInput and UpdatePostInput.

What is worse, we cannot use nullable type as a part of a database index. So, we should write:

type Post
  @model
  @key(name: "byUser", fields: ["userId", "createdAt"]) {
    id: ID!
    userId: ID!
    text: String
    createdAt: AWSDateTime!
}

Predictabley, the result is bad. https://github.com/aws-amplify/amplify-cli/issues/1657

Usage

1. Install package

npm install graphql-auto-transformer -D

or

yarn add graphql-auto-transformer -D

2. Setup custom transformer

Edit amplify/backend/api/<YOUR_API>/transform.conf.json and append "./graphql-auto-transformer" to transformers field.

    "transformers": [
      "graphql-auto-transformer"
    ]

3. Use @auto directive

Append @auto to target fields.

type Post @model {
  id: ID!
  text: String
  createdAt: AWSDateTime! @auto
}

generates:

input CreatePostInput {
  id: ID
  text: String
}

input UpdatePostInput {
  id: ID!
  text: String
}

If you want to allow optional creation/update like id field, use creatable and updatable parameter.

type Post @model {
  id: ID!
  text: String
  createdAt: AWSDateTime! @auto(creatable: true)
}

generates:

input CreatePostInput {
  id: ID
  text: String
  createdAt: AWSDateTime
}

input UpdatePostInput {
  id: ID!
  text: String
}

License

Fork of graphql-versioned-transformer

Apache-2.0

Copyright 2017 - 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.

Copyright 2020 - 2020 Hiroshi Ioka. All Rights Reserved.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].