Documentation
SCKelemen opened this issue · comments
Is there any documentation?
Especially on using this with a router.
The README offers a brief code-cum-documentation of the library. We need to do some work to make better documentation. @SCKelemen what kind of router are you using btw?
I apologize for the delay. I thought I had already replied.
I am using quo-vadis. https://github.com/jackc/quo_vadis
Thanks!
We're using Echo server, but I think this example should translate to your case too. The setup is very simple, just mount your graphql request server on the /graphql
POST route.
func NewServer() *echo.Echo {
...
server.Post("/graphql", graphQLHandler)
}
func graphQLHandler(context echo.Context) error {
...
// setup executor here
...
body, err := ioutil.ReadAll(context.Request().Body())
if err != nil {
panic(err)
}
var data map[string]interface{}
if err := json.Unmarshal(body, &data); err != nil {
panic(err)
}
query := data["query"]
variables := data["variables"]
result, err := executor.Execute(context, query, variables, "")
if err != nil {
panic(err)
}
fmt.Printf("%v", result)
// return result
}