@aws-amplify/graphql-model-transformer 2.1.1 → 2.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`ModelTransformer: should filter known input types from create and update input fields 1`] = `
3
+ exports[`ModelTransformer: should filter known input types from create and update input fields 1`] = `
4
4
  "type Test {
5
5
  id: ID!
6
6
  email: Email
@@ -285,7 +285,7 @@ input ModelSubscriptionEmailFilterInput {
285
285
  "
286
286
  `;
287
287
 
288
- exports[`ModelTransformer: should generate enum input objects 1`] = `
288
+ exports[`ModelTransformer: should generate enum input objects 1`] = `
289
289
  "type Post {
290
290
  id: ID!
291
291
  title: String!
@@ -810,7 +810,7 @@ input ModelSubscriptionCommentFilterInput {
810
810
  "
811
811
  `;
812
812
 
813
- exports[`ModelTransformer: should generate sync resolver with ConflictHandlerType.Automerge 1`] = `
813
+ exports[`ModelTransformer: should generate sync resolver with ConflictHandlerType.Automerge 1`] = `
814
814
  Object {
815
815
  "Mutation.createPost.init.1.req.vtl": "## [Start] Initialization default values. **
816
816
  $util.qr($ctx.stash.put(\\"defaultValues\\", $util.defaultIfNull($ctx.stash.defaultValues, {})))
@@ -1397,7 +1397,7 @@ $util.toJson(null)
1397
1397
  }
1398
1398
  `;
1399
1399
 
1400
- exports[`ModelTransformer: should generate sync resolver with ConflictHandlerType.LAMBDA 1`] = `
1400
+ exports[`ModelTransformer: should generate sync resolver with ConflictHandlerType.LAMBDA 1`] = `
1401
1401
  Object {
1402
1402
  "Mutation.createPost.init.1.req.vtl": "## [Start] Initialization default values. **
1403
1403
  $util.qr($ctx.stash.put(\\"defaultValues\\", $util.defaultIfNull($ctx.stash.defaultValues, {})))
@@ -1984,7 +1984,7 @@ $util.toJson(null)
1984
1984
  }
1985
1985
  `;
1986
1986
 
1987
- exports[`ModelTransformer: should generate sync resolver with ConflictHandlerType.Optimistic 1`] = `
1987
+ exports[`ModelTransformer: should generate sync resolver with ConflictHandlerType.Optimistic 1`] = `
1988
1988
  Object {
1989
1989
  "Mutation.createPost.init.1.req.vtl": "## [Start] Initialization default values. **
1990
1990
  $util.qr($ctx.stash.put(\\"defaultValues\\", $util.defaultIfNull($ctx.stash.defaultValues, {})))
@@ -2571,7 +2571,7 @@ $util.toJson(null)
2571
2571
  }
2572
2572
  `;
2573
2573
 
2574
- exports[`ModelTransformer: should have timestamps as nullable fields when the type makes it non-nullable 1`] = `
2574
+ exports[`ModelTransformer: should have timestamps as nullable fields when the type makes it non-nullable 1`] = `
2575
2575
  "type Post {
2576
2576
  id: ID!
2577
2577
  str: String
@@ -2810,7 +2810,7 @@ type Subscription {
2810
2810
  "
2811
2811
  `;
2812
2812
 
2813
- exports[`ModelTransformer: should have timestamps as nullable fields when the type makes it non-nullable 2`] = `
2813
+ exports[`ModelTransformer: should have timestamps as nullable fields when the type makes it non-nullable 2`] = `
2814
2814
  "## [Start] Create Request template. **
2815
2815
  #set( $args = $util.defaultIfNull($ctx.stash.transformedArgs, $ctx.args) )
2816
2816
  ## Set the default values to put request **
@@ -2879,7 +2879,7 @@ $util.toJson($PutObject)
2879
2879
  ## [End] Create Request template. **"
2880
2880
  `;
2881
2881
 
2882
- exports[`ModelTransformer: should have timestamps as nullable fields when the type makes it non-nullable 3`] = `
2882
+ exports[`ModelTransformer: should have timestamps as nullable fields when the type makes it non-nullable 3`] = `
2883
2883
  "## [Start] Mutation Update resolver. **
2884
2884
  #set( $args = $util.defaultIfNull($ctx.stash.transformedArgs, $ctx.args) )
2885
2885
  ## Set the default values to put request **
@@ -3013,7 +3013,7 @@ $util.toJson($UpdateItem)
3013
3013
  ## [End] Mutation Update resolver. **"
3014
3014
  `;
3015
3015
 
3016
- exports[`ModelTransformer: should not add default primary key when ID is defined 1`] = `
3016
+ exports[`ModelTransformer: should not add default primary key when ID is defined 1`] = `
3017
3017
  "## [Start] Create Request template. **
3018
3018
  #set( $args = $util.defaultIfNull($ctx.stash.transformedArgs, $ctx.args) )
3019
3019
  ## Set the default values to put request **
@@ -3082,7 +3082,7 @@ $util.toJson($PutObject)
3082
3082
  ## [End] Create Request template. **"
3083
3083
  `;
3084
3084
 
3085
- exports[`ModelTransformer: should not generate superfluous input and filter types 1`] = `
3085
+ exports[`ModelTransformer: should not generate superfluous input and filter types 1`] = `
3086
3086
  "type Entity {
3087
3087
  id: ID!
3088
3088
  str: String
@@ -3246,7 +3246,7 @@ type Query {
3246
3246
  "
3247
3247
  `;
3248
3248
 
3249
- exports[`ModelTransformer: should not to auto generate createdAt and updatedAt when the type in schema is not AWSDateTime 1`] = `
3249
+ exports[`ModelTransformer: should not to auto generate createdAt and updatedAt when the type in schema is not AWSDateTime 1`] = `
3250
3250
  "type Post {
3251
3251
  id: ID!
3252
3252
  str: String
@@ -3485,7 +3485,7 @@ type Subscription {
3485
3485
  "
3486
3486
  `;
3487
3487
 
3488
- exports[`ModelTransformer: should not to auto generate createdAt and updatedAt when the type in schema is not AWSDateTime 2`] = `
3488
+ exports[`ModelTransformer: should not to auto generate createdAt and updatedAt when the type in schema is not AWSDateTime 2`] = `
3489
3489
  "## [Start] Create Request template. **
3490
3490
  #set( $args = $util.defaultIfNull($ctx.stash.transformedArgs, $ctx.args) )
3491
3491
  ## Set the default values to put request **
@@ -3554,7 +3554,7 @@ $util.toJson($PutObject)
3554
3554
  ## [End] Create Request template. **"
3555
3555
  `;
3556
3556
 
3557
- exports[`ModelTransformer: should not to auto generate createdAt and updatedAt when the type in schema is not AWSDateTime 3`] = `
3557
+ exports[`ModelTransformer: should not to auto generate createdAt and updatedAt when the type in schema is not AWSDateTime 3`] = `
3558
3558
  "## [Start] Mutation Update resolver. **
3559
3559
  #set( $args = $util.defaultIfNull($ctx.stash.transformedArgs, $ctx.args) )
3560
3560
  ## Set the default values to put request **
@@ -3688,7 +3688,7 @@ $util.toJson($UpdateItem)
3688
3688
  ## [End] Mutation Update resolver. **"
3689
3689
  `;
3690
3690
 
3691
- exports[`ModelTransformer: should not to include createdAt and updatedAt field when timestamps is set to null 1`] = `
3691
+ exports[`ModelTransformer: should not to include createdAt and updatedAt field when timestamps is set to null 1`] = `
3692
3692
  "type Post {
3693
3693
  id: ID!
3694
3694
  str: String
@@ -3915,7 +3915,7 @@ type Subscription {
3915
3915
  "
3916
3916
  `;
3917
3917
 
3918
- exports[`ModelTransformer: should not to include createdAt and updatedAt field when timestamps is set to null 2`] = `
3918
+ exports[`ModelTransformer: should not to include createdAt and updatedAt field when timestamps is set to null 2`] = `
3919
3919
  "## [Start] Create Request template. **
3920
3920
  #set( $args = $util.defaultIfNull($ctx.stash.transformedArgs, $ctx.args) )
3921
3921
  ## Set the default values to put request **
@@ -3984,7 +3984,7 @@ $util.toJson($PutObject)
3984
3984
  ## [End] Create Request template. **"
3985
3985
  `;
3986
3986
 
3987
- exports[`ModelTransformer: should not to include createdAt and updatedAt field when timestamps is set to null 3`] = `
3987
+ exports[`ModelTransformer: should not to include createdAt and updatedAt field when timestamps is set to null 3`] = `
3988
3988
  "## [Start] Mutation Update resolver. **
3989
3989
  #set( $args = $util.defaultIfNull($ctx.stash.transformedArgs, $ctx.args) )
3990
3990
  ## Set the default values to put request **
@@ -4118,7 +4118,7 @@ $util.toJson($UpdateItem)
4118
4118
  ## [End] Mutation Update resolver. **"
4119
4119
  `;
4120
4120
 
4121
- exports[`ModelTransformer: should successfully transform simple Embeddable type (non-model) schema 1`] = `
4121
+ exports[`ModelTransformer: should successfully transform simple Embeddable type (non-model) schema 1`] = `
4122
4122
  "type NonModelType {
4123
4123
  id: ID!
4124
4124
  title: String!
@@ -4276,7 +4276,7 @@ enum ModelSortDirection {
4276
4276
  "
4277
4277
  `;
4278
4278
 
4279
- exports[`ModelTransformer: should successfully transform simple non-capitalized Model/Embeddable type (non-model) name schema 1`] = `
4279
+ exports[`ModelTransformer: should successfully transform simple non-capitalized Model/Embeddable type (non-model) name schema 1`] = `
4280
4280
  "type modelType {
4281
4281
  id: ID!
4282
4282
  title: String!
@@ -4518,7 +4518,7 @@ type Subscription {
4518
4518
  "
4519
4519
  `;
4520
4520
 
4521
- exports[`ModelTransformer: should support timestamp parameters when generating resolvers and output schema 1`] = `
4521
+ exports[`ModelTransformer: should support timestamp parameters when generating resolvers and output schema 1`] = `
4522
4522
  "type Post {
4523
4523
  id: ID!
4524
4524
  str: String
@@ -4747,7 +4747,7 @@ type Subscription {
4747
4747
  "
4748
4748
  `;
4749
4749
 
4750
- exports[`ModelTransformer: should support timestamp parameters when generating resolvers and output schema 2`] = `
4750
+ exports[`ModelTransformer: should support timestamp parameters when generating resolvers and output schema 2`] = `
4751
4751
  "## [Start] Create Request template. **
4752
4752
  #set( $args = $util.defaultIfNull($ctx.stash.transformedArgs, $ctx.args) )
4753
4753
  ## Set the default values to put request **
@@ -4816,7 +4816,7 @@ $util.toJson($PutObject)
4816
4816
  ## [End] Create Request template. **"
4817
4817
  `;
4818
4818
 
4819
- exports[`ModelTransformer: should support timestamp parameters when generating resolvers and output schema 3`] = `
4819
+ exports[`ModelTransformer: should support timestamp parameters when generating resolvers and output schema 3`] = `
4820
4820
  "## [Start] Mutation Update resolver. **
4821
4821
  #set( $args = $util.defaultIfNull($ctx.stash.transformedArgs, $ctx.args) )
4822
4822
  ## Set the default values to put request **
@@ -4950,7 +4950,7 @@ $util.toJson($UpdateItem)
4950
4950
  ## [End] Mutation Update resolver. **"
4951
4951
  `;
4952
4952
 
4953
- exports[`ModelTransformer: the datastore table should be configured 1`] = `
4953
+ exports[`ModelTransformer: the datastore table should be configured 1`] = `
4954
4954
  "## [Start] Sync Request template. **
4955
4955
  #set( $args = $util.defaultIfNull($ctx.stash.transformedArgs, $ctx.args) )
4956
4956
  #set( $queryFilterContainsAuthField = false )
@@ -5034,7 +5034,7 @@ null
5034
5034
  ## [End] Sync Request template. **"
5035
5035
  `;
5036
5036
 
5037
- exports[`ModelTransformer: the datastore table should be configured 2`] = `
5037
+ exports[`ModelTransformer: the datastore table should be configured 2`] = `
5038
5038
  "## [Start] ResponseTemplate. **
5039
5039
  #if( $ctx.error )
5040
5040
  $util.error($ctx.error.message, $ctx.error.type, $ctx.result)
@@ -16,7 +16,7 @@ import {
16
16
  verifyMatchingTypes,
17
17
  } from './test-utils/helpers';
18
18
 
19
- describe('ModelTransformer: ', () => {
19
+ describe('ModelTransformer:', () => {
20
20
  it('should successfully transform simple valid schema', async () => {
21
21
  const validSchema = `
22
22
  type Post @model {
@@ -603,7 +603,7 @@ describe('ModelTransformer: ', () => {
603
603
  expect(verifyInputCount(parsed, 'TagInput', 1)).toBeTruthy();
604
604
  });
605
605
 
606
- it('it should generate filter inputs', () => {
606
+ it('should generate filter inputs', () => {
607
607
  const validSchema = `
608
608
  type Post @model {
609
609
  id: ID!
@@ -698,7 +698,7 @@ export class ModelTransformer extends TransformerModelBase implements Transforme
698
698
  }
699
699
  case SubscriptionFieldType.ON_CREATE:
700
700
  case SubscriptionFieldType.ON_DELETE:
701
- case SubscriptionFieldType.ON_UPDATE:
701
+ case SubscriptionFieldType.ON_UPDATE: {
702
702
  const filterInputName = toPascalCase(['ModelSubscription', type.name.value, 'FilterInput']);
703
703
  const filterInputs = createEnumModelFilters(ctx, type);
704
704
  filterInputs.push(makeSubscriptionQueryFilterInput(ctx, filterInputName, type));
@@ -710,6 +710,7 @@ export class ModelTransformer extends TransformerModelBase implements Transforme
710
710
  });
711
711
 
712
712
  return [makeInputValueDefinition('filter', makeNamedType(filterInputName))];
713
+ }
713
714
 
714
715
  default:
715
716
  throw new Error('Unknown operation type');
@@ -1,6 +1,6 @@
1
1
  import { MYSQL_DB_TYPE, RDSConnectionSecrets } from '@aws-amplify/graphql-transformer-core';
2
2
  import { TransformerContextProvider } from '@aws-amplify/graphql-transformer-interfaces';
3
- import { Topic } from 'aws-cdk-lib/aws-sns';
3
+ import { Topic, SubscriptionFilter } from 'aws-cdk-lib/aws-sns';
4
4
  import { LambdaSubscription } from 'aws-cdk-lib/aws-sns-subscriptions';
5
5
  import { ResourceConstants } from 'graphql-transformer-common';
6
6
  import { ModelVTLGenerator, RDSModelVTLGenerator } from '../resolvers';
@@ -13,7 +13,6 @@ import {
13
13
  } from '../resolvers/rds';
14
14
  import { ModelResourceGenerator } from './model-resource-generator';
15
15
  import { Fn } from 'aws-cdk-lib';
16
- import { SubscriptionFilter } from 'aws-cdk-lib/aws-sns';
17
16
 
18
17
  export const RDS_STACK_NAME = 'RdsApiStack';
19
18
  // Beta SNS topic - 'arn:aws:sns:us-east-1:956468067974:AmplifyRDSLayerNotification'