@@ -2,7 +2,7 @@ import { request, RequestOptions } from 'https'
22import { CancellationToken } from 'vscode'
33import { log } from '../log'
44import { debugEnabledSetting } from '../settings/debugEnabledSetting'
5- import { endpointHostnameSetting } from '../settings/endpointSetting'
5+ import { endpointHostnameSetting , endpointSetting } from '../settings/endpointSetting'
66import { accessTokenSetting } from '../settings/accessTokenSetting'
77
88export function graphqlQuery < A , B > ( query : string , variables : A , token : CancellationToken ) : Promise < B | undefined > {
@@ -15,6 +15,7 @@ export function graphqlQueryWithAccessToken<A, B>(
1515 token : CancellationToken ,
1616 accessToken : string
1717) : Promise < B | undefined > {
18+ accessToken = accessToken . trim ( )
1819 return new Promise < B | undefined > ( ( resolve , reject ) => {
1920 const data = JSON . stringify ( {
2021 query,
@@ -58,14 +59,10 @@ export function graphqlQueryWithAccessToken<A, B>(
5859 req . write ( data )
5960 req . end ( )
6061 if ( debugEnabledSetting ( ) ) {
61- const command : string [ ] = [
62- 'api' ,
63- '-query' ,
64- query . trim ( ) . replace ( / \n / g, ' ' ) . replace ( / + / g, ' ' ) ,
65- '-vars' ,
66- JSON . stringify ( variables ) ,
67- ]
68- log . appendLine ( 'src ' + command . map ( part => `'${ part } '` ) . join ( ' ' ) )
62+ const data : string = JSON . stringify ( { query : query . replace ( / \s + / g, ' ' ) , variables } )
63+ log . appendLine (
64+ `curl -H 'Authorization: token ${ accessToken } ' -d '${ data } ' ${ endpointSetting ( ) } /.api/graphql`
65+ )
6966 }
7067 token . onCancellationRequested ( ( ) => {
7168 req . destroy ( )
0 commit comments