@@ -23,31 +23,36 @@ export function createGraphqlProcessor() {
2323      // WORKAROUND: This restores the original filename for the block representing original code. 
2424      //             This allows to be compatible with other eslint plugins relying on filesystem 
2525      //             This is temporary, waiting for https://github.com/eslint/eslint/issues/11989 
26-       const  originalFileBlock  =  {  text,  filename : `/../../${ basename ( filename ) }   } 
26+       const  originalFileBlock  =  {  text,  filename : `/../../${ basename ( filename ) }   } ; 
2727
2828      if  ( filename  &&  text  &&  RELEVANT_KEYWORDS . some ( keyword  =>  text . includes ( keyword ) ) )  { 
29-         const  extractedDocuments  =  parseCode ( { 
30-           code : text , 
31-           filePath : filename , 
32-           options : { 
33-             globalGqlIdentifierName : [ 'gql' ,  'graphql' ] , 
34-             skipIndent : true , 
35-           } , 
36-         } ) ; 
29+         try  { 
30+           const  extractedDocuments  =  parseCode ( { 
31+             code : text , 
32+             filePath : filename , 
33+             options : { 
34+               globalGqlIdentifierName : [ 'gql' ,  'graphql' ] , 
35+               skipIndent : true , 
36+             } , 
37+           } ) ; 
3738
38-         if  ( extractedDocuments  &&  extractedDocuments . length  >  0 )  { 
39-           for  ( const  item  of  extractedDocuments )  { 
40-             blocks . push ( { 
41-               filename : `document.graphql` , 
42-               text : item . content , 
43-               lineOffset : item . loc . start . line  -  1 , 
44-               offset : item . start  +  1 , 
45-             } ) ; 
46-           } 
39+            if  ( extractedDocuments  &&  extractedDocuments . length  >  0 )  { 
40+              for  ( const  item  of  extractedDocuments )  { 
41+                blocks . push ( { 
42+                  filename : `document.graphql` , 
43+                  text : item . content , 
44+                  lineOffset : item . loc . start . line  -  1 , 
45+                  offset : item . start  +  1 , 
46+                } ) ; 
47+              } 
4748
48-           blocks . push ( originalFileBlock ) ; 
49+              blocks . push ( originalFileBlock ) ; 
4950
50-           return  blocks ; 
51+             return  blocks ; 
52+           } 
53+         }  catch  ( e )  { 
54+           // eslint-disable-next-line no-console 
55+           console . warn ( `[graphql-eslint/processor]: Unable to process file "${ filename }  ,  e ) ; 
5156        } 
5257      } 
5358
0 commit comments