@@ -9,9 +9,14 @@ import {
9
9
OneGraphClient ,
10
10
} from 'netlify-onegraph-internal' ;
11
11
import path from 'path' ;
12
+ import process from 'process'
12
13
13
14
const { Kind, parse, print } = GraphQL
14
15
16
+ const condLog = ( message ) => {
17
+ process . env . NETLIFY_GRAPH_DEBUG === 'true' && console . log ( message ) ;
18
+ }
19
+
15
20
/**
16
21
* Remove any relative path components from the given path
17
22
* @param {string[] } items Filesystem path items to filter
@@ -368,8 +373,8 @@ const readGraphQLOperationsSourceFiles = (netlifyGraphConfig) => {
368
373
369
374
const filenames = fs . readdirSync ( operationsPath )
370
375
371
- console . log ( "operationsPath" , operationsPath )
372
- console . log ( "filenames" , filenames )
376
+ condLog ( "operationsPath" , operationsPath )
377
+ condLog ( "filenames" , filenames )
373
378
filenames . forEach ( ( filename ) => {
374
379
if ( / .* \. ( g r a p h q l ? ) / gi. test ( filename ) ) {
375
380
const content = fs . readFileSync ( path . resolve ( operationsPath , filename ) , 'utf8' )
@@ -400,7 +405,7 @@ const readGraphQLOperationsSourceFiles = (netlifyGraphConfig) => {
400
405
401
406
const source = print ( parsedDoc )
402
407
403
- console . log ( "GraphQL source" , source )
408
+ condLog ( "GraphQL source" , source )
404
409
405
410
return source
406
411
}
@@ -521,7 +526,7 @@ Run \`netlify graph:init\` to generate a new token.`
521
526
site : siteInfo ,
522
527
} ) ;
523
528
524
- console . log ( "netlifyGraphConfig" , netlifyGraphConfig )
529
+ condLog ( "netlifyGraphConfig" , netlifyGraphConfig )
525
530
526
531
let netlifyGraphJson ;
527
532
try {
@@ -537,7 +542,7 @@ Run \`netlify graph:init\` to generate a new token.`
537
542
) ;
538
543
}
539
544
540
- console . log ( 'Creating a new Netlify Graph schema' ) ;
545
+ condLog ( 'Creating a new Netlify Graph schema' ) ;
541
546
542
547
const createGraphQLSchemaResult =
543
548
await OneGraphClient . executeCreateGraphQLSchemaMutation (
@@ -557,7 +562,7 @@ Run \`netlify graph:init\` to generate a new token.`
557
562
}
558
563
) ;
559
564
560
- console . log (
565
+ condLog (
561
566
'Created a new Netlify Graph schema' ,
562
567
createGraphQLSchemaResult
563
568
) ;
0 commit comments