@aws-amplify/graphql-model-transformer 1.1.0-beta.4 → 1.1.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -37,4 +37,33 @@ describe('ModelTransformer: ', () => {
|
|
|
37
37
|
expect(postStack).toMatchSnapshot();
|
|
38
38
|
expect(commentStack).toMatchSnapshot();
|
|
39
39
|
});
|
|
40
|
+
|
|
41
|
+
it('should not override model objects when override file does not exist', () => {
|
|
42
|
+
const validSchema = `
|
|
43
|
+
type Post @model {
|
|
44
|
+
id: ID!
|
|
45
|
+
comments: [Comment]
|
|
46
|
+
}
|
|
47
|
+
type Comment @model{
|
|
48
|
+
id: String!
|
|
49
|
+
text: String!
|
|
50
|
+
}
|
|
51
|
+
`;
|
|
52
|
+
const transformer = new GraphQLTransform({
|
|
53
|
+
transformers: [new ModelTransformer()],
|
|
54
|
+
overrideConfig: {
|
|
55
|
+
overrideDir: path.join(__dirname, 'non-existing-override-directory'),
|
|
56
|
+
overrideFlag: true,
|
|
57
|
+
resourceName: 'myResource',
|
|
58
|
+
},
|
|
59
|
+
featureFlags,
|
|
60
|
+
});
|
|
61
|
+
const out = transformer.transform(validSchema);
|
|
62
|
+
expect(out).toBeDefined();
|
|
63
|
+
const postStack = out.stacks.Post;
|
|
64
|
+
const commentStack = out.stacks.Comment;
|
|
65
|
+
|
|
66
|
+
expect(postStack).toMatchSnapshot();
|
|
67
|
+
expect(commentStack).toMatchSnapshot();
|
|
68
|
+
});
|
|
40
69
|
});
|
|
@@ -1168,7 +1168,89 @@ describe('ModelTransformer: ', () => {
|
|
|
1168
1168
|
},
|
|
1169
1169
|
});
|
|
1170
1170
|
});
|
|
1171
|
+
it("the conflict detection of per model rule should be respected", () => {
|
|
1172
|
+
const validSchema = `
|
|
1173
|
+
type Todo @model {
|
|
1174
|
+
name: String
|
|
1175
|
+
}
|
|
1176
|
+
type Author @model {
|
|
1177
|
+
name: String
|
|
1178
|
+
}
|
|
1179
|
+
`;
|
|
1180
|
+
|
|
1181
|
+
const transformer = new GraphQLTransform({
|
|
1182
|
+
transformConfig: {},
|
|
1183
|
+
resolverConfig: {
|
|
1184
|
+
project: {
|
|
1185
|
+
ConflictDetection: "VERSION",
|
|
1186
|
+
ConflictHandler: ConflictHandlerType.AUTOMERGE
|
|
1187
|
+
},
|
|
1188
|
+
models: {
|
|
1189
|
+
Todo: {
|
|
1190
|
+
ConflictDetection: "VERSION",
|
|
1191
|
+
ConflictHandler: ConflictHandlerType.LAMBDA,
|
|
1192
|
+
LambdaConflictHandler: {
|
|
1193
|
+
name: "myTodoConflictHandler"
|
|
1194
|
+
}
|
|
1195
|
+
},
|
|
1196
|
+
Author: {
|
|
1197
|
+
ConflictDetection: "VERSION",
|
|
1198
|
+
ConflictHandler: ConflictHandlerType.AUTOMERGE
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
},
|
|
1202
|
+
sandboxModeEnabled: true,
|
|
1203
|
+
transformers: [new ModelTransformer()]
|
|
1204
|
+
});
|
|
1205
|
+
const out = transformer.transform(validSchema);
|
|
1206
|
+
expect(out).toBeDefined();
|
|
1207
|
+
const schema = parse(out.schema);
|
|
1208
|
+
validateModelSchema(schema);
|
|
1209
|
+
// nested stacks for models
|
|
1210
|
+
const todoStack = out.stacks["Todo"];
|
|
1211
|
+
const authorStack = out.stacks["Author"];
|
|
1212
|
+
// Todo stack should have lambda for conflict detect rather than auto merge
|
|
1213
|
+
Template.fromJSON(todoStack).hasResourceProperties(
|
|
1214
|
+
"AWS::AppSync::FunctionConfiguration",
|
|
1215
|
+
{
|
|
1216
|
+
SyncConfig: {
|
|
1217
|
+
ConflictDetection: "VERSION",
|
|
1218
|
+
ConflictHandler: "LAMBDA",
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
);
|
|
1222
|
+
Template.fromJSON(todoStack).resourcePropertiesCountIs(
|
|
1223
|
+
"AWS::AppSync::FunctionConfiguration",
|
|
1224
|
+
{
|
|
1225
|
+
SyncConfig: {
|
|
1226
|
+
ConflictDetection: "VERSION",
|
|
1227
|
+
ConflictHandler: "AUTOMERGE",
|
|
1228
|
+
}
|
|
1229
|
+
},
|
|
1230
|
+
0
|
|
1231
|
+
);
|
|
1232
|
+
// Author stack should have automerge for conflict detect rather than lambda
|
|
1233
|
+
Template.fromJSON(authorStack).resourcePropertiesCountIs(
|
|
1234
|
+
"AWS::AppSync::FunctionConfiguration",
|
|
1235
|
+
{
|
|
1236
|
+
SyncConfig: {
|
|
1237
|
+
ConflictDetection: "VERSION",
|
|
1238
|
+
ConflictHandler: "LAMBDA",
|
|
1239
|
+
}
|
|
1240
|
+
},
|
|
1241
|
+
0
|
|
1242
|
+
);
|
|
1243
|
+
Template.fromJSON(authorStack).hasResourceProperties(
|
|
1244
|
+
"AWS::AppSync::FunctionConfiguration",
|
|
1245
|
+
{
|
|
1246
|
+
SyncConfig: {
|
|
1247
|
+
ConflictDetection: "VERSION",
|
|
1248
|
+
ConflictHandler: "AUTOMERGE",
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
);
|
|
1171
1252
|
|
|
1253
|
+
});
|
|
1172
1254
|
it('should add the model parameters at the root sack', () => {
|
|
1173
1255
|
const modelParams = {
|
|
1174
1256
|
DynamoDBModelTableReadIOPS: expect.objectContaining({
|