Skip to content
This repository was archived by the owner on Mar 10, 2022. It is now read-only.

Commit 6620d93

Browse files
committed
feat: log out curl command during debug mode
This will make it easier to understand why something is not working.
1 parent 6cc979f commit 6620d93

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

src/queries/graphqlQuery.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { request, RequestOptions } from 'https'
22
import { CancellationToken } from 'vscode'
33
import { log } from '../log'
44
import { debugEnabledSetting } from '../settings/debugEnabledSetting'
5-
import { endpointHostnameSetting } from '../settings/endpointSetting'
5+
import { endpointHostnameSetting, endpointSetting } from '../settings/endpointSetting'
66
import { accessTokenSetting } from '../settings/accessTokenSetting'
77

88
export 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

Comments
 (0)