'graphql issue with route in golang

I used router in my code as:

router := chi.NewRouter()

router.Use(auth.Middleware())
srv := handler.NewDefaultServer(generated.NewExecutableSchema(generated.Config{Resolvers: &graph.Resolver{}}))

router.Handle("/", playground.Handler("GraphQL playground", "/query"))
router.Handle("/query", srv)

and got error like :

{
  "errors": {
    "message": "Unexpected token p in JSON at position 4",
    "stack": "SyntaxError: Unexpected token p in JSON at position 4"
  }
}

but when I Try using it with http.Handle it doesn't show error but the code inside auth.middleware doesn't run at all.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source