File tree Expand file tree Collapse file tree 2 files changed +65
-1
lines changed
Expand file tree Collapse file tree 2 files changed +65
-1
lines changed Original file line number Diff line number Diff line change @@ -1077,5 +1077,69 @@ describe('Resolvers', () => {
10771077 }
10781078 ` ) ;
10791079 } ) ;
1080+
1081+ it ( 'should fallback to global caching TTL' , ( ) => {
1082+ const api = new Api (
1083+ given . appSyncConfig ( {
1084+ caching : {
1085+ behavior : 'PER_RESOLVER_CACHING' ,
1086+ ttl : 300 ,
1087+ } ,
1088+ dataSources : {
1089+ myTable : {
1090+ name : 'myTable' ,
1091+ type : 'AMAZON_DYNAMODB' ,
1092+ config : { tableName : 'data' } ,
1093+ } ,
1094+ } ,
1095+ } ) ,
1096+ plugin ,
1097+ ) ;
1098+ expect (
1099+ api . compileResolver ( {
1100+ dataSource : 'myTable' ,
1101+ kind : 'UNIT' ,
1102+ type : 'Query' ,
1103+ field : 'user' ,
1104+ caching : {
1105+ keys : [ '$context.identity.sub' , '$context.arguments.id' ] ,
1106+ } ,
1107+ } ) ,
1108+ ) . toMatchInlineSnapshot ( `
1109+ Object {
1110+ "GraphQlResolverQueryuser": Object {
1111+ "DependsOn": Array [
1112+ "GraphQlSchema",
1113+ ],
1114+ "Properties": Object {
1115+ "ApiId": Object {
1116+ "Fn::GetAtt": Array [
1117+ "GraphQlApi",
1118+ "ApiId",
1119+ ],
1120+ },
1121+ "CachingConfig": Object {
1122+ "CachingKeys": Array [
1123+ "$context.identity.sub",
1124+ "$context.arguments.id",
1125+ ],
1126+ "Ttl": 300,
1127+ },
1128+ "DataSourceName": Object {
1129+ "Fn::GetAtt": Array [
1130+ "GraphQlDsmyTable",
1131+ "Name",
1132+ ],
1133+ },
1134+ "FieldName": "user",
1135+ "Kind": "UNIT",
1136+ "MaxBatchSize": undefined,
1137+ "TypeName": "Query",
1138+ },
1139+ "Type": "AWS::AppSync::Resolver",
1140+ },
1141+ }
1142+ ` ) ;
1143+ } ) ;
10801144 } ) ;
10811145} ) ;
Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ export class Resolver {
6767 } else if ( typeof this . config . caching === 'object' ) {
6868 Properties . CachingConfig = {
6969 CachingKeys : this . config . caching . keys ,
70- Ttl : this . config . caching . ttl || this . config . caching . ttl || 3600 ,
70+ Ttl : this . config . caching . ttl || this . api . config . caching ? .ttl || 3600 ,
7171 } ;
7272 }
7373 }
You can’t perform that action at this time.
0 commit comments