Skip to content

Commit c42ad16

Browse files
authored
Merge pull request #308 from aws-amplify/master
release add dependencies version upgrade and join table name fix
2 parents 3395490 + 5f213d5 commit c42ad16

File tree

8 files changed

+78
-33
lines changed

8 files changed

+78
-33
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@
9595
"ts-jest": "^25.5.0",
9696
"ts-node": "^8.10.1",
9797
"typescript": "^3.8.3",
98-
"amplify-cli-core": "^1.17.2",
99-
"graphql-transformer-core": "^6.26.2",
100-
"amplify-headless-interface": "^1.6.0"
98+
"amplify-cli-core": "^2.3.0",
99+
"graphql-transformer-core": "^7.2.1",
100+
"amplify-headless-interface": "^1.13.1"
101101
},
102102
"config": {
103103
"commitizen": {

packages/amplify-codegen-e2e-core/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
"uuid": "7.0.1"
3636
},
3737
"peerDependencies": {
38-
"amplify-cli-core": "^1.18.1",
39-
"amplify-headless-interface": "^1.5.3",
40-
"graphql-transformer-core": "^6.27.0"
38+
"amplify-cli-core": "^2.3.0",
39+
"amplify-headless-interface": "^1.13.1",
40+
"graphql-transformer-core": "^7.2.1"
4141
}
4242
}

packages/amplify-codegen-e2e-core/src/categories/api.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export function addApiWithoutSchema(cwd: string, opts: Partial<AddApiOptions & {
3636
const options = _.assign(defaultOptions, opts);
3737
return new Promise<void>((resolve, reject) => {
3838
spawn(getCLIPath(options.testingWithLatestCodebase), ['add', 'api'], { cwd, stripColors: true })
39-
.wait('Please select from one of the below mentioned services:')
39+
.wait('Select from one of the below mentioned services:')
4040
.sendCarriageReturn()
4141
.wait(/.*Here is the GraphQL API that we will create. Select a setting to edit or continue.*/)
4242
.sendKeyUp(3)
@@ -66,7 +66,7 @@ export function addApiWithBlankSchema(cwd: string, opts: Partial<AddApiOptions &
6666
const options = _.assign(defaultOptions, opts);
6767
return new Promise<void>((resolve, reject) => {
6868
spawn(getCLIPath(options.testingWithLatestCodebase), ['add', 'api'], { cwd, stripColors: true })
69-
.wait('Please select from one of the below mentioned services:')
69+
.wait('Select from one of the below mentioned services:')
7070
.sendCarriageReturn()
7171
.wait(/.*Here is the GraphQL API that we will create. Select a setting to edit or continue.*/)
7272
.sendKeyUp(3)
@@ -97,7 +97,7 @@ export function addApiWithBlankSchema(cwd: string, opts: Partial<AddApiOptions &
9797
export function addApiWithBlankSchemaAndConflictDetection(cwd: string) {
9898
return new Promise<void>((resolve, reject) => {
9999
spawn(getCLIPath(defaultOptions.testingWithLatestCodebase), ['add', 'api'], { cwd, stripColors: true })
100-
.wait('Please select from one of the below mentioned services:')
100+
.wait('Select from one of the below mentioned services:')
101101
.sendCarriageReturn()
102102
.wait(/.*Here is the GraphQL API that we will create. Select a setting to edit or continue.*/)
103103
.sendKeyUp()
@@ -138,7 +138,7 @@ export function updateApiSchema(cwd: string, projectName: string, schemaName: st
138138
export function updateApiWithMultiAuth(cwd: string, settings: any) {
139139
return new Promise<void>((resolve, reject) => {
140140
spawn(getCLIPath(settings.testingWithLatestCodebase), ['update', 'api'], { cwd, stripColors: true })
141-
.wait('Please select from one of the below mentioned services:')
141+
.wait('Select from one of the below mentioned services:')
142142
.sendCarriageReturn()
143143
.wait(/.*Select a setting to edit.*/)
144144
.sendCarriageReturn()
@@ -185,7 +185,7 @@ export function updateApiWithMultiAuth(cwd: string, settings: any) {
185185
export function apiEnableDataStore(cwd: string, settings: any) {
186186
return new Promise<void>((resolve, reject) => {
187187
spawn(getCLIPath(settings.testingWithLatestCodebase), ['update', 'api'], { cwd, stripColors: true })
188-
.wait('Please select from one of the below mentioned services:')
188+
.wait('Select from one of the below mentioned services:')
189189
.sendCarriageReturn()
190190
.wait(/.*Select a setting to edit.*/)
191191
.sendKeyDown()
@@ -209,7 +209,7 @@ export function apiEnableDataStore(cwd: string, settings: any) {
209209
export function apiDisableDataStore(cwd: string, settings: any) {
210210
return new Promise<void>((resolve, reject) => {
211211
spawn(getCLIPath(settings.testingWithLatestCodebase), ['update', 'api'], { cwd, stripColors: true })
212-
.wait('Please select from one of the below mentioned services:')
212+
.wait('Select from one of the below mentioned services:')
213213
.sendCarriageReturn()
214214
.wait(/.*Select a setting to edit.*/)
215215
.sendKeyDown(2) // Disable conflict detection
@@ -229,7 +229,7 @@ export function apiDisableDataStore(cwd: string, settings: any) {
229229
export function updateAPIWithResolutionStrategyWithoutModels(cwd: string, settings: any) {
230230
return new Promise<void>((resolve, reject) => {
231231
spawn(getCLIPath(settings.testingWithLatestCodebase), ['update', 'api'], { cwd, stripColors: true })
232-
.wait('Please select from one of the below mentioned services:')
232+
.wait('Select from one of the below mentioned services:')
233233
.sendCarriageReturn()
234234
.wait(/.*Select a setting to edit.*/)
235235
.sendKeyDown()
@@ -252,7 +252,7 @@ export function updateAPIWithResolutionStrategyWithoutModels(cwd: string, settin
252252
export function updateAPIWithResolutionStrategyWithModels(cwd: string, settings: any) {
253253
return new Promise<void>((resolve, reject) => {
254254
spawn(getCLIPath(settings.testingWithLatestCodebase), ['update', 'api'], { cwd, stripColors: true })
255-
.wait('Please select from one of the below mentioned services:')
255+
.wait('Select from one of the below mentioned services:')
256256
.sendCarriageReturn()
257257
.wait(/.*Select a setting to edit.*/)
258258
.sendKeyDown()
@@ -277,7 +277,7 @@ export function updateAPIWithResolutionStrategyWithModels(cwd: string, settings:
277277
export function updateAPIWithResolutionStrategy(cwd: string, settings: any) {
278278
return new Promise<void>((resolve, reject) => {
279279
spawn(getCLIPath(settings.testingWithLatestCodebase), ['update', 'api'], { cwd, stripColors: true })
280-
.wait('Please select from one of the below mentioned services:')
280+
.wait('Select from one of the below mentioned services:')
281281
.sendCarriageReturn()
282282
.wait('Select from the options below')
283283
.sendCarriageReturn()
@@ -317,7 +317,7 @@ export function addRestApi(cwd: string, settings: any) {
317317
} else {
318318
const isFirstRestApi = settings.isFirstRestApi ?? true;
319319
let chain = spawn(getCLIPath(), ['add', 'api'], { cwd, stripColors: true })
320-
.wait('Please select from one of the below mentioned services')
320+
.wait('Select from one of the below mentioned services')
321321
.send(KEY_DOWN_ARROW)
322322
.sendCarriageReturn(); // REST
323323

@@ -439,7 +439,7 @@ export function addApi(projectDir: string, settings?: any) {
439439
let authTypesToSelectFrom = allAuthTypes.slice();
440440
return new Promise<void>((resolve, reject) => {
441441
let chain = spawn(getCLIPath(defaultOptions.testingWithLatestCodebase), ['add', 'api'], { cwd: projectDir, stripColors: true })
442-
.wait('Please select from one of the below mentioned services:')
442+
.wait('Select from one of the below mentioned services:')
443443
.sendCarriageReturn();
444444

445445
if (settings && Object.keys(settings).length > 0) {
@@ -557,7 +557,7 @@ function setupOIDC(chain: any, settings?: any) {
557557
export function addApiWithCognitoUserPoolAuthTypeWhenAuthExists(projectDir: string) {
558558
return new Promise<void>((resolve, reject) => {
559559
spawn(getCLIPath(defaultOptions.testingWithLatestCodebase), ['add', 'api'], { cwd: projectDir, stripColors: true })
560-
.wait('Please select from one of the below mentioned services:')
560+
.wait('Select from one of the below mentioned services:')
561561
.sendCarriageReturn()
562562
.wait(/.*Here is the GraphQL API that we will create. Select a setting to edit or continue.*/)
563563
.sendKeyUp(2)
@@ -587,7 +587,7 @@ export function addApiWithCognitoUserPoolAuthTypeWhenAuthExists(projectDir: stri
587587
export function addRestContainerApi(projectDir: string) {
588588
return new Promise<void>((resolve, reject) => {
589589
spawn(getCLIPath(), ['add', 'api'], { cwd: projectDir, stripColors: true })
590-
.wait('Please select from one of the below mentioned services:')
590+
.wait('Select from one of the below mentioned services:')
591591
.sendKeyDown()
592592
.sendCarriageReturn()
593593
.wait('Which service would you like to use')
@@ -628,7 +628,7 @@ export function rebuildApi(projDir: string, apiName: string) {
628628
export function addRestContainerApiForCustomPolicies(projectDir: string, settings: { name: string }) {
629629
return new Promise<void>((resolve, reject) => {
630630
spawn(getCLIPath(), ['add', 'api'], { cwd: projectDir, stripColors: true })
631-
.wait('Please select from one of the below mentioned services:')
631+
.wait('Select from one of the below mentioned services:')
632632
.sendKeyDown()
633633
.sendCarriageReturn()
634634
.wait('Which service would you like to use')

packages/amplify-codegen-e2e-tests/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
"ts-node": "^8.9.0"
4343
},
4444
"peerDependencies": {
45-
"amplify-cli-core": "^1.18.1",
46-
"graphql-transformer-core": "^6.27.0"
45+
"amplify-cli-core": "^2.3.0",
46+
"graphql-transformer-core": "^7.2.1"
4747
},
4848
"jest": {
4949
"verbose": false,

packages/amplify-codegen/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
"slash": "^3.0.0"
4141
},
4242
"peerDependencies": {
43-
"amplify-cli-core": "^1.17.2",
44-
"graphql-transformer-core": "^6.26.2"
43+
"amplify-cli-core": "^2.3.0",
44+
"graphql-transformer-core": "^7.2.1"
4545
},
4646
"jest": {
4747
"collectCoverage": true,

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

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,9 @@ describe('AppSyncModelVisitor', () => {
339339
);
340340
visit(ast, { leave: visitor });
341341
visitor.generate();
342-
const projectTeamIdField = visitor.models.Project.fields.find(field => { return field.name === 'projectTeamId'; });
342+
const projectTeamIdField = visitor.models.Project.fields.find(field => {
343+
return field.name === 'projectTeamId';
344+
});
343345
expect(projectTeamIdField).toBeDefined();
344346
expect(projectTeamIdField.isNullable).toBeTruthy();
345347
});
@@ -664,6 +666,7 @@ describe('AppSyncModelVisitor', () => {
664666
let simpleManyToManySchema;
665667
let simpleManyModelMap;
666668
let transformedSimpleManyModelMap;
669+
let manyToManyModelNameSchema;
667670

668671
beforeEach(() => {
669672
simpleManyToManySchema = /* GraphQL */ `
@@ -678,6 +681,16 @@ describe('AppSyncModelVisitor', () => {
678681
}
679682
`;
680683

684+
manyToManyModelNameSchema = /* GraphQL */ `
685+
type ModelA @model {
686+
models: [ModelB] @manyToMany(relationName: "Models")
687+
}
688+
689+
type ModelB @model {
690+
models: [ModelA] @manyToMany(relationName: "Models")
691+
}
692+
`;
693+
681694
simpleManyModelMap = {
682695
Human: {
683696
name: 'Human',
@@ -832,5 +845,36 @@ describe('AppSyncModelVisitor', () => {
832845
expect(visitor.models.Animal.fields[2].directives[0].arguments.fields[0]).toEqual('id');
833846
expect(visitor.models.Animal.fields[2].directives[0].arguments.indexName).toEqual('byAnimal');
834847
});
848+
849+
it('Should correctly field names for many to many join table', () => {
850+
const visitor = createAndGeneratePipelinedTransformerVisitor(manyToManyModelNameSchema);
851+
852+
expect(visitor.models.ModelA.fields.length).toEqual(4);
853+
expect(visitor.models.ModelA.fields[1].directives[0].name).toEqual('hasMany');
854+
expect(visitor.models.ModelA.fields[1].directives[0].arguments.fields.length).toEqual(1);
855+
expect(visitor.models.ModelA.fields[1].directives[0].arguments.fields[0]).toEqual('id');
856+
expect(visitor.models.ModelA.fields[1].directives[0].arguments.indexName).toEqual('byModelA');
857+
858+
expect(visitor.models.Models).toBeDefined();
859+
expect(visitor.models.Models.fields.length).toEqual(5);
860+
861+
const modelA = visitor.models.Models.fields.find(f => f.name === 'modelA');
862+
expect(modelA).toBeDefined();
863+
expect(modelA.directives[0].name).toEqual('belongsTo');
864+
expect(modelA.directives[0].arguments.fields.length).toEqual(1);
865+
expect(modelA.directives[0].arguments.fields[0]).toEqual('modelAID');
866+
867+
const modelB = visitor.models.Models.fields.find(f => f.name === 'modelB');
868+
expect(modelB).toBeDefined();
869+
expect(modelB.directives[0].name).toEqual('belongsTo');
870+
expect(modelB.directives[0].arguments.fields.length).toEqual(1);
871+
expect(modelB.directives[0].arguments.fields[0]).toEqual('modelBID');
872+
873+
expect(visitor.models.ModelB.fields.length).toEqual(4);
874+
expect(visitor.models.ModelB.fields[1].directives[0].name).toEqual('hasMany');
875+
expect(visitor.models.ModelB.fields[1].directives[0].arguments.fields.length).toEqual(1);
876+
expect(visitor.models.ModelB.fields[1].directives[0].arguments.fields[0]).toEqual('id');
877+
expect(visitor.models.ModelB.fields[1].directives[0].arguments.indexName).toEqual('byModelB');
878+
});
835879
});
836880
});

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
ParsedConfig,
77
RawConfig,
88
} from '@graphql-codegen/visitor-plugin-common';
9-
import { constantCase, pascalCase } from 'change-case';
9+
import { camelCase, constantCase, pascalCase } from 'change-case';
1010
import { plural } from 'pluralize';
1111
import crypto from 'crypto';
1212
import {
@@ -553,8 +553,8 @@ export class AppSyncModelVisitor<
553553
secondField: CodeGenField,
554554
relationName: string,
555555
) {
556-
const firstModelKeyFieldName = `${firstModel.name.toLowerCase()}ID`;
557-
const secondModelKeyFieldName = `${secondModel.name.toLowerCase()}ID`;
556+
const firstModelKeyFieldName = `${camelCase(firstModel.name)}ID`;
557+
const secondModelKeyFieldName = `${camelCase(secondModel.name)}ID`;
558558
let intermediateModel: CodeGenModel = {
559559
name: relationName,
560560
type: 'model',
@@ -585,14 +585,14 @@ export class AppSyncModelVisitor<
585585
type: firstModel.name,
586586
isNullable: false,
587587
isList: false,
588-
name: firstModel.name.toLowerCase(),
588+
name: camelCase(firstModel.name),
589589
directives: [{ name: 'belongsTo', arguments: { fields: [firstModelKeyFieldName] } }],
590590
},
591591
{
592592
type: secondModel.name,
593593
isNullable: false,
594594
isList: false,
595-
name: secondModel.name.toLowerCase(),
595+
name: camelCase(secondModel.name),
596596
directives: [{ name: 'belongsTo', arguments: { fields: [secondModelKeyFieldName] } }],
597597
},
598598
],
@@ -708,7 +708,9 @@ export class AppSyncModelVisitor<
708708
const connectionInfo = field.connectionInfo;
709709
if (modelTypes.includes(fieldType) && connectionInfo === undefined) {
710710
printWarning(
711-
`Model ${model.name} has field ${field.name} of type ${field.type} but its not connected. Add the appropriate ${field.isList ? '@hasMany' : '@hasOne'}/@belongsTo directive if you want to connect them.`,
711+
`Model ${model.name} has field ${field.name} of type ${field.type} but its not connected. Add the appropriate ${
712+
field.isList ? '@hasMany' : '@hasOne'
713+
}/@belongsTo directive if you want to connect them.`,
712714
);
713715
return false;
714716
}

packages/graphql-types-generator/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@
7474
],
7575
"testMatch": [
7676
"**/test/**/*.(js|ts)",
77-
"**/test/*.(js|ts)",
78-
"**/__tests__/*.(js|ts)"
77+
"**/test/*.(js|ts)"
7978
],
8079
"testPathIgnorePatterns": [
8180
"<rootDir>/node_modules/",

0 commit comments

Comments
 (0)