Skip to content

Commit 4f41416

Browse files
committed
chore: merge in changes from #328
1 parent 289e38b commit 4f41416

File tree

9 files changed

+14
-39
lines changed

9 files changed

+14
-39
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -853,10 +853,10 @@ describe('AppSyncModelVisitor', () => {
853853
expect(visitor.models.Human.fields[2].directives[0].arguments.fields[0]).toEqual('governmentID');
854854
expect(visitor.models.Human.fields[2].directives[0].arguments.indexName).toEqual('byHuman');
855855
expect(visitor.models.PetFriend).toBeDefined();
856-
expect(visitor.models.PetFriend.fields.length).toEqual(7);
857-
expect(visitor.models.PetFriend.fields[4].directives[0].name).toEqual('belongsTo');
858-
expect(visitor.models.PetFriend.fields[4].directives[0].arguments.fields.length).toEqual(1);
859-
expect(visitor.models.PetFriend.fields[4].directives[0].arguments.fields[0]).toEqual('animalID');
856+
expect(visitor.models.PetFriend.fields.length).toEqual(5);
857+
expect(visitor.models.PetFriend.fields[2].directives[0].name).toEqual('belongsTo');
858+
expect(visitor.models.PetFriend.fields[2].directives[0].arguments.fields.length).toEqual(1);
859+
expect(visitor.models.PetFriend.fields[2].directives[0].arguments.fields[0]).toEqual('animalID');
860860
expect(visitor.models.Animal.fields.length).toEqual(5);
861861
expect(visitor.models.Animal.fields[2].type).toEqual('PetFriend');
862862
expect(visitor.models.Animal.fields[2].directives.length).toEqual(1);
@@ -876,7 +876,7 @@ describe('AppSyncModelVisitor', () => {
876876
expect(visitor.models.ModelA.fields[1].directives[0].arguments.indexName).toEqual('byModelA');
877877

878878
expect(visitor.models.Models).toBeDefined();
879-
expect(visitor.models.Models.fields.length).toEqual(7);
879+
expect(visitor.models.Models.fields.length).toEqual(5);
880880

881881
const modelA = visitor.models.Models.fields.find(f => f.name === 'modelA');
882882
expect(modelA).toBeDefined();

packages/appsync-modelgen-plugin/src/__tests__/visitors/gqlv2-regression-tests/__snapshots__/appsync-javascript-visitor.test.ts.snap

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,6 @@ export declare class Project2 {
251251
export declare class Team2 {
252252
readonly id: string;
253253
readonly name: string;
254-
readonly projectID?: string;
255254
readonly project?: Project2;
256255
constructor(init: ModelInit<Team2>);
257256
static copyOf(source: Team2, mutator: (draft: MutableModel<Team2>) => MutableModel<Team2> | void): Team2;
@@ -267,7 +266,6 @@ export declare class Post {
267266

268267
export declare class Comment {
269268
readonly id: string;
270-
readonly postID: string;
271269
readonly content: string;
272270
readonly post?: Post;
273271
constructor(init: ModelInit<Comment>);
@@ -330,7 +328,6 @@ export declare class Project2 {
330328
export declare class Team2 {
331329
readonly id: string;
332330
readonly name: string;
333-
readonly projectID?: string;
334331
readonly project?: Project2;
335332
constructor(init: ModelInit<Team2>);
336333
static copyOf(source: Team2, mutator: (draft: MutableModel<Team2>) => MutableModel<Team2> | void): Team2;
@@ -346,7 +343,6 @@ export declare class Post {
346343

347344
export declare class Comment {
348345
readonly id: string;
349-
readonly postID: string;
350346
readonly content: string;
351347
readonly post?: Post;
352348
constructor(init: ModelInit<Comment>);
@@ -409,7 +405,6 @@ export declare class Project2 {
409405
export declare class Team2 {
410406
readonly id: string;
411407
readonly name: string;
412-
readonly projectID?: string;
413408
readonly project?: Project2;
414409
constructor(init: ModelInit<Team2>);
415410
static copyOf(source: Team2, mutator: (draft: MutableModel<Team2>) => MutableModel<Team2> | void): Team2;
@@ -425,7 +420,6 @@ export declare class Post {
425420

426421
export declare class Comment {
427422
readonly id: string;
428-
readonly postID: string;
429423
readonly content: string;
430424
readonly post?: Post;
431425
constructor(init: ModelInit<Comment>);
@@ -488,7 +482,6 @@ export declare class Project2 {
488482
export declare class Team2 {
489483
readonly id: string;
490484
readonly name: string;
491-
readonly projectID?: string;
492485
readonly project?: Project2;
493486
constructor(init: ModelInit<Team2>);
494487
static copyOf(source: Team2, mutator: (draft: MutableModel<Team2>) => MutableModel<Team2> | void): Team2;
@@ -504,7 +497,6 @@ export declare class Post {
504497

505498
export declare class Comment {
506499
readonly id: string;
507-
readonly postID: string;
508500
readonly content: string;
509501
readonly post?: Post;
510502
constructor(init: ModelInit<Comment>);
@@ -567,7 +559,6 @@ export declare class Project2 {
567559
export declare class Team2 {
568560
readonly id: string;
569561
readonly name: string;
570-
readonly projectID?: string;
571562
readonly project?: Project2;
572563
constructor(init: ModelInit<Team2>);
573564
static copyOf(source: Team2, mutator: (draft: MutableModel<Team2>) => MutableModel<Team2> | void): Team2;
@@ -583,7 +574,6 @@ export declare class Post {
583574

584575
export declare class Comment {
585576
readonly id: string;
586-
readonly postID: string;
587577
readonly content: string;
588578
readonly post?: Post;
589579
constructor(init: ModelInit<Comment>);
@@ -646,7 +636,6 @@ export declare class Project2 {
646636
export declare class Team2 {
647637
readonly id: string;
648638
readonly name: string;
649-
readonly projectID?: string;
650639
readonly project?: Project2;
651640
constructor(init: ModelInit<Team2>);
652641
static copyOf(source: Team2, mutator: (draft: MutableModel<Team2>) => MutableModel<Team2> | void): Team2;
@@ -662,7 +651,6 @@ export declare class Post {
662651

663652
export declare class Comment {
664653
readonly id: string;
665-
readonly postID: string;
666654
readonly content: string;
667655
readonly post?: Post;
668656
constructor(init: ModelInit<Comment>);
@@ -1164,8 +1152,6 @@ export declare class Tag {
11641152

11651153
export declare class PostTags {
11661154
readonly id: string;
1167-
readonly postID: string;
1168-
readonly tagID: string;
11691155
readonly post: Post;
11701156
readonly tag: Tag;
11711157
constructor(init: ModelInit<PostTags>);
@@ -1215,8 +1201,6 @@ export declare class Tag {
12151201

12161202
export declare class PostTags {
12171203
readonly id: string;
1218-
readonly postID: string;
1219-
readonly tagID: string;
12201204
readonly post: Post;
12211205
readonly tag: Tag;
12221206
constructor(init: ModelInit<PostTags>);

packages/appsync-modelgen-plugin/src/visitors/appsync-dart-visitor.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,8 @@ export class AppSyncModelDartVisitor<
5454

5555
generate(): string {
5656
// TODO: Remove us, leaving in to be explicit on why this flag is here.
57-
const shouldRevertBreakingKeyChange = true;
5857
const shouldUseModelNameFieldInHasManyAndBelongsTo = true;
59-
this.processDirectives(shouldRevertBreakingKeyChange, shouldUseModelNameFieldInHasManyAndBelongsTo);
58+
this.processDirectives(shouldUseModelNameFieldInHasManyAndBelongsTo);
6059
this.validateReservedKeywords();
6160
if (this._parsedConfig.generate === CodeGenGenerateEnum.loader) {
6261
return this.generateClassLoader();

packages/appsync-modelgen-plugin/src/visitors/appsync-java-visitor.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@ export class AppSyncModelJavaVisitor<
2727

2828
generate(): string {
2929
// TODO: Remove us, leaving in to be explicit on why this flag is here.
30-
const shouldRevertBreakingKeyChange = true;
3130
const shouldUseModelNameFieldInHasManyAndBelongsTo = false;
32-
this.processDirectives(shouldRevertBreakingKeyChange, shouldUseModelNameFieldInHasManyAndBelongsTo);
31+
this.processDirectives(shouldUseModelNameFieldInHasManyAndBelongsTo);
3332
if (this._parsedConfig.generate === 'loader') {
3433
return this.generateClassLoader();
3534
}

packages/appsync-modelgen-plugin/src/visitors/appsync-javascript-visitor.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,8 @@ export class AppSyncModelJavascriptVisitor<
4646

4747
generate(): string {
4848
// TODO: Remove us, leaving in to be explicit on why this flag is here.
49-
const shouldRevertBreakingKeyChange = false;
5049
const shouldUseModelNameFieldInHasManyAndBelongsTo = false;
51-
this.processDirectives(shouldRevertBreakingKeyChange, shouldUseModelNameFieldInHasManyAndBelongsTo);
50+
this.processDirectives(shouldUseModelNameFieldInHasManyAndBelongsTo);
5251
if (this._parsedConfig.isDeclaration) {
5352
const imports = this.generateImports();
5453
const enumDeclarations = Object.values(this.enumMap)

packages/appsync-modelgen-plugin/src/visitors/appsync-json-metadata-visitor.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,8 @@ export class AppSyncJSONVisitor<
110110
}
111111
generate(): string {
112112
// TODO: Remove us, leaving in to be explicit on why this flag is here.
113-
const shouldRevertBreakingKeyChange = false;
114113
const shouldUseModelNameFieldInHasManyAndBelongsTo = false;
115-
this.processDirectives(shouldRevertBreakingKeyChange, shouldUseModelNameFieldInHasManyAndBelongsTo);
114+
this.processDirectives(shouldUseModelNameFieldInHasManyAndBelongsTo);
116115
if (this._parsedConfig.metadataTarget === 'typescript') {
117116
return this.generateTypeScriptMetadata();
118117
} else if (this._parsedConfig.metadataTarget === 'javascript') {

packages/appsync-modelgen-plugin/src/visitors/appsync-swift-visitor.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,8 @@ export class AppSyncSwiftVisitor<
5858

5959
generate(): string {
6060
// TODO: Remove us, leaving in to be explicit on why this flag is here.
61-
const shouldRevertBreakingKeyChange = true;
6261
const shouldUseModelNameFieldInHasManyAndBelongsTo = true;
63-
this.processDirectives(shouldRevertBreakingKeyChange, shouldUseModelNameFieldInHasManyAndBelongsTo);
62+
this.processDirectives(shouldUseModelNameFieldInHasManyAndBelongsTo);
6463

6564
const code = [`// swiftlint:disable all`];
6665
if (this._parsedConfig.generate === CodeGenGenerateEnum.metadata) {

packages/appsync-modelgen-plugin/src/visitors/appsync-typescript-visitor.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ export class AppSyncModelTypeScriptVisitor<
3535

3636
generate(): string {
3737
// TODO: Remove us, leaving in to be explicit on why this flag is here.
38-
const shouldRevertBreakingKeyChange = false;
3938
const shouldUseModelNameFieldInHasManyAndBelongsTo = false;
40-
this.processDirectives(shouldRevertBreakingKeyChange, shouldUseModelNameFieldInHasManyAndBelongsTo);
39+
this.processDirectives(shouldUseModelNameFieldInHasManyAndBelongsTo);
4140
const imports = this.generateImports();
4241
const enumDeclarations = Object.values(this.enumMap)
4342
.map(enumObj => this.generateEnumDeclarations(enumObj))

packages/appsync-modelgen-plugin/src/visitors/appsync-visitor.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -296,22 +296,20 @@ export class AppSyncModelVisitor<
296296
}
297297
processDirectives(
298298
// TODO: Remove us when we have a fix to roll-forward.
299-
shouldRevertBreakingKeyChange: boolean,
300299
shouldUseModelNameFieldInHasManyAndBelongsTo: boolean
301300
) {
302301
if (this.config.usePipelinedTransformer || this.config.transformerVersion === 2) {
303302
this.processV2KeyDirectives();
304-
this.processConnectionDirectivesV2(shouldRevertBreakingKeyChange, shouldUseModelNameFieldInHasManyAndBelongsTo);
303+
this.processConnectionDirectivesV2(shouldUseModelNameFieldInHasManyAndBelongsTo);
305304
} else {
306305
this.processConnectionDirective();
307306
}
308307
this.processAuthDirectives();
309308
}
310309
generate(): string {
311310
// TODO: Remove me, leaving in to be explicit on why this flag is here.
312-
const shouldRevertBreakingKeyChange = false;
313311
const shouldUseModelNameFieldInHasManyAndBelongsTo = false;
314-
this.processDirectives(shouldRevertBreakingKeyChange, shouldUseModelNameFieldInHasManyAndBelongsTo);
312+
this.processDirectives(shouldUseModelNameFieldInHasManyAndBelongsTo);
315313
return '';
316314
}
317315

@@ -684,7 +682,6 @@ export class AppSyncModelVisitor<
684682

685683
protected processConnectionDirectivesV2(
686684
// TODO: Remove us when we have a fix to roll-forward.
687-
shouldRevertBreakingKeyChange: boolean,
688685
shouldUseModelNameFieldInHasManyAndBelongsTo: boolean
689686
): void {
690687
this.processManyToManyDirectives();
@@ -704,7 +701,7 @@ export class AppSyncModelVisitor<
704701
isList: false,
705702
isNullable: field.isNullable,
706703
});
707-
} else if (shouldRevertBreakingKeyChange && connectionInfo.targetName !== 'id') {
704+
} else if (connectionInfo.targetName !== 'id') {
708705
// TODO: Remove this branch when we can roll forward.
709706
// Need to remove the field that is targetName, only apply if shouldRevertBreakingKeyChange is set
710707
removeFieldFromModel(model, connectionInfo.targetName);

0 commit comments

Comments
 (0)