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

Commit 7c7f48e

Browse files
authored
feat: add rejectUnauthorized setting (#241) (#295)
1 parent 5eabcad commit 7c7f48e

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ module.exports = {
9898
headers: { Authorization: `Bearer ${process.env.API_TOKEN}` },
9999
},
100100
},
101-
}
101+
},
102102
},
103103
db: {
104104
schema: "src/generated/db.graphql",
@@ -191,7 +191,13 @@ The best way to make "execute <op type>" codelens work is to add endpoints confi
191191

192192
The config example above shows how to configure endpoints.
193193

194-
If there is an issue with execution that has to do with your server, the error response should show now in the results panel
194+
If there is an issue with execution that has to do with your server, the error response should show now in the results panel.
195+
196+
In case the request fails due to self signed certificate, you can bypass that check by adding this to your settings:
197+
198+
```json
199+
"vscode-graphql.rejectUnauthorized": false
200+
```
195201

196202
### My graphql config file is not at the root
197203

package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,13 @@
147147
],
148148
"description": "Use local SDL/IDL files for definition lookups. Default is to use generated_schema.graphql from GraphQL Config settings for definitions"
149149
},
150+
"vscode-graphql.rejectUnauthorized": {
151+
"type": [
152+
"boolean"
153+
],
154+
"description": "Fail the request on invalid certificate",
155+
"default": true
156+
},
150157
"graphql-config.load.rootDir": {
151158
"type": [
152159
"string"

src/client/network-helper.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ import { createHttpLink } from "apollo-link-http"
1313
import { WebSocketLink } from "apollo-link-ws"
1414
import { InMemoryCache } from "apollo-cache-inmemory"
1515
import fetch from "node-fetch"
16+
import { Agent } from "https"
1617
import * as ws from "ws"
1718

1819
import { Endpoints } from "graphql-config/extensions/endpoints"
19-
import { OutputChannel } from "vscode"
20+
import { OutputChannel, workspace } from "vscode"
2021
import { ApolloLink } from "apollo-link"
2122
import { UserVariables } from "./graphql-content-provider"
2223
import { GraphQLProjectConfig } from "graphql-config"
@@ -40,10 +41,16 @@ export class NetworkHelper {
4041
endpoint: Endpoint
4142
updateCallback: (data: string, operation: string) => void
4243
}) {
44+
const { rejectUnauthorized } = workspace.getConfiguration("vscode-graphql")
45+
const agent = new Agent({ rejectUnauthorized })
46+
4347
const httpLink = createHttpLink({
4448
uri: endpoint.url,
4549
headers: endpoint.headers,
4650
fetch,
51+
fetchOptions: {
52+
agent,
53+
},
4754
})
4855

4956
const errorLink = onError(({ graphQLErrors, networkError }) => {

0 commit comments

Comments
 (0)