Open
Description
I am trying to access the top-level query's arguments (and other stuff) from child object resolvers. This was my attempt to pass them down through p.Info.RootValue
. However, the request body is always empty. The content length however says otherwise.
func GinHttpHandler() gin.HandlerFunc {
httpHandler := handler.New(&handler.Config{
Schema: &rootSchema,
Pretty: true,
GraphiQL: true,
Playground: true,
RootObjectFn: func(ctx context.Context, r *http.Request) map[string]interface{} {
rootObj := make(map[string]interface{})
bb, err := io.ReadAll(r.Body)
if err != nil {
log.Println(err)
}
rootObj[`raw_query`] = string(bb) // body always empty
rootObj[`content_length`] = r.ContentLength // always 2271
return rootObj
},
})
return func(ctx *gin.Context) {
httpHandler.ServeHTTP(ctx.Writer, ctx.Request)
}
}
The query itself always have a successful response:
// POST request body from Postman
{
service(id: "xxxxxxx") {
id
description
...
}
}
Metadata
Metadata
Assignees
Labels
No labels