2

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.

eglease
  • 2,445
  • 11
  • 18
  • 28
  • Are you following along the Learn GraphQL Golang path? What does your http.ListenAndServe line contain? Because I had a problem with , nil) instead of using router there. – oalmgren Sep 16 '22 at 07:53

0 Answers0