@@ -67,8 +67,13 @@ async function generateStatements(context, forceDownloadSchema, maxDepth, withou
6767 typenameIntrospection :
6868 cfg . amplifyExtension . typenameIntrospection === undefined ? true : ! ! cfg . amplifyExtension . typenameIntrospection ,
6969 } ) ;
70- await writeGeneratedDocuments ( language , generatedOps , opsGenDirectory ) ;
71- opsGenSpinner . succeed ( constants . INFO_MESSAGE_OPS_GEN_SUCCESS + path . relative ( path . resolve ( '.' ) , opsGenDirectory ) ) ;
70+ if ( ! generatedOps ) {
71+ context . print . warning ( 'No GraphQL statements are generated. Check if the introspection schema has GraphQL operations defined.' ) ;
72+ }
73+ else {
74+ await writeGeneratedDocuments ( language , generatedOps , opsGenDirectory ) ;
75+ opsGenSpinner . succeed ( constants . INFO_MESSAGE_OPS_GEN_SUCCESS + path . relative ( path . resolve ( '.' ) , opsGenDirectory ) ) ;
76+ }
7277 } finally {
7378 opsGenSpinner . stop ( ) ;
7479 }
@@ -77,13 +82,10 @@ async function generateStatements(context, forceDownloadSchema, maxDepth, withou
7782
7883async function writeGeneratedDocuments ( language , generatedStatements , outputPath ) {
7984 const fileExtension = FILE_EXTENSION_MAP [ language ] ;
80- if ( ! generatedStatements ) {
81- throw new Error ( 'No GraphQL statements are generated' ) ;
82- }
8385
8486 [ 'queries' , 'mutations' , 'subscriptions' ] . forEach ( op => {
8587 const ops = generatedStatements [ op ] ;
86- if ( ops . size ) {
88+ if ( ops && ops . size ) {
8789 const formattedStatements = ( new GraphQLStatementsFormatter ( language ) ) . format ( ops ) ;
8890 const outputFile = path . resolve ( path . join ( outputPath , `${ op } .${ fileExtension } ` ) ) ;
8991 fs . writeFileSync ( outputFile , formattedStatements ) ;
0 commit comments