apollographql / apollographql/vscode-graphql
"Error initializing Apollo GraphQL project" when behind a proxy
- Dominant language
- TypeScript
- Stars
- 78
- Forks
- 23
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
When behind a corporate proxy, the extensions fails at startup with this error message:
```
[Network Error]: FetchError: request to https://graphql.api.apollographql.com/api/graphql failed, reason: connect ETIMEDOUT
ApolloError: request to https://graphql.api.apollographql.com/api/graphql failed, reason: connect ETIMEDOUT
```
Same project works just fine when not behind the proxy.
Things I've tried:
* In vscode, changing values for the following settings:
Setting http.proxy to the proxy value
Enabling and disabling http.proxyAuthorization
Enabling and disabling http.proxyStrictSSL
Setting http.proxySupport to 'on'
* In the .env file, setting the following values:
http_proxy
https_proxy
HTTP_PROXY
HTTPS_PROXY
GLOBAL_AGENT_HTTPS_PROXY
global_agent_https_proxy
* Setting the following environment variables:
http_proxy
https_proxy
HTTP_PROXY
HTTPS_PROXY
GLOBAL_AGENT_HTTPS_PROXY
global_agent_https_proxy
Looking at the code, I couldn't find any evidence of proxies being supported, libraries like `https-proxy-agent` or `global-agent` are not being used.
The only way I could get the proxy to work was by hacking direct access to my proxy in `src/env/fetch/fetch.ts`:
```
const agent = new (HttpsProxyAgent as any)("http://proxy.company.com:8080");
function proxyFetch(url: RequestInfo, options: RequestInit | undefined) {
return fetch(url, {
...options,
agent,
});
}
export { proxyFetch as fetch };
export {
Request,
Response,
Headers,
ResponseInit,
BodyInit,
RequestInfo,
HeadersInit,
Body,
RequestInit,
RequestMode,
RequestCredentials,
RequestCache,
RequestRedirect,
} from "node-fetch";
```
Once I've done that, then the Apollo GraphQL status shows the schema as loaded.
Is there a setting, in vscode, the extension or in my environment that I am missing in order to use the extension behind a corporate proxy, or is it simply not supported?
┆Issue is synchronized with this [Jira Task](https://apollographql.atlassian.net/browse/NEBULA-1310) by [Unito](https://www.unito.io)
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with src/env/fetch/fetch.ts and trace how the extension performs the request to graphql.api.apollographql.com. Check how VS Code, environment, and proxy settings reach this fetch path. Done means the extension can load the schema behind a corporate proxy without hard-coded proxy access, with the supported configuration documented or covered by an appropriate test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, nodejs, typescript
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100