Repository navigation
Message: x-hasura-admin-secret but not found, #96
Answered
by
celikezer
mvltyldrmm
asked this question in
Q&A
|
Hi. |
Answered by
celikezer
Jun 22, 2022
Replies: 1 comment
|
I have had the same issue, and I solve it by passing these missing parameters to the header like below. Create a round trip with your required tokens & credentials or etc. Then create an HTTP client using this Round Trip, this will add the header parameters, and you can edit your requests there.
var client *graphql.Client
func init() {
if client != nil {
return
}
httpClient := http.Client{
Transport: &authedTransport{
wrapped: http.DefaultTransport,
},
}
client = graphql.NewClient("https://your-hasura-address.hasura.app/v1/graphql", &httpClient)
}
func GetGraphQLClient() *graphql.Client {
return client
}
type authedTransport struct {
wrapped http.RoundTripper
}
func (t *authedTransport) RoundTrip(req *http.Request) (*http.Response, error) {
// you can mutate your requests here as you wish
req.Header.Set("x-hasura-admin-secret", "your-admin-secret-key")
req.Header.Set("x-hasura-access-key", "your-token")
return t.wrapped.RoundTrip(req)
} |
0 replies
Answer selected by
mvltyldrmm
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have had the same issue, and I solve it by passing these missing parameters to the header like below.
Create a round trip with your required tokens & credentials or etc. Then create an HTTP client using this Round Trip, this will add the header parameters, and you can edit your requests there.