File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,24 +4,32 @@ let isGraphQLAvailable = false;
44let parseFunction = null ;
55
66// Attempt to load GraphQL parse function
7- if ( typeof process !== 'undefined' && process . versions && process . versions . node ) {
7+ /* istanbul ignore if */
8+ if ( typeof process === 'undefined' || ! process . versions || ! process . versions . node ) {
9+ // Skip initialization in non-Node environments
10+ } else {
811 const nodeVersion = process . versions . node . split ( '.' ) [ 0 ] ;
12+ /* istanbul ignore else */
913 if ( parseInt ( nodeVersion , 10 ) >= 10 ) {
1014 try {
1115 // eslint-disable-next-line global-require
1216 const { parse } = require ( 'graphql' ) ;
1317 parseFunction = parse ;
1418 isGraphQLAvailable = true ;
1519 } catch ( e ) {
20+ /* istanbul ignore next */
1621 // GraphQL loading failed
22+ isGraphQLAvailable = false ;
1723 }
1824 }
1925}
2026
2127export default function isValidGraphQLQuery ( input ) {
2228 assertString ( input ) ;
2329
30+ /* istanbul ignore if */
2431 if ( ! isGraphQLAvailable || ! parseFunction ) {
32+ /* istanbul ignore next */
2533 return false ;
2634 }
2735
You can’t perform that action at this time.
0 commit comments