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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra Headers support in CLI #430

Open
DaniFoldi opened this issue Apr 19, 2024 · 1 comment
Open

Extra Headers support in CLI #430

DaniFoldi opened this issue Apr 19, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@DaniFoldi
Copy link

Hi 馃憢,

I'm opening this issue to ask if a new config option extraHeaders would be interesting. In our setup (behind Cloudflare Access) any programmatic access needs to provide two extra headers, provided as environment variables to the Docker container. In an effort to get rid of our mitm proxy in CI that just adds the headers to all requests, I was instead looking at a native solution.

To me it looked like the only place this needs to be added (in the CLI, since all the rest is inside the docker container that is the application behind Access) is here in project-fetcher.ts:

return await fetch(`${config.apiUrl}/graphql`, {
body: JSON.stringify({query, variables}),
headers: {
'Content-Type': 'application/json',
authorization: `Bearer ${config.apiKey}`
},
method: 'POST'
});
and a few places in document.ts - in this second case the simplest solution would be to (add it to config, pass it the Document class) and add it the the private authorizationHeader() method:
private authorizationHeader() {
return {authorization: `Bearer ${this.apiKey}`};
}
; alternatively the couple of places that call fetch()聽could all be modified, which one would be preferable?

In general, would this extra headers feature be something you would be interested in supporting? Happy to work on a PR implementing it.

@simonprev
Copy link
Member

Sure I鈥檓 open to a PR addressing thing 馃槂

@simonprev simonprev added the enhancement New feature or request label May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants