@@ -79,15 +79,14 @@ export const addCommand: AddCommand = (ctx, cli) =>
7979 let supergraph :
8080 | UnifiedGraphConfig
8181 | GatewayHiveCDNOptions
82- | GatewayGraphOSManagedFederationOptions = 'supergraph.graphql' ;
82+ | GatewayGraphOSManagedFederationOptions = './ supergraph.graphql' ;
8383 if ( schemaPathOrUrl ) {
84- ctx . log . info ( ' Supergraph will be loaded from %s' , schemaPathOrUrl ) ;
84+ ctx . log . info ( ` Supergraph will be loaded from ${ schemaPathOrUrl } ` ) ;
8585 if ( hiveCdnKey ) {
8686 ctx . log . info ( 'Using Hive CDN key' ) ;
8787 if ( ! isUrl ( schemaPathOrUrl ) ) {
8888 ctx . log . error (
89- 'Hive CDN endpoint must be a URL when providing --hive-cdn-key but got %s' ,
90- schemaPathOrUrl ,
89+ `Hive CDN endpoint must be a URL when providing --hive-cdn-key but got ${ schemaPathOrUrl } ` ,
9190 ) ;
9291 process . exit ( 1 ) ;
9392 }
@@ -100,8 +99,7 @@ export const addCommand: AddCommand = (ctx, cli) =>
10099 ctx . log . info ( 'Using GraphOS API key' ) ;
101100 if ( ! schemaPathOrUrl . includes ( '@' ) ) {
102101 ctx . log . error (
103- `Apollo GraphOS requires a graph ref in the format <graph-id>@<graph-variant> when providing --apollo-key. Please provide a valid graph ref not %s.` ,
104- schemaPathOrUrl ,
102+ `Apollo GraphOS requires a graph ref in the format <graph-id>@<graph-variant> when providing --apollo-key. Please provide a valid graph ref not ${ schemaPathOrUrl } .` ,
105103 ) ;
106104 process . exit ( 1 ) ;
107105 }
@@ -128,7 +126,7 @@ export const addCommand: AddCommand = (ctx, cli) =>
128126 ) ;
129127 process . exit ( 1 ) ;
130128 }
131- ctx . log . info ( ' Using Hive CDN endpoint %s' , hiveCdnEndpoint ) ;
129+ ctx . log . info ( ` Using Hive CDN endpoint ${ hiveCdnEndpoint } ` ) ;
132130 supergraph = {
133131 type : 'hive' ,
134132 endpoint : hiveCdnEndpoint ,
@@ -137,8 +135,7 @@ export const addCommand: AddCommand = (ctx, cli) =>
137135 } else if ( apolloGraphRef ) {
138136 if ( ! apolloGraphRef . includes ( '@' ) ) {
139137 ctx . log . error (
140- 'Apollo GraphOS requires a graph ref in the format <graph-id>@<graph-variant>. Please provide a valid graph ref not %s.' ,
141- apolloGraphRef ,
138+ `Apollo GraphOS requires a graph ref in the format <graph-id>@<graph-variant>. Please provide a valid graph ref not ${ apolloGraphRef } .` ,
142139 ) ;
143140 process . exit ( 1 ) ;
144141 }
@@ -148,7 +145,7 @@ export const addCommand: AddCommand = (ctx, cli) =>
148145 ) ;
149146 process . exit ( 1 ) ;
150147 }
151- ctx . log . info ( ' Using Apollo Graph Ref %s' , apolloGraphRef ) ;
148+ ctx . log . info ( ` Using Apollo Graph Ref ${ apolloGraphRef } ` ) ;
152149 supergraph = {
153150 type : 'graphos' ,
154151 apiKey : apolloKey ,
@@ -159,7 +156,7 @@ export const addCommand: AddCommand = (ctx, cli) =>
159156 supergraph = loadedConfig . supergraph ! ; // TODO: assertion wont be necessary when exactOptionalPropertyTypes
160157 // TODO: how to provide hive-cdn-key?
161158 } else {
162- ctx . log . info ( ' Using default supergraph location %s' , supergraph ) ;
159+ ctx . log . info ( ` Using default supergraph location " ${ supergraph } "` ) ;
163160 }
164161
165162 const registryConfig : Pick < SupergraphConfig , 'reporting' > = { } ;
@@ -276,13 +273,13 @@ export async function runSupergraph(
276273 absSchemaPath = isAbsolute ( supergraphPath )
277274 ? String ( supergraphPath )
278275 : resolve ( process . cwd ( ) , supergraphPath ) ;
279- log . info ( 'Reading supergraph from %s' , absSchemaPath ) ;
276+ log . info ( { path : absSchemaPath } , 'Reading supergraph' ) ;
280277 try {
281278 await lstat ( absSchemaPath ) ;
282- } catch {
279+ } catch ( err ) {
283280 log . error (
284- 'Could not read supergraph from %s. Make sure the file exists.' ,
285- absSchemaPath ,
281+ { path : absSchemaPath , err } ,
282+ 'Could not read supergraph. Make sure the file exists.' ,
286283 ) ;
287284 process . exit ( 1 ) ;
288285 }
@@ -292,11 +289,14 @@ export async function runSupergraph(
292289 // Polling should not be enabled when watching the file
293290 delete config . pollingInterval ;
294291 if ( cluster . isPrimary ) {
295- log . info ( 'Watching %s for changes' , absSchemaPath ) ;
292+ log . info ( { path : absSchemaPath } , 'Watching supergraph for changes' ) ;
296293
297294 const ctrl = new AbortController ( ) ;
298295 registerTerminateHandler ( ( signal ) => {
299- log . info ( 'Closing watcher for %s on %s' , absSchemaPath , signal ) ;
296+ log . info (
297+ { path : absSchemaPath } ,
298+ `Closing watcher for supergraph on ${ signal } ` ,
299+ ) ;
300300 return ctrl . abort ( `Process terminated on ${ signal } ` ) ;
301301 } ) ;
302302
@@ -308,7 +308,10 @@ export async function runSupergraph(
308308 // TODO: or should we just ignore?
309309 throw new Error ( `Supergraph file was renamed to "${ f . filename } "` ) ;
310310 }
311- log . info ( '%s changed. Invalidating supergraph...' , absSchemaPath ) ;
311+ log . info (
312+ { path : absSchemaPath } ,
313+ 'Supergraph changed. Invalidating...' ,
314+ ) ;
312315 if ( config . fork && config . fork > 1 ) {
313316 for ( const workerId in cluster . workers ) {
314317 cluster . workers [ workerId ] ! . send ( 'invalidateUnifiedGraph' ) ;
@@ -321,10 +324,16 @@ export async function runSupergraph(
321324 } ) ( )
322325 . catch ( ( e ) => {
323326 if ( e . name === 'AbortError' ) return ;
324- log . error ( e , 'Watcher for %s closed with an error' , absSchemaPath ) ;
327+ log . error (
328+ { path : absSchemaPath , err : e } ,
329+ 'Supergraph watcher closed with an error' ,
330+ ) ;
325331 } )
326332 . then ( ( ) => {
327- log . info ( 'Watcher for %s successfuly closed' , absSchemaPath ) ;
333+ log . info (
334+ { path : absSchemaPath } ,
335+ 'Supergraph watcher successfuly closed' ,
336+ ) ;
328337 } ) ;
329338 }
330339 }
@@ -359,17 +368,17 @@ export async function runSupergraph(
359368 const runtime = createGatewayRuntime ( config ) ;
360369
361370 if ( absSchemaPath ) {
362- log . info ( 'Serving local supergraph from %s' , absSchemaPath ) ;
371+ log . info ( { path : absSchemaPath } , 'Serving local supergraph' ) ;
363372 } else if ( isUrl ( String ( config . supergraph ) ) ) {
364- log . info ( 'Serving remote supergraph from %s' , config . supergraph ) ;
373+ log . info ( { url : config . supergraph } , 'Serving remote supergraph' ) ;
365374 } else if (
366375 typeof config . supergraph === 'object' &&
367376 'type' in config . supergraph &&
368377 config . supergraph . type === 'hive'
369378 ) {
370379 log . info (
371- 'Serving supergraph from Hive CDN at %s' ,
372- config . supergraph . endpoint ,
380+ { endpoint : config . supergraph . endpoint } ,
381+ 'Serving supergraph from Hive CDN' ,
373382 ) ;
374383 } else {
375384 log . info ( 'Serving supergraph from config' ) ;
0 commit comments