Skip to content

Commit 6c2f0c8

Browse files
fix: partially rolling back commit 310 for flutter, swift, and java platforms (#319)
* fix: rolling back commit 310 for flutter, swift, and java platforms * fix: short-circuit field rename * fix: update swift hasMany relationship for compile issues * fix: remove unnecessary revert logic * fix: correct field name * test: add unit tests that we believe are realistic for hasMany/belongsTo * test: adding snapshot tests corresponding to bad output, waiting on platform test pass to update * fix: rm duplicate snapshots for v2 * fix: change dart to null safety * fix: test case 13 for flutter and ios Co-authored-by: Zeyu Li <[email protected]>
1 parent 3401656 commit 6c2f0c8

18 files changed

+11143
-66
lines changed

packages/appsync-modelgen-plugin/src/__tests__/visitors/__snapshots__/appsync-dart-visitor.test.ts.snap

Lines changed: 7 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,8 +1279,6 @@ class _TagModelType extends ModelType<Tag> {
12791279
class PostTags extends Model {
12801280
static const classType = const _PostTagsModelType();
12811281
final String id;
1282-
final String postID;
1283-
final String tagID;
12841282
final Post post;
12851283
final Tag tag;
12861284

@@ -1293,24 +1291,11 @@ class PostTags extends Model {
12931291
}
12941292

12951293
const PostTags._internal(
1296-
{@required this.id,
1297-
@required this.postID,
1298-
@required this.tagID,
1299-
@required this.post,
1300-
@required this.tag});
1294+
{@required this.id, @required this.post, @required this.tag});
13011295

1302-
factory PostTags(
1303-
{String id,
1304-
@required String postID,
1305-
@required String tagID,
1306-
@required Post post,
1307-
@required Tag tag}) {
1296+
factory PostTags({String id, @required Post post, @required Tag tag}) {
13081297
return PostTags._internal(
1309-
id: id == null ? UUID.getUUID() : id,
1310-
postID: postID,
1311-
tagID: tagID,
1312-
post: post,
1313-
tag: tag);
1298+
id: id == null ? UUID.getUUID() : id, post: post, tag: tag);
13141299
}
13151300

13161301
bool equals(Object other) {
@@ -1322,8 +1307,6 @@ class PostTags extends Model {
13221307
if (identical(other, this)) return true;
13231308
return other is PostTags &&
13241309
id == other.id &&
1325-
postID == other.postID &&
1326-
tagID == other.tagID &&
13271310
post == other.post &&
13281311
tag == other.tag;
13291312
}
@@ -1337,47 +1320,31 @@ class PostTags extends Model {
13371320

13381321
buffer.write(\\"PostTags {\\");
13391322
buffer.write(\\"id=\\" + \\"$id\\" + \\", \\");
1340-
buffer.write(\\"postID=\\" + \\"$postID\\" + \\", \\");
1341-
buffer.write(\\"tagID=\\" + \\"$tagID\\" + \\", \\");
13421323
buffer.write(\\"post=\\" + (post != null ? post.toString() : \\"null\\") + \\", \\");
13431324
buffer.write(\\"tag=\\" + (tag != null ? tag.toString() : \\"null\\"));
13441325
buffer.write(\\"}\\");
13451326

13461327
return buffer.toString();
13471328
}
13481329

1349-
PostTags copyWith(
1350-
{String id, String postID, String tagID, Post post, Tag tag}) {
1330+
PostTags copyWith({String id, Post post, Tag tag}) {
13511331
return PostTags(
1352-
id: id ?? this.id,
1353-
postID: postID ?? this.postID,
1354-
tagID: tagID ?? this.tagID,
1355-
post: post ?? this.post,
1356-
tag: tag ?? this.tag);
1332+
id: id ?? this.id, post: post ?? this.post, tag: tag ?? this.tag);
13571333
}
13581334

13591335
PostTags.fromJson(Map<String, dynamic> json)
13601336
: id = json['id'],
1361-
postID = json['postID'],
1362-
tagID = json['tagID'],
13631337
post = json['post'] != null
13641338
? Post.fromJson(new Map<String, dynamic>.from(json['post']))
13651339
: null,
13661340
tag = json['tag'] != null
13671341
? Tag.fromJson(new Map<String, dynamic>.from(json['tag']))
13681342
: null;
13691343

1370-
Map<String, dynamic> toJson() => {
1371-
'id': id,
1372-
'postID': postID,
1373-
'tagID': tagID,
1374-
'post': post?.toJson(),
1375-
'tag': tag?.toJson()
1376-
};
1344+
Map<String, dynamic> toJson() =>
1345+
{'id': id, 'post': post?.toJson(), 'tag': tag?.toJson()};
13771346

13781347
static final QueryField ID = QueryField(fieldName: \\"postTags.id\\");
1379-
static final QueryField POSTID = QueryField(fieldName: \\"postID\\");
1380-
static final QueryField TAGID = QueryField(fieldName: \\"tagID\\");
13811348
static final QueryField POST = QueryField(
13821349
fieldName: \\"post\\",
13831350
fieldType: ModelFieldType(ModelFieldTypeEnum.model,
@@ -1393,16 +1360,6 @@ class PostTags extends Model {
13931360

13941361
modelSchemaDefinition.addField(ModelFieldDefinition.id());
13951362

1396-
modelSchemaDefinition.addField(ModelFieldDefinition.field(
1397-
key: PostTags.POSTID,
1398-
isRequired: true,
1399-
ofType: ModelFieldType(ModelFieldTypeEnum.string)));
1400-
1401-
modelSchemaDefinition.addField(ModelFieldDefinition.field(
1402-
key: PostTags.TAGID,
1403-
isRequired: true,
1404-
ofType: ModelFieldType(ModelFieldTypeEnum.string)));
1405-
14061363
modelSchemaDefinition.addField(ModelFieldDefinition.belongsTo(
14071364
key: PostTags.POST,
14081365
isRequired: true,

0 commit comments

Comments
 (0)