Message: x-hasura-admin-secret but not found, #96
-
Hi. |
Beta Was this translation helpful? Give feedback.
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)
} |
Beta Was this translation helpful? Give feedback.
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.