@@ -2,6 +2,7 @@ package graphql
22
33import (
44 "github.com/99designs/gqlgen/graphql/handler"
5+ "github.com/99designs/gqlgen/graphql/handler/extension"
56 "github.com/99designs/gqlgen/graphql/handler/transport"
67 "github.com/99designs/gqlgen/graphql/playground"
78 "github.com/labstack/echo/v4"
@@ -18,7 +19,10 @@ func (server *Server) Initialize() {
1819 ),
1920 )
2021 graphqlHandler .AddTransport (& transport.Websocket {})
21- playgroundHandler := playground .Handler ("GraphQL" , "/graphql" )
22+
23+ if server .SystemConfig .IsDevelopmentMode {
24+ graphqlHandler .Use (extension.Introspection {})
25+ }
2226
2327 server .EchoServer .GET ("/graphql" , func (c echo.Context ) error {
2428 graphqlHandler .ServeHTTP (c .Response (), c .Request ())
@@ -30,8 +34,12 @@ func (server *Server) Initialize() {
3034 return nil
3135 })
3236
33- server .EchoServer .GET ("/playground" , func (c echo.Context ) error {
34- playgroundHandler .ServeHTTP (c .Response (), c .Request ())
35- return nil
36- })
37+ if server .SystemConfig .IsDevelopmentMode {
38+ // Create GraphQL Playground
39+ playgroundHandler := playground .Handler ("GraphQL" , "/graphql" )
40+ server .EchoServer .GET ("/playground" , func (c echo.Context ) error {
41+ playgroundHandler .ServeHTTP (c .Response (), c .Request ())
42+ return nil
43+ })
44+ }
3745}
0 commit comments