File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,10 +18,14 @@ export default function VitePluginGraphQLCodegen(): Plugin {
1818 viteConfig = resolvedConfig ;
1919 } ,
2020 async buildStart ( ) {
21- await generate ( codegenContext ) ;
21+ try {
22+ await generate ( codegenContext ) ;
23+ } catch ( error ) {
24+ console . log ( 'Something went wrong.' ) ;
25+ }
2226 } ,
2327 configureServer ( server ) {
24- const listener = ( path = '' ) => {
28+ const listener = async ( path = '' ) => {
2529 const { generates, documents } = codegenContext . getConfig ( ) ;
2630
2731 // Check if file is a generated file
@@ -30,11 +34,15 @@ export default function VitePluginGraphQLCodegen(): Plugin {
3034 if ( isGenerated ) return ;
3135
3236 // Check if file is an operation document
33- const [ , fileName = '' ] = path . split ( `${ viteConfig . root } /` ) ;
34- const isDocument = minimatch ( fileName , documents ) ;
37+ const [ , relativePath = '' ] = path . split ( `${ viteConfig . root } /` ) ;
38+ const isDocument = minimatch ( relativePath , documents ) ;
3539 if ( ! isDocument ) return ;
3640
37- generate ( codegenContext ) ;
41+ try {
42+ await generate ( codegenContext ) ;
43+ } catch ( error ) {
44+ console . log ( 'Something went wrong. Please save the file again.' ) ;
45+ }
3846 } ;
3947
4048 server . watcher . on ( 'add' , listener ) ;
You can’t perform that action at this time.
0 commit comments