Skip to content

Commit

Permalink
test: await on gql compile
Browse files Browse the repository at this point in the history
  • Loading branch information
dpilch committed Nov 22, 2023
1 parent 430f2ee commit e454ad5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('build app - Android', () => {
await initProjectWithProfile(projectRoot, { ...config });
await addApiWithDefaultSchemaAndConflictDetection(projectRoot);
apiName = readdirSync(path.join(projectRoot, 'amplify', 'backend', 'api'))[0];
apiGqlCompile(projectRoot);
await apiGqlCompile(projectRoot);
await addCodegen(projectRoot, {
frontendType: AmplifyFrontend.android,
});
Expand All @@ -58,7 +58,7 @@ describe('build app - Android', () => {
// @ts-ignore
const schemaText = `input AMPLIFY { globalAuthRule: AuthRule = { allow: public } }\n${schema.sdl}`;
updateApiSchemaWithText(projectRoot, apiName, schemaText);
apiGqlCompile(projectRoot);
await apiGqlCompile(projectRoot);
await generateModels(projectRoot);
await generateStatementsAndTypes(projectRoot);
await androidBuild(projectRoot, { ...config });
Expand Down Expand Up @@ -92,7 +92,7 @@ describe('build app - Android', () => {
it('fails build with syntax error in models', async () => {
// @ts-ignore
updateApiSchemaWithText(projectRoot, apiName, Object.values(schemas)[0].sdl);
apiGqlCompile(projectRoot);
await apiGqlCompile(projectRoot);
await generateModels(projectRoot);
await writeFileSync(path.join(projectRoot, modelDir, 'AmplifyModelProvider.java'), 'foo\nbar');
await expect(androidBuild(projectRoot, { ...config })).rejects.toThrowError();
Expand All @@ -101,7 +101,7 @@ describe('build app - Android', () => {
it('fails build with syntax error in statements', async () => {
// @ts-ignore
updateApiSchemaWithText(projectRoot, apiName, Object.values(schemas)[0].sdl);
apiGqlCompile(projectRoot);
await apiGqlCompile(projectRoot);
await generateModels(projectRoot);
await generateStatementsAndTypes(projectRoot);
writeFileSync(path.join(projectRoot, statementsDir, 'mutations.graphql'), 'foo\nbar'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('build app - Swift', () => {
await initIosProjectWithProfile(projectRoot, { ...config });
await addApiWithDefaultSchemaAndConflictDetection(projectRoot);
apiName = readdirSync(path.join(projectRoot, 'amplify', 'backend', 'api'))[0];
apiGqlCompile(projectRoot);
await apiGqlCompile(projectRoot);
await addCodegen(projectRoot, {
frontendType: AmplifyFrontend.ios,
});
Expand Down Expand Up @@ -72,7 +72,7 @@ describe('build app - Swift', () => {
const schemaText = `input AMPLIFY { globalAuthRule: AuthRule = { allow: public } }\n${schema.sdl}`;
console.log(schemaText); // log so that ci does not timeout
updateApiSchemaWithText(projectRoot, apiName, schemaText);
apiGqlCompile(projectRoot);
await apiGqlCompile(projectRoot);
await generateModels(projectRoot, outputDir);
await generateStatementsAndTypes(projectRoot);
// swift uses raw graphql syntax
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('build app - JS', () => {
const testFunction = async () => {
const schemaText = `input AMPLIFY { globalAuthRule: AuthRule = { allow: public } }\n${(schema as any).sdl}`;
updateApiSchemaWithText(projectRoot, apiName, schemaText);
apiGqlCompile(projectRoot);
await apiGqlCompile(projectRoot);
await generateModels(projectRoot);
await generateStatementsAndTypes(projectRoot);
await craBuild(projectRoot, { ...config });
Expand All @@ -61,7 +61,7 @@ describe('build app - JS', () => {
it('fails build with syntax error in models', async () => {
const schemaText = `input AMPLIFY { globalAuthRule: AuthRule = { allow: public } }\n${(Object.values(schemas)[0] as any).sdl}`;
updateApiSchemaWithText(projectRoot, apiName, schemaText);
apiGqlCompile(projectRoot);
await apiGqlCompile(projectRoot);
await generateStatementsAndTypes(projectRoot);
await writeFileSync(path.join(projectRoot, 'src', 'models', 'index.d.ts'), 'foo\nbar');
await expect(craBuild(projectRoot, { ...config })).rejects.toThrowError();
Expand All @@ -70,7 +70,7 @@ describe('build app - JS', () => {
it('fails build with syntax error in statements', async () => {
const schemaText = `input AMPLIFY { globalAuthRule: AuthRule = { allow: public } }\n${(Object.values(schemas)[0] as any).sdl}`;
updateApiSchemaWithText(projectRoot, apiName, schemaText);
apiGqlCompile(projectRoot);
await apiGqlCompile(projectRoot);
await generateModels(projectRoot);
await generateStatementsAndTypes(projectRoot);
await writeFileSync(path.join(projectRoot, 'src', 'graphql', 'queries.ts'), 'foo\nbar');
Expand All @@ -80,7 +80,7 @@ describe('build app - JS', () => {
it('fails build with syntax error in types', async () => {
const schemaText = `input AMPLIFY { globalAuthRule: AuthRule = { allow: public } }\n${(Object.values(schemas)[0] as any).sdl}`;
updateApiSchemaWithText(projectRoot, apiName, schemaText);
apiGqlCompile(projectRoot);
await apiGqlCompile(projectRoot);
await generateModels(projectRoot);
await generateStatementsAndTypes(projectRoot);
await writeFileSync(path.join(projectRoot, 'src', 'API.ts'), 'foo\nbar');
Expand Down

0 comments on commit e454ad5

Please sign in to comment.