Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add agent to client constructor options #130

Closed
wants to merge 2 commits into from

Conversation

dannycochran
Copy link

@dannycochran dannycochran commented Mar 6, 2019

It looks like there's some hangup around adding an agent property to the constructor options, but I'm not sure I entirely understand it.

For instance, Fredy C commented in #84 that:

I guess that my concern is about importing https module which would work fine in node environment, but when building eg. with Webpack, it would suddenly force users to somehow mock that module. From my experience even using inline require does not work because Webpack will see it.

However, if you like at the typings for the request module, they're doing the same thing so I'm not sure what the hangup is?

https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/request/index.d.ts#L21

@dannycochran
Copy link
Author

ping @schickling as I recently ran into this issue again and found my own issue here while debugging :)

@Gocnak
Copy link

Gocnak commented Jun 30, 2021

Hello! I'd like to bump @schickling and/or @jjangga0214 to check out this PR, as this fixes a problem within an upstream dependency of ours.

I did a writeup of the bug that's happening here: https://gitlab.com/groups/gitlab-org/-/epics/6244#note_615087584

It would be amazing to have this fix merged in, which allows anyone using a self-signed cert to make the proper requests via an https.Agent. Thank you.

This would fix #41 as well.

@schickling
Copy link
Contributor

Sorry for the radio silence from my end. Unfortunately I currently don't have the capacity to maintain this library but given that @jjangga0214 seems to have been active here recently I hope they can carry this PR forward. 🙏

@jjangga0214
Copy link
Contributor

jjangga0214 commented Jul 2, 2021

@Gocnak @schickling Yes I think I can contribute :)

By the way, we are using cross-fetch under the hood, but it doesn't provide an agent option. So we can consider...

1. Replacing it to a non-compatible new library.

For example axios provides httpAgent and httpsAgent options.

However, that can be a breaking change, especially as we allow users to pass the fetch-compatible function.

https://github.com/prisma-labs/graphql-request/blob/c544c5f72942d23668aad6819257521c804f035f/src/types.dom.ts#L297

If needed, in order to avoid such a breaking change, we might still leave the option as-is, and
A. Using axios as default, fetch only when it is passed (and throw an error if agent and fetch are both given)
or
B. Using fetch as default, axios only when agent is passed.

Many parts of our code would need to be refactored, and some PRs waiting(pending) will become invalid.

2. Creating a slightly modified library, fetch-compatible except optionally allowing agent option.

For instance, we can modify cross-fetch a little bit, as it uses node-fetch on nodejs env, and node-fetch allows the agent option (though it is not standard whatwg-fetch spec).


In my humble opinion, I feel OK with such refactoring, but I want to also hear peoples' opinions first (especially @schickling @jasonkuhrt).

@jjangga0214 jjangga0214 mentioned this pull request Jul 3, 2021
@jasonkuhrt jasonkuhrt deleted the branch graffle-js:master January 26, 2023 02:00
@jasonkuhrt jasonkuhrt closed this Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants