Skip to content

Commit 52b535b

Browse files
authoredDec 6, 2021
fix(appsync): add caching config to AppSync resolvers (#17815)
While trying to add caching config to some of my application's resolvers, I discovered that the BaseResolverProps do not include caching configuration like the CfnResolver does. This PR adds this missing caching configuration to the BaseResolverProps and adds the configuration as part of the creation of the CfnResolver. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 5737c33 commit 52b535b

12 files changed

+200
-1
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Duration } from '@aws-cdk/core';
2+
3+
/**
4+
* CachingConfig for AppSync resolvers
5+
*/
6+
export interface CachingConfig {
7+
/**
8+
* The caching keys for a resolver that has caching enabled.
9+
* Valid values are entries from the $context.arguments, $context.source, and $context.identity maps.
10+
*
11+
* @default - No caching keys
12+
*/
13+
readonly cachingKeys?: string[];
14+
15+
/**
16+
* The TTL in seconds for a resolver that has caching enabled.
17+
* Valid values are between 1 and 3600 seconds.
18+
*
19+
* @default - No TTL
20+
*/
21+
readonly ttl?: Duration;
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export const CONTEXT_ARGUMENTS_CACHING_KEY = '$context.arguments';
2+
export const CONTEXT_SOURCE_CACHING_KEY = '$context.source';
3+
export const CONTEXT_IDENTITY_CACHING_KEY = '$context.identity';
4+
export const BASE_CACHING_KEYS = [CONTEXT_ARGUMENTS_CACHING_KEY, CONTEXT_SOURCE_CACHING_KEY, CONTEXT_IDENTITY_CACHING_KEY];

‎packages/@aws-cdk/aws-appsync/lib/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// AWS::AppSync CloudFormation Resources:
22
export * from './appsync-function';
33
export * from './appsync.generated';
4+
export * from './caching-config';
5+
export * from './caching-key';
46
export * from './key';
57
export * from './data-source';
68
export * from './mapping-template';

‎packages/@aws-cdk/aws-appsync/lib/resolver.ts

+24-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import { Construct } from 'constructs';
22
import { IAppsyncFunction } from './appsync-function';
33
import { CfnResolver } from './appsync.generated';
4+
import { CachingConfig } from './caching-config';
5+
import { BASE_CACHING_KEYS } from './caching-key';
46
import { BaseDataSource } from './data-source';
57
import { IGraphqlApi } from './graphqlapi-base';
68
import { MappingTemplate } from './mapping-template';
79

810
// v2 - keep this import as a separate section to reduce merge conflict when forward merging with the v2 branch.
911
// eslint-disable-next-line
10-
import { Construct as CoreConstruct } from '@aws-cdk/core';
12+
import { Construct as CoreConstruct, Token } from '@aws-cdk/core';
1113

1214
/**
1315
* Basic properties for an AppSync resolver
@@ -40,6 +42,12 @@ export interface BaseResolverProps {
4042
* @default - No mapping template
4143
*/
4244
readonly responseMappingTemplate?: MappingTemplate;
45+
/**
46+
* The caching configuration for this resolver
47+
*
48+
* @default - No caching configuration
49+
*/
50+
readonly cachingConfig?: CachingConfig;
4351
}
4452

4553
/**
@@ -86,6 +94,17 @@ export class Resolver extends CoreConstruct {
8694
throw new Error(`Pipeline Resolver cannot have data source. Received: ${props.dataSource.name}`);
8795
}
8896

97+
if (props.cachingConfig?.ttl && (props.cachingConfig.ttl.toSeconds() < 1 || props.cachingConfig.ttl.toSeconds() > 3600)) {
98+
throw new Error(`Caching config TTL must be between 1 and 3600 seconds. Received: ${props.cachingConfig.ttl.toSeconds()}`);
99+
}
100+
101+
if (props.cachingConfig?.cachingKeys) {
102+
if (props.cachingConfig.cachingKeys.find(cachingKey =>
103+
!Token.isUnresolved(cachingKey) && !BASE_CACHING_KEYS.find(baseCachingKey => cachingKey.startsWith(baseCachingKey)))) {
104+
throw new Error(`Caching config keys must begin with $context.arguments, $context.source or $context.identity. Received: ${props.cachingConfig.cachingKeys}`);
105+
}
106+
}
107+
89108
this.resolver = new CfnResolver(this, 'Resource', {
90109
apiId: props.api.apiId,
91110
typeName: props.typeName,
@@ -95,6 +114,10 @@ export class Resolver extends CoreConstruct {
95114
pipelineConfig: pipelineConfig,
96115
requestMappingTemplate: props.requestMappingTemplate ? props.requestMappingTemplate.renderTemplate() : undefined,
97116
responseMappingTemplate: props.responseMappingTemplate ? props.responseMappingTemplate.renderTemplate() : undefined,
117+
cachingConfig: {
118+
cachingKeys: props.cachingConfig?.cachingKeys,
119+
ttl: props.cachingConfig?.ttl?.toSeconds(),
120+
},
98121
});
99122
props.api.addSchemaDependency(this.resolver);
100123
if (props.dataSource) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
import * as path from 'path';
2+
import { Template } from '@aws-cdk/assertions';
3+
import * as lambda from '@aws-cdk/aws-lambda';
4+
import * as cdk from '@aws-cdk/core';
5+
import { Duration } from '@aws-cdk/core';
6+
import * as appsync from '../lib';
7+
8+
let stack: cdk.Stack;
9+
let api: appsync.GraphqlApi;
10+
11+
beforeEach(() => {
12+
// GIVEN
13+
stack = new cdk.Stack();
14+
api = new appsync.GraphqlApi(stack, 'api', {
15+
name: 'api',
16+
schema: appsync.Schema.fromAsset(path.join(__dirname, 'appsync.lambda.graphql')),
17+
});
18+
});
19+
20+
describe('Lambda caching config', () => {
21+
// GIVEN
22+
let func: lambda.Function;
23+
24+
beforeEach(() => {
25+
func = new lambda.Function(stack, 'func', {
26+
code: lambda.Code.fromAsset(path.join(__dirname, 'verify/lambda-tutorial')),
27+
handler: 'lambda-tutorial.handler',
28+
runtime: lambda.Runtime.NODEJS_12_X,
29+
});
30+
});
31+
32+
test('Lambda resolver contains caching config with caching key and TTL', () => {
33+
// WHEN
34+
const lambdaDS = api.addLambdaDataSource('LambdaDS', func);
35+
36+
lambdaDS.createResolver({
37+
typeName: 'Query',
38+
fieldName: 'allPosts',
39+
cachingConfig: {
40+
cachingKeys: ['$context.arguments', '$context.source', '$context.identity'],
41+
ttl: Duration.seconds(300),
42+
},
43+
});
44+
45+
// THEN
46+
Template.fromStack(stack).hasResourceProperties('AWS::AppSync::Resolver', {
47+
TypeName: 'Query',
48+
FieldName: 'allPosts',
49+
CachingConfig: {
50+
CachingKeys: ['$context.arguments', '$context.source', '$context.identity'],
51+
Ttl: 300,
52+
},
53+
});
54+
});
55+
56+
test('Lambda resolver throws error when caching config with TTL is less than 1 second', () => {
57+
// WHEN
58+
const ttlInSconds = 0;
59+
const lambdaDS = api.addLambdaDataSource('LambdaDS', func);
60+
61+
// THEN
62+
expect(() => {
63+
lambdaDS.createResolver({
64+
typeName: 'Query',
65+
fieldName: 'allPosts',
66+
cachingConfig: {
67+
cachingKeys: ['$context.identity'],
68+
ttl: Duration.seconds(0),
69+
},
70+
});
71+
}).toThrowError(`Caching config TTL must be between 1 and 3600 seconds. Received: ${ttlInSconds}`);
72+
});
73+
74+
test('Lambda resolver throws error when caching config with TTL is greater than 3600 seconds', () => {
75+
// WHEN
76+
const ttlInSconds = 4200;
77+
const lambdaDS = api.addLambdaDataSource('LambdaDS', func);
78+
79+
// THEN
80+
expect(() => {
81+
lambdaDS.createResolver({
82+
typeName: 'Query',
83+
fieldName: 'allPosts',
84+
cachingConfig: {
85+
cachingKeys: ['$context.identity'],
86+
ttl: Duration.seconds(ttlInSconds),
87+
},
88+
});
89+
}).toThrowError(`Caching config TTL must be between 1 and 3600 seconds. Received: ${ttlInSconds}`);
90+
});
91+
92+
test('Lambda resolver throws error when caching config has invalid caching keys', () => {
93+
// WHEN
94+
const invalidCachingKeys = ['$context.metadata'];
95+
const lambdaDS = api.addLambdaDataSource('LambdaDS', func);
96+
97+
// THEN
98+
expect(() => {
99+
lambdaDS.createResolver({
100+
typeName: 'Query',
101+
fieldName: 'allPosts',
102+
cachingConfig: {
103+
cachingKeys: invalidCachingKeys,
104+
ttl: Duration.seconds(300),
105+
},
106+
});
107+
}).toThrowError(`Caching config keys must begin with $context.arguments, $context.source or $context.identity. Received: ${invalidCachingKeys}`);
108+
});
109+
});

‎packages/@aws-cdk/aws-appsync/test/integ.api-import.expected.json

+3
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@
143143
},
144144
"FieldName": "getTests",
145145
"TypeName": "Query",
146+
"CachingConfig": {},
146147
"DataSourceName": "ds",
147148
"Kind": "UNIT",
148149
"RequestMappingTemplate": "{\"version\" : \"2017-02-28\", \"operation\" : \"Scan\"}",
@@ -160,6 +161,7 @@
160161
},
161162
"FieldName": "addTest",
162163
"TypeName": "Mutation",
164+
"CachingConfig": {},
163165
"DataSourceName": "ds",
164166
"Kind": "UNIT",
165167
"RequestMappingTemplate": "\n #set($input = $ctx.args.test)\n \n {\n \"version\": \"2017-02-28\",\n \"operation\": \"PutItem\",\n \"key\" : {\n \"id\" : $util.dynamodb.toDynamoDBJson($util.autoId())\n },\n \"attributeValues\": $util.dynamodb.toMapValuesJson($input)\n }",
@@ -223,6 +225,7 @@
223225
},
224226
"FieldName": "version",
225227
"TypeName": "test",
228+
"CachingConfig": {},
226229
"Kind": "PIPELINE",
227230
"PipelineConfig": {
228231
"Functions": [

‎packages/@aws-cdk/aws-appsync/test/integ.appsync-lambda.expected.json

+4
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@
114114
},
115115
"FieldName": "getPost",
116116
"TypeName": "Query",
117+
"CachingConfig": {},
117118
"DataSourceName": "LambdaDS",
118119
"Kind": "UNIT",
119120
"RequestMappingTemplate": "{\"version\": \"2017-02-28\", \"operation\": \"Invoke\", \"payload\": { \"field\": \"getPost\", \"arguments\": $utils.toJson($context.arguments)}}",
@@ -135,6 +136,7 @@
135136
},
136137
"FieldName": "allPosts",
137138
"TypeName": "Query",
139+
"CachingConfig": {},
138140
"DataSourceName": "LambdaDS",
139141
"Kind": "UNIT",
140142
"RequestMappingTemplate": "{\"version\": \"2017-02-28\", \"operation\": \"Invoke\", \"payload\": { \"field\": \"allPosts\"}}",
@@ -156,6 +158,7 @@
156158
},
157159
"FieldName": "addPost",
158160
"TypeName": "Mutation",
161+
"CachingConfig": {},
159162
"DataSourceName": "LambdaDS",
160163
"Kind": "UNIT",
161164
"RequestMappingTemplate": "{\"version\": \"2017-02-28\", \"operation\": \"Invoke\", \"payload\": { \"field\": \"addPost\", \"arguments\": $utils.toJson($context.arguments)}}",
@@ -177,6 +180,7 @@
177180
},
178181
"FieldName": "relatedPosts",
179182
"TypeName": "Post",
183+
"CachingConfig": {},
180184
"DataSourceName": "LambdaDS",
181185
"Kind": "UNIT",
182186
"RequestMappingTemplate": "{\"version\": \"2017-02-28\", \"operation\": \"BatchInvoke\", \"payload\": { \"field\": \"relatedPosts\", \"source\": $utils.toJson($context.source)}}",

‎packages/@aws-cdk/aws-appsync/test/integ.auth-apikey.expected.json

+2
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@
132132
},
133133
"FieldName": "getTests",
134134
"TypeName": "Query",
135+
"CachingConfig": {},
135136
"DataSourceName": "testDataSource",
136137
"Kind": "UNIT",
137138
"RequestMappingTemplate": "{\"version\" : \"2017-02-28\", \"operation\" : \"Scan\"}",
@@ -153,6 +154,7 @@
153154
},
154155
"FieldName": "addTest",
155156
"TypeName": "Mutation",
157+
"CachingConfig": {},
156158
"DataSourceName": "testDataSource",
157159
"Kind": "UNIT",
158160
"RequestMappingTemplate": "\n #set($input = $ctx.args.test)\n \n {\n \"version\": \"2017-02-28\",\n \"operation\": \"PutItem\",\n \"key\" : {\n \"id\" : $util.dynamodb.toDynamoDBJson($util.autoId())\n },\n \"attributeValues\": $util.dynamodb.toMapValuesJson($input)\n }",

‎packages/@aws-cdk/aws-appsync/test/integ.graphql-elasticsearch.expected.json

+1
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@
196196
},
197197
"FieldName": "getTests",
198198
"TypeName": "Query",
199+
"CachingConfig": {},
199200
"DataSourceName": "ds",
200201
"Kind": "UNIT",
201202
"RequestMappingTemplate": "{\"version\":\"2017-02-28\",\"operation\":\"GET\",\"path\":\"/id/post/_search\",\"params\":{\"headers\":{},\"queryString\":{},\"body\":{\"from\":0,\"size\":50}}}",

‎packages/@aws-cdk/aws-appsync/test/integ.graphql-iam.expected.json

+3
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@
163163
},
164164
"FieldName": "getTest",
165165
"TypeName": "Query",
166+
"CachingConfig": {},
166167
"DataSourceName": "testDataSource",
167168
"Kind": "UNIT",
168169
"RequestMappingTemplate": "{\"version\": \"2017-02-28\", \"operation\": \"GetItem\", \"key\": {\"id\": $util.dynamodb.toDynamoDBJson($ctx.args.id)}}",
@@ -184,6 +185,7 @@
184185
},
185186
"FieldName": "getTests",
186187
"TypeName": "Query",
188+
"CachingConfig": {},
187189
"DataSourceName": "testDataSource",
188190
"Kind": "UNIT",
189191
"RequestMappingTemplate": "{\"version\" : \"2017-02-28\", \"operation\" : \"Scan\"}",
@@ -205,6 +207,7 @@
205207
},
206208
"FieldName": "addTest",
207209
"TypeName": "Mutation",
210+
"CachingConfig": {},
208211
"DataSourceName": "testDataSource",
209212
"Kind": "UNIT",
210213
"RequestMappingTemplate": "\n #set($input = $ctx.args.test)\n \n {\n \"version\": \"2017-02-28\",\n \"operation\": \"PutItem\",\n \"key\" : {\n \"id\" : $util.dynamodb.toDynamoDBJson($util.autoId())\n },\n \"attributeValues\": $util.dynamodb.toMapValuesJson($input)\n }",

‎packages/@aws-cdk/aws-appsync/test/integ.graphql-schema.expected.json

+2
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@
131131
},
132132
"FieldName": "getPlanets",
133133
"TypeName": "Query",
134+
"CachingConfig": {},
134135
"DataSourceName": "planets",
135136
"Kind": "UNIT",
136137
"RequestMappingTemplate": "{\"version\" : \"2017-02-28\", \"operation\" : \"Scan\"}",
@@ -152,6 +153,7 @@
152153
},
153154
"FieldName": "addPlanet",
154155
"TypeName": "Mutation",
156+
"CachingConfig": {},
155157
"DataSourceName": "planets",
156158
"Kind": "UNIT",
157159
"RequestMappingTemplate": "\n #set($input = $context.arguments)\n $util.qr($input.put(\"name\", $context.arguments.name))\n$util.qr($input.put(\"diameter\", $context.arguments.diameter))\n$util.qr($input.put(\"rotationPeriod\", $context.arguments.rotationPeriod))\n$util.qr($input.put(\"orbitalPeriod\", $context.arguments.orbitalPeriod))\n$util.qr($input.put(\"gravityPeriod\", $context.arguments.gravity))\n$util.qr($input.put(\"population\", $context.arguments.population))\n$util.qr($input.put(\"climates\", $context.arguments.climates))\n$util.qr($input.put(\"terrains\", $context.arguments.terrains))\n$util.qr($input.put(\"surfaceWater\", $context.arguments.surfaceWater))\n {\n \"version\": \"2017-02-28\",\n \"operation\": \"PutItem\",\n \"key\" : {\n \"id\" : $util.dynamodb.toDynamoDBJson($util.autoId())\n },\n \"attributeValues\": $util.dynamodb.toMapValuesJson($input)\n }",

‎packages/@aws-cdk/aws-appsync/test/integ.graphql.expected.json

+24
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
},
104104
"FieldName": "getServiceVersion",
105105
"TypeName": "Query",
106+
"CachingConfig": {},
106107
"DataSourceName": "None",
107108
"Kind": "UNIT",
108109
"RequestMappingTemplate": "{\"version\":\"2017-02-28\"}",
@@ -211,6 +212,7 @@
211212
},
212213
"FieldName": "getCustomers",
213214
"TypeName": "Query",
215+
"CachingConfig": {},
214216
"DataSourceName": "Customer",
215217
"Kind": "UNIT",
216218
"RequestMappingTemplate": "{\"version\" : \"2017-02-28\", \"operation\" : \"Scan\"}",
@@ -232,6 +234,7 @@
232234
},
233235
"FieldName": "getCustomer",
234236
"TypeName": "Query",
237+
"CachingConfig": {},
235238
"DataSourceName": "Customer",
236239
"Kind": "UNIT",
237240
"RequestMappingTemplate": "{\"version\": \"2017-02-28\", \"operation\": \"GetItem\", \"key\": {\"id\": $util.dynamodb.toDynamoDBJson($ctx.args.id)}}",
@@ -253,6 +256,7 @@
253256
},
254257
"FieldName": "addCustomer",
255258
"TypeName": "Mutation",
259+
"CachingConfig": {},
256260
"DataSourceName": "Customer",
257261
"Kind": "UNIT",
258262
"RequestMappingTemplate": "\n #set($input = $ctx.args.customer)\n \n {\n \"version\": \"2017-02-28\",\n \"operation\": \"PutItem\",\n \"key\" : {\n \"id\" : $util.dynamodb.toDynamoDBJson($util.autoId())\n },\n \"attributeValues\": $util.dynamodb.toMapValuesJson($input)\n }",
@@ -274,6 +278,7 @@
274278
},
275279
"FieldName": "saveCustomer",
276280
"TypeName": "Mutation",
281+
"CachingConfig": {},
277282
"DataSourceName": "Customer",
278283
"Kind": "UNIT",
279284
"RequestMappingTemplate": "\n #set($input = $ctx.args.customer)\n \n {\n \"version\": \"2017-02-28\",\n \"operation\": \"PutItem\",\n \"key\" : {\n \"id\" : $util.dynamodb.toDynamoDBJson($ctx.args.id)\n },\n \"attributeValues\": $util.dynamodb.toMapValuesJson($input)\n }",
@@ -295,6 +300,7 @@
295300
},
296301
"FieldName": "saveCustomerWithFirstOrder",
297302
"TypeName": "Mutation",
303+
"CachingConfig": {},
298304
"DataSourceName": "Customer",
299305
"Kind": "UNIT",
300306
"RequestMappingTemplate": "\n #set($input = $ctx.args.order)\n $util.qr($input.put(\"referral\", referral))\n {\n \"version\": \"2017-02-28\",\n \"operation\": \"PutItem\",\n \"key\" : {\n \"order\" : $util.dynamodb.toDynamoDBJson($util.autoId()),\"customer\" : $util.dynamodb.toDynamoDBJson($ctx.args.customer.id)\n },\n \"attributeValues\": $util.dynamodb.toMapValuesJson($input)\n }",
@@ -316,6 +322,7 @@
316322
},
317323
"FieldName": "removeCustomer",
318324
"TypeName": "Mutation",
325+
"CachingConfig": {},
319326
"DataSourceName": "Customer",
320327
"Kind": "UNIT",
321328
"RequestMappingTemplate": "{\"version\": \"2017-02-28\", \"operation\": \"DeleteItem\", \"key\": {\"id\": $util.dynamodb.toDynamoDBJson($ctx.args.id)}}",
@@ -435,6 +442,7 @@
435442
},
436443
"FieldName": "getCustomerOrdersEq",
437444
"TypeName": "Query",
445+
"CachingConfig": {},
438446
"DataSourceName": "Order",
439447
"Kind": "UNIT",
440448
"RequestMappingTemplate": "{\"version\" : \"2017-02-28\", \"operation\" : \"Query\", \"query\" : {\n \"expression\" : \"#customer = :customer\",\n \"expressionNames\" : {\n \"#customer\" : \"customer\"\n },\n \"expressionValues\" : {\n \":customer\" : $util.dynamodb.toDynamoDBJson($ctx.args.customer)\n }\n }}",
@@ -456,6 +464,7 @@
456464
},
457465
"FieldName": "getOrderCustomersEq",
458466
"TypeName": "Query",
467+
"CachingConfig": {},
459468
"DataSourceName": "Order",
460469
"Kind": "UNIT",
461470
"RequestMappingTemplate": "{\"version\" : \"2017-02-28\", \"operation\" : \"Query\", \"index\" : \"orderIndex\", \"query\" : {\n \"expression\" : \"#order = :order\",\n \"expressionNames\" : {\n \"#order\" : \"order\"\n },\n \"expressionValues\" : {\n \":order\" : $util.dynamodb.toDynamoDBJson($ctx.args.order)\n }\n }}",
@@ -477,6 +486,7 @@
477486
},
478487
"FieldName": "getCustomerOrdersLt",
479488
"TypeName": "Query",
489+
"CachingConfig": {},
480490
"DataSourceName": "Order",
481491
"Kind": "UNIT",
482492
"RequestMappingTemplate": "{\"version\" : \"2017-02-28\", \"operation\" : \"Query\", \"query\" : {\n \"expression\" : \"#customer < :customer\",\n \"expressionNames\" : {\n \"#customer\" : \"customer\"\n },\n \"expressionValues\" : {\n \":customer\" : $util.dynamodb.toDynamoDBJson($ctx.args.customer)\n }\n }}",
@@ -498,6 +508,7 @@
498508
},
499509
"FieldName": "getOrderCustomersLt",
500510
"TypeName": "Query",
511+
"CachingConfig": {},
501512
"DataSourceName": "Order",
502513
"Kind": "UNIT",
503514
"RequestMappingTemplate": "{\"version\" : \"2017-02-28\", \"operation\" : \"Query\", \"index\" : \"orderIndex\", \"query\" : {\n \"expression\" : \"#order < :order\",\n \"expressionNames\" : {\n \"#order\" : \"order\"\n },\n \"expressionValues\" : {\n \":order\" : $util.dynamodb.toDynamoDBJson($ctx.args.order)\n }\n }}",
@@ -519,6 +530,7 @@
519530
},
520531
"FieldName": "getCustomerOrdersLe",
521532
"TypeName": "Query",
533+
"CachingConfig": {},
522534
"DataSourceName": "Order",
523535
"Kind": "UNIT",
524536
"RequestMappingTemplate": "{\"version\" : \"2017-02-28\", \"operation\" : \"Query\", \"query\" : {\n \"expression\" : \"#customer <= :customer\",\n \"expressionNames\" : {\n \"#customer\" : \"customer\"\n },\n \"expressionValues\" : {\n \":customer\" : $util.dynamodb.toDynamoDBJson($ctx.args.customer)\n }\n }}",
@@ -540,6 +552,7 @@
540552
},
541553
"FieldName": "getOrderCustomersLe",
542554
"TypeName": "Query",
555+
"CachingConfig": {},
543556
"DataSourceName": "Order",
544557
"Kind": "UNIT",
545558
"RequestMappingTemplate": "{\"version\" : \"2017-02-28\", \"operation\" : \"Query\", \"index\" : \"orderIndex\", \"query\" : {\n \"expression\" : \"#order <= :order\",\n \"expressionNames\" : {\n \"#order\" : \"order\"\n },\n \"expressionValues\" : {\n \":order\" : $util.dynamodb.toDynamoDBJson($ctx.args.order)\n }\n }}",
@@ -561,6 +574,7 @@
561574
},
562575
"FieldName": "getCustomerOrdersGt",
563576
"TypeName": "Query",
577+
"CachingConfig": {},
564578
"DataSourceName": "Order",
565579
"Kind": "UNIT",
566580
"RequestMappingTemplate": "{\"version\" : \"2017-02-28\", \"operation\" : \"Query\", \"query\" : {\n \"expression\" : \"#customer > :customer\",\n \"expressionNames\" : {\n \"#customer\" : \"customer\"\n },\n \"expressionValues\" : {\n \":customer\" : $util.dynamodb.toDynamoDBJson($ctx.args.customer)\n }\n }}",
@@ -582,6 +596,7 @@
582596
},
583597
"FieldName": "getOrderCustomersGt",
584598
"TypeName": "Query",
599+
"CachingConfig": {},
585600
"DataSourceName": "Order",
586601
"Kind": "UNIT",
587602
"RequestMappingTemplate": "{\"version\" : \"2017-02-28\", \"operation\" : \"Query\", \"index\" : \"orderIndex\", \"query\" : {\n \"expression\" : \"#order > :order\",\n \"expressionNames\" : {\n \"#order\" : \"order\"\n },\n \"expressionValues\" : {\n \":order\" : $util.dynamodb.toDynamoDBJson($ctx.args.order)\n }\n }}",
@@ -603,6 +618,7 @@
603618
},
604619
"FieldName": "getCustomerOrdersGe",
605620
"TypeName": "Query",
621+
"CachingConfig": {},
606622
"DataSourceName": "Order",
607623
"Kind": "UNIT",
608624
"RequestMappingTemplate": "{\"version\" : \"2017-02-28\", \"operation\" : \"Query\", \"query\" : {\n \"expression\" : \"#customer >= :customer\",\n \"expressionNames\" : {\n \"#customer\" : \"customer\"\n },\n \"expressionValues\" : {\n \":customer\" : $util.dynamodb.toDynamoDBJson($ctx.args.customer)\n }\n }}",
@@ -624,6 +640,7 @@
624640
},
625641
"FieldName": "getOrderCustomersGe",
626642
"TypeName": "Query",
643+
"CachingConfig": {},
627644
"DataSourceName": "Order",
628645
"Kind": "UNIT",
629646
"RequestMappingTemplate": "{\"version\" : \"2017-02-28\", \"operation\" : \"Query\", \"index\" : \"orderIndex\", \"query\" : {\n \"expression\" : \"#order >= :order\",\n \"expressionNames\" : {\n \"#order\" : \"order\"\n },\n \"expressionValues\" : {\n \":order\" : $util.dynamodb.toDynamoDBJson($ctx.args.order)\n }\n }}",
@@ -645,6 +662,7 @@
645662
},
646663
"FieldName": "getCustomerOrdersFilter",
647664
"TypeName": "Query",
665+
"CachingConfig": {},
648666
"DataSourceName": "Order",
649667
"Kind": "UNIT",
650668
"RequestMappingTemplate": "{\"version\" : \"2017-02-28\", \"operation\" : \"Query\", \"query\" : {\n \"expression\" : \"#customer = :customer AND begins_with(#order, :order)\",\n \"expressionNames\" : {\n \"#customer\" : \"customer\", \"#order\" : \"order\"\n },\n \"expressionValues\" : {\n \":customer\" : $util.dynamodb.toDynamoDBJson($ctx.args.customer), \":order\" : $util.dynamodb.toDynamoDBJson($ctx.args.order)\n }\n }}",
@@ -666,6 +684,7 @@
666684
},
667685
"FieldName": "getCustomerOrdersBetween",
668686
"TypeName": "Query",
687+
"CachingConfig": {},
669688
"DataSourceName": "Order",
670689
"Kind": "UNIT",
671690
"RequestMappingTemplate": "{\"version\" : \"2017-02-28\", \"operation\" : \"Query\", \"query\" : {\n \"expression\" : \"#customer = :customer AND #order BETWEEN :order1 AND :order2\",\n \"expressionNames\" : {\n \"#customer\" : \"customer\", \"#order\" : \"order\"\n },\n \"expressionValues\" : {\n \":customer\" : $util.dynamodb.toDynamoDBJson($ctx.args.customer), \":order1\" : $util.dynamodb.toDynamoDBJson($ctx.args.order1), \":order2\" : $util.dynamodb.toDynamoDBJson($ctx.args.order2)\n }\n }}",
@@ -687,6 +706,7 @@
687706
},
688707
"FieldName": "getOrderCustomersFilter",
689708
"TypeName": "Query",
709+
"CachingConfig": {},
690710
"DataSourceName": "Order",
691711
"Kind": "UNIT",
692712
"RequestMappingTemplate": "{\"version\" : \"2017-02-28\", \"operation\" : \"Query\", \"query\" : {\n \"expression\" : \"#order = :order AND begins_with(#customer, :customer)\",\n \"expressionNames\" : {\n \"#order\" : \"order\", \"#customer\" : \"customer\"\n },\n \"expressionValues\" : {\n \":order\" : $util.dynamodb.toDynamoDBJson($ctx.args.order), \":customer\" : $util.dynamodb.toDynamoDBJson($ctx.args.customer)\n }\n }}",
@@ -708,6 +728,7 @@
708728
},
709729
"FieldName": "getOrderCustomersBetween",
710730
"TypeName": "Query",
731+
"CachingConfig": {},
711732
"DataSourceName": "Order",
712733
"Kind": "UNIT",
713734
"RequestMappingTemplate": "{\"version\" : \"2017-02-28\", \"operation\" : \"Query\", \"index\" : \"orderIndex\", \"query\" : {\n \"expression\" : \"#order = :order AND #customer BETWEEN :customer1 AND :customer2\",\n \"expressionNames\" : {\n \"#order\" : \"order\", \"#customer\" : \"customer\"\n },\n \"expressionValues\" : {\n \":order\" : $util.dynamodb.toDynamoDBJson($ctx.args.order), \":customer1\" : $util.dynamodb.toDynamoDBJson($ctx.args.customer1), \":customer2\" : $util.dynamodb.toDynamoDBJson($ctx.args.customer2)\n }\n }}",
@@ -828,6 +849,7 @@
828849
},
829850
"FieldName": "getPayment",
830851
"TypeName": "Query",
852+
"CachingConfig": {},
831853
"DataSourceName": "Payment",
832854
"Kind": "UNIT",
833855
"RequestMappingTemplate": "{\"version\": \"2017-02-28\", \"operation\": \"GetItem\", \"key\": {\"id\": $util.dynamodb.toDynamoDBJson($ctx.args.id)}}",
@@ -849,6 +871,7 @@
849871
},
850872
"FieldName": "savePayment",
851873
"TypeName": "Mutation",
874+
"CachingConfig": {},
852875
"DataSourceName": "Payment",
853876
"Kind": "UNIT",
854877
"RequestMappingTemplate": "\n #set($input = $ctx.args.payment)\n \n {\n \"version\": \"2017-02-28\",\n \"operation\": \"PutItem\",\n \"key\" : {\n \"id\" : $util.dynamodb.toDynamoDBJson($util.autoId())\n },\n \"attributeValues\": $util.dynamodb.toMapValuesJson($input)\n }",
@@ -909,6 +932,7 @@
909932
},
910933
"FieldName": "doPostOnAws",
911934
"TypeName": "Mutation",
935+
"CachingConfig": {},
912936
"DataSourceName": "http",
913937
"Kind": "UNIT",
914938
"RequestMappingTemplate": "{\n \"version\": \"2018-05-29\",\n \"method\": \"POST\",\n # if full path is https://api.xxxxxxxxx.com/posts then resourcePath would be /posts\n \"resourcePath\": \"/path/123\",\n \"params\":{\n \"body\": $util.toJson($ctx.args),\n \"headers\":{\n \"Content-Type\": \"application/json\",\n \"Authorization\": \"$ctx.request.headers.Authorization\"\n }\n }\n }",

0 commit comments

Comments
 (0)
Please sign in to comment.