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

Support adding additional headers in client #857

Closed
jamesabbottsmith opened this issue Sep 11, 2019 · 3 comments
Closed

Support adding additional headers in client #857

jamesabbottsmith opened this issue Sep 11, 2019 · 3 comments

Comments

@jamesabbottsmith
Copy link

jamesabbottsmith commented Sep 11, 2019

What happened?

Current client implementation does not support adding additional Headers

What did you expect?

The ability to set custom Headers using the client when making a req.
This is handy for testing against GraphQL servers that have authentication.

For example

client.Header.Add("authorization", "abcd1234")`

(I've hacked it locally to make it work for me, happy to submit a PR. Should be backward compatible)

versions

  • v0.9.3-dev
  • go version go1.13 darwin/amd64
@vektah
Copy link
Collaborator

vektah commented Oct 1, 2019

Fixed by #861 in 0.10

@vektah vektah closed this as completed Oct 1, 2019
@harmnot
Copy link

harmnot commented Jun 14, 2020

I got issue with this
here is my client:

	clientTest := client.New(handler.NewDefaultServer(resolver.NewExecutableSchema(config)))

when I mutation query which need header

	client.MustPost(
			mutation,
			&respond,
                       client.AddHeader("Token", TOKEN_HERE)
		)

It doesn't read my header at all, any idea ? I have look your PR and implement it, no luck to me
I am using
latest gqlgen
latest go version

@lwc
Copy link
Member

lwc commented Sep 22, 2020

@harmnot how are you reading the header back into context? seems like you need some middleware to move the value from the http header into context?

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

No branches or pull requests

4 participants