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

Commit 7c9c03d

Browse files
JoviDeCroockacao
authored andcommitted
check protocol for https and else disable agent
1 parent 82ede28 commit 7c9c03d

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

src/client/network-helper.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -70,35 +70,35 @@ export class NetworkHelper {
7070
headers: endpoint.headers as HeadersInit,
7171
// this is an option that's only available in `node-fetch`, not in the standard fetch API
7272
// @ts-expect-error
73-
agent,
73+
agent: new URL(endpoint.url).protocol === 'https:' ? agent : undefined,
7474
},
7575
exchanges,
7676
})
7777
}
7878

7979
buildSubscribeConsumer =
8080
(cb: ExecuteOperationOptions["updateCallback"], operation: string) =>
81-
(result: OperationResult) => {
82-
const { errors, data, error } = result as {
83-
error?: CombinedError
84-
errors?: GraphQLError[]
85-
data?: unknown
86-
}
87-
if (errors || data) {
88-
cb(formatData(result), operation)
89-
}
90-
if (error) {
91-
if (error.graphQLErrors && error.graphQLErrors.length > 0) {
92-
cb(
93-
JSON.stringify({ errors: error.graphQLErrors }, null, 2),
94-
operation,
95-
)
81+
(result: OperationResult) => {
82+
const { errors, data, error } = result as {
83+
error?: CombinedError
84+
errors?: GraphQLError[]
85+
data?: unknown
86+
}
87+
if (errors || data) {
88+
cb(formatData(result), operation)
9689
}
97-
if (error.networkError) {
98-
cb(error.networkError.toString(), operation)
90+
if (error) {
91+
if (error.graphQLErrors && error.graphQLErrors.length > 0) {
92+
cb(
93+
JSON.stringify({ errors: error.graphQLErrors }, null, 2),
94+
operation,
95+
)
96+
}
97+
if (error.networkError) {
98+
cb(error.networkError.toString(), operation)
99+
}
99100
}
100101
}
101-
}
102102

103103
async executeOperation({
104104
endpoint,

0 commit comments

Comments
 (0)