@@ -79,15 +79,14 @@ export const addCommand: AddCommand = (ctx, cli) =>
79
79
let supergraph :
80
80
| UnifiedGraphConfig
81
81
| GatewayHiveCDNOptions
82
- | GatewayGraphOSManagedFederationOptions = 'supergraph.graphql' ;
82
+ | GatewayGraphOSManagedFederationOptions = './ supergraph.graphql' ;
83
83
if ( schemaPathOrUrl ) {
84
- ctx . log . info ( ' Supergraph will be loaded from %s' , schemaPathOrUrl ) ;
84
+ ctx . log . info ( ` Supergraph will be loaded from ${ schemaPathOrUrl } ` ) ;
85
85
if ( hiveCdnKey ) {
86
86
ctx . log . info ( 'Using Hive CDN key' ) ;
87
87
if ( ! isUrl ( schemaPathOrUrl ) ) {
88
88
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 } ` ,
91
90
) ;
92
91
process . exit ( 1 ) ;
93
92
}
@@ -100,8 +99,7 @@ export const addCommand: AddCommand = (ctx, cli) =>
100
99
ctx . log . info ( 'Using GraphOS API key' ) ;
101
100
if ( ! schemaPathOrUrl . includes ( '@' ) ) {
102
101
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 } .` ,
105
103
) ;
106
104
process . exit ( 1 ) ;
107
105
}
@@ -128,7 +126,7 @@ export const addCommand: AddCommand = (ctx, cli) =>
128
126
) ;
129
127
process . exit ( 1 ) ;
130
128
}
131
- ctx . log . info ( ' Using Hive CDN endpoint %s' , hiveCdnEndpoint ) ;
129
+ ctx . log . info ( ` Using Hive CDN endpoint ${ hiveCdnEndpoint } ` ) ;
132
130
supergraph = {
133
131
type : 'hive' ,
134
132
endpoint : hiveCdnEndpoint ,
@@ -137,8 +135,7 @@ export const addCommand: AddCommand = (ctx, cli) =>
137
135
} else if ( apolloGraphRef ) {
138
136
if ( ! apolloGraphRef . includes ( '@' ) ) {
139
137
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 } .` ,
142
139
) ;
143
140
process . exit ( 1 ) ;
144
141
}
@@ -148,7 +145,7 @@ export const addCommand: AddCommand = (ctx, cli) =>
148
145
) ;
149
146
process . exit ( 1 ) ;
150
147
}
151
- ctx . log . info ( ' Using Apollo Graph Ref %s' , apolloGraphRef ) ;
148
+ ctx . log . info ( ` Using Apollo Graph Ref ${ apolloGraphRef } ` ) ;
152
149
supergraph = {
153
150
type : 'graphos' ,
154
151
apiKey : apolloKey ,
@@ -159,7 +156,7 @@ export const addCommand: AddCommand = (ctx, cli) =>
159
156
supergraph = loadedConfig . supergraph ! ; // TODO: assertion wont be necessary when exactOptionalPropertyTypes
160
157
// TODO: how to provide hive-cdn-key?
161
158
} else {
162
- ctx . log . info ( ' Using default supergraph location %s' , supergraph ) ;
159
+ ctx . log . info ( ` Using default supergraph location " ${ supergraph } "` ) ;
163
160
}
164
161
165
162
const registryConfig : Pick < SupergraphConfig , 'reporting' > = { } ;
@@ -276,13 +273,13 @@ export async function runSupergraph(
276
273
absSchemaPath = isAbsolute ( supergraphPath )
277
274
? String ( supergraphPath )
278
275
: resolve ( process . cwd ( ) , supergraphPath ) ;
279
- log . info ( 'Reading supergraph from %s' , absSchemaPath ) ;
276
+ log . info ( { path : absSchemaPath } , 'Reading supergraph' ) ;
280
277
try {
281
278
await lstat ( absSchemaPath ) ;
282
- } catch {
279
+ } catch ( err ) {
283
280
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.' ,
286
283
) ;
287
284
process . exit ( 1 ) ;
288
285
}
@@ -292,11 +289,14 @@ export async function runSupergraph(
292
289
// Polling should not be enabled when watching the file
293
290
delete config . pollingInterval ;
294
291
if ( cluster . isPrimary ) {
295
- log . info ( 'Watching %s for changes' , absSchemaPath ) ;
292
+ log . info ( { path : absSchemaPath } , 'Watching supergraph for changes' ) ;
296
293
297
294
const ctrl = new AbortController ( ) ;
298
295
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
+ ) ;
300
300
return ctrl . abort ( `Process terminated on ${ signal } ` ) ;
301
301
} ) ;
302
302
@@ -308,7 +308,10 @@ export async function runSupergraph(
308
308
// TODO: or should we just ignore?
309
309
throw new Error ( `Supergraph file was renamed to "${ f . filename } "` ) ;
310
310
}
311
- log . info ( '%s changed. Invalidating supergraph...' , absSchemaPath ) ;
311
+ log . info (
312
+ { path : absSchemaPath } ,
313
+ 'Supergraph changed. Invalidating...' ,
314
+ ) ;
312
315
if ( config . fork && config . fork > 1 ) {
313
316
for ( const workerId in cluster . workers ) {
314
317
cluster . workers [ workerId ] ! . send ( 'invalidateUnifiedGraph' ) ;
@@ -321,10 +324,16 @@ export async function runSupergraph(
321
324
} ) ( )
322
325
. catch ( ( e ) => {
323
326
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
+ ) ;
325
331
} )
326
332
. then ( ( ) => {
327
- log . info ( 'Watcher for %s successfuly closed' , absSchemaPath ) ;
333
+ log . info (
334
+ { path : absSchemaPath } ,
335
+ 'Supergraph watcher successfuly closed' ,
336
+ ) ;
328
337
} ) ;
329
338
}
330
339
}
@@ -359,17 +368,17 @@ export async function runSupergraph(
359
368
const runtime = createGatewayRuntime ( config ) ;
360
369
361
370
if ( absSchemaPath ) {
362
- log . info ( 'Serving local supergraph from %s' , absSchemaPath ) ;
371
+ log . info ( { path : absSchemaPath } , 'Serving local supergraph' ) ;
363
372
} 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' ) ;
365
374
} else if (
366
375
typeof config . supergraph === 'object' &&
367
376
'type' in config . supergraph &&
368
377
config . supergraph . type === 'hive'
369
378
) {
370
379
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' ,
373
382
) ;
374
383
} else {
375
384
log . info ( 'Serving supergraph from config' ) ;
0 commit comments