@@ -12,6 +12,7 @@ import { updateSubgraphNetwork } from '../command-helpers/network';
12
12
import { chooseNodeUrl , getHostedServiceSubgraphId } from '../command-helpers/node' ;
13
13
import { assertGraphTsVersion , assertManifestApiVersion } from '../command-helpers/version' ;
14
14
import { GRAPH_CLI_SHARED_HEADERS } from '../constants' ;
15
+ import debugFactory from '../debug' ;
15
16
import Protocol from '../protocols' ;
16
17
17
18
const headersFlag = Flags . custom < Record < string , string > > ( {
@@ -23,6 +24,8 @@ const headersFlag = Flags.custom<Record<string, string>>({
23
24
24
25
const productOptions = [ 'subgraph-studio' , 'hosted-service' ] ;
25
26
27
+ const deployDebugger = debugFactory ( 'graph-cli:deploy' ) ;
28
+
26
29
export default class DeployCommand extends Command {
27
30
static description = 'Deploys a subgraph to a Graph node.' ;
28
31
@@ -205,17 +208,21 @@ export default class DeployCommand extends Command {
205
208
// @ts -expect-error TODO: why are the arguments not typed?
206
209
res ,
207
210
) => {
211
+ deployDebugger ( 'requestError: %O' , requestError ) ;
212
+ deployDebugger ( 'jsonRpcError: %O' , jsonRpcError ) ;
208
213
if ( jsonRpcError ) {
209
- let errorMessage = `Failed to deploy to Graph node ${ requestUrl } : ${ jsonRpcError . message } ` ;
214
+ const message = jsonRpcError ?. message || jsonRpcError ?. code ?. toString ( ) ;
215
+ deployDebugger ( 'message: %O' , message ) ;
216
+ let errorMessage = `Failed to deploy to Graph node ${ requestUrl } : ${ message } ` ;
210
217
211
218
// Provide helpful advice when the subgraph has not been created yet
212
- if ( jsonRpcError . message . match ( / s u b g r a p h n a m e n o t f o u n d / ) ) {
219
+ if ( message ? .match ( / s u b g r a p h n a m e n o t f o u n d / ) ) {
213
220
errorMessage += `
214
221
Make sure to create the subgraph first by running the following command:
215
222
$ graph create --node ${ node } ${ subgraphName } ` ;
216
223
}
217
224
218
- if ( jsonRpcError . message . match ( / a u t h f a i l u r e / ) ) {
225
+ if ( message ? .match ( / a u t h f a i l u r e / ) ) {
219
226
errorMessage += '\nYou may need to authenticate first.' ;
220
227
}
221
228
@@ -336,11 +343,15 @@ export default class DeployCommand extends Command {
336
343
// @ts -expect-error TODO: why are the arguments not typed?
337
344
res ,
338
345
) => {
346
+ deployDebugger ( 'requestError: %O' , requestError ) ;
347
+ deployDebugger ( 'jsonRpcError: %O' , jsonRpcError ) ;
339
348
if ( jsonRpcError ) {
340
- let errorMessage = `Failed to deploy to Graph node ${ requestUrl } : ${ jsonRpcError . message } ` ;
349
+ const message = jsonRpcError ?. message || jsonRpcError ?. code ?. toString ( ) ;
350
+ deployDebugger ( 'message: %O' , message ) ;
351
+ let errorMessage = `Failed to deploy to Graph node ${ requestUrl } : ${ message } ` ;
341
352
342
353
// Provide helpful advice when the subgraph has not been created yet
343
- if ( jsonRpcError . message . match ( / s u b g r a p h n a m e n o t f o u n d / ) ) {
354
+ if ( message ? .match ( / s u b g r a p h n a m e n o t f o u n d / ) ) {
344
355
if ( isHostedService ) {
345
356
errorMessage +=
346
357
'\nYou may need to create it at https://thegraph.com/explorer/dashboard.' ;
@@ -350,7 +361,7 @@ export default class DeployCommand extends Command {
350
361
$ graph create --node ${ node } ${ subgraphName } ` ;
351
362
}
352
363
}
353
- if ( jsonRpcError . message . match ( / a u t h f a i l u r e / ) ) {
364
+ if ( message ? .match ( / a u t h f a i l u r e / ) ) {
354
365
errorMessage += '\nYou may need to authenticate first.' ;
355
366
}
356
367
spinner . fail ( errorMessage ) ;
0 commit comments