Skip to content

Commit 476aef4

Browse files
author
Dane Pilcher
committed
test: gql compile
1 parent 4bbb565 commit 476aef4

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

packages/amplify-codegen-e2e-tests/src/__tests__/build-app-android.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
addCodegen,
1111
AmplifyFrontend,
1212
amplifyPush,
13+
apiGqlCompile,
1314
} from '@aws-amplify/amplify-codegen-e2e-core';
1415
const { schemas } = require('@aws-amplify/graphql-schema-test-library');
1516
import { existsSync, writeFileSync, readdirSync, rmSync, readFileSync } from 'fs';
@@ -55,6 +56,7 @@ describe('build app - Android', () => {
5556
// @ts-ignore
5657
const schemaText = `input AMPLIFY { globalAuthRule: AuthRule = { allow: public } }\n${schema.sdl}`;
5758
updateApiSchemaWithText(projectRoot, apiName, schemaText);
59+
apiGqlCompile(projectRoot);
5860
await generateModels(projectRoot);
5961
await generateStatementsAndTypes(projectRoot);
6062
await androidBuild(projectRoot, { ...config });
@@ -73,6 +75,7 @@ describe('build app - Android', () => {
7375
it('fails build with syntax error in models', async () => {
7476
// @ts-ignore
7577
updateApiSchemaWithText(projectRoot, apiName, Object.values(schemas)[0].sdl);
78+
apiGqlCompile(projectRoot);
7679
await generateModels(projectRoot);
7780
await writeFileSync(path.join(projectRoot, modelDir, 'AmplifyModelProvider.java'), 'foo\nbar');
7881
await expect(androidBuild(projectRoot, { ...config })).rejects.toThrowError();
@@ -81,6 +84,7 @@ describe('build app - Android', () => {
8184
it('fails build with syntax error in statements', async () => {
8285
// @ts-ignore
8386
updateApiSchemaWithText(projectRoot, apiName, Object.values(schemas)[0].sdl);
87+
apiGqlCompile(projectRoot);
8488
await generateModels(projectRoot);
8589
writeFileSync(path.join(projectRoot, path.join(statementsDir, 'mutations.graphql')), 'foo\nbar'),
8690
expect(() => parse(readFileSync(path.join(projectRoot, path.join(statementsDir, 'mutations.graphql')), 'utf8'))).toThrowError();

packages/amplify-codegen-e2e-tests/src/__tests__/build-app-swift.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
addCodegen,
99
AmplifyFrontend,
1010
amplifyPush,
11+
apiGqlCompile,
1112
} from '@aws-amplify/amplify-codegen-e2e-core';
1213
const { schemas } = require('@aws-amplify/graphql-schema-test-library');
1314
import { writeFileSync, readdirSync, readFileSync } from 'fs';
@@ -33,6 +34,7 @@ describe('build app - Swift', () => {
3334
apiName = readdirSync(path.join(projectRoot, 'amplify', 'backend', 'api'))[0];
3435
const schemaText = `input AMPLIFY { globalAuthRule: AuthRule = { allow: public } }\n${schemas[0].sdl}`;
3536
updateApiSchemaWithText(projectRoot, apiName, schemaText);
37+
apiGqlCompile(projectRoot);
3638
await amplifyPush(projectRoot);
3739
await addCodegen(projectRoot, {
3840
frontendType: AmplifyFrontend.ios,
@@ -54,6 +56,7 @@ describe('build app - Swift', () => {
5456
const schemaText = `input AMPLIFY { globalAuthRule: AuthRule = { allow: public } }\n${schema.sdl}`;
5557
console.log(schemaText); // log so that ci does not timeout
5658
updateApiSchemaWithText(projectRoot, 'amplifyDatasource', schemaText);
59+
apiGqlCompile(projectRoot);
5760
await generateModels(projectRoot, outputDir);
5861
await generateStatementsAndTypes(projectRoot);
5962
// swift uses raw graphql syntax

packages/amplify-codegen-e2e-tests/src/__tests__/build-app-ts.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
addCodegen,
1111
AmplifyFrontend,
1212
amplifyPush,
13+
apiGqlCompile,
1314
} from '@aws-amplify/amplify-codegen-e2e-core';
1415
const { schemas } = require('@aws-amplify/graphql-schema-test-library');
1516
import { existsSync, writeFileSync, readdirSync, rmSync } from 'fs';
@@ -46,6 +47,7 @@ describe('build app - JS', () => {
4647
// @ts-ignore
4748
const schemaText = `input AMPLIFY { globalAuthRule: AuthRule = { allow: public } }\n${schema.sdl}`;
4849
updateApiSchemaWithText(projectRoot, apiName, schemaText);
50+
apiGqlCompile(projectRoot);
4951
await generateModels(projectRoot);
5052
await generateStatementsAndTypes(projectRoot);
5153
await craBuild(projectRoot, { ...config });
@@ -55,6 +57,7 @@ describe('build app - JS', () => {
5557
it('fails build with syntax error in models', async () => {
5658
const schemaText = `input AMPLIFY { globalAuthRule: AuthRule = { allow: public } }\n${(Object.values(schemas)[0] as any).sdl}`;
5759
updateApiSchemaWithText(projectRoot, apiName, schemaText);
60+
apiGqlCompile(projectRoot);
5861
await generateStatementsAndTypes(projectRoot);
5962
await writeFileSync(path.join(projectRoot, 'src', 'models', 'index.d.ts'), 'foo\nbar');
6063
await expect(craBuild(projectRoot, { ...config })).rejects.toThrowError();
@@ -63,6 +66,7 @@ describe('build app - JS', () => {
6366
it('fails build with syntax error in statements', async () => {
6467
const schemaText = `input AMPLIFY { globalAuthRule: AuthRule = { allow: public } }\n${(Object.values(schemas)[0] as any).sdl}`;
6568
updateApiSchemaWithText(projectRoot, apiName, schemaText);
69+
apiGqlCompile(projectRoot);
6670
await generateModels(projectRoot);
6771
await generateStatementsAndTypes(projectRoot);
6872
await writeFileSync(path.join(projectRoot, 'src', 'graphql', 'queries.ts'), 'foo\nbar');
@@ -72,6 +76,7 @@ describe('build app - JS', () => {
7276
it('fails build with syntax error in types', async () => {
7377
const schemaText = `input AMPLIFY { globalAuthRule: AuthRule = { allow: public } }\n${(Object.values(schemas)[0] as any).sdl}`;
7478
updateApiSchemaWithText(projectRoot, apiName, schemaText);
79+
apiGqlCompile(projectRoot);
7580
await generateModels(projectRoot);
7681
await generateStatementsAndTypes(projectRoot);
7782
await writeFileSync(path.join(projectRoot, 'src', 'API.ts'), 'foo\nbar');

0 commit comments

Comments
 (0)