From 26ee1aa1c9a08d15df5cb189c05195a635be6a64 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Tue, 18 Feb 2020 21:59:12 +0800 Subject: [PATCH] docs(gin): missing import playground --- docs/content/recipes/gin.md | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/docs/content/recipes/gin.md b/docs/content/recipes/gin.md index 1e680dc6471..155cc76e05e 100644 --- a/docs/content/recipes/gin.md +++ b/docs/content/recipes/gin.md @@ -17,16 +17,19 @@ $ go get github.com/gin-gonic/gin ``` In your router file, define the handlers for the GraphQL and Playground endpoints in two different methods and tie then together in the Gin router: + ```go import ( - "github.com/99designs/gqlgen/graphql/handler" - "github.com/gin-gonic/gin" + "github.com/gin-gonic/gin" + + "github.com/99designs/gqlgen/graphql/handler" + "github.com/99designs/gqlgen/graphql/playground" ) // Defining the Graphql handler func graphqlHandler() gin.HandlerFunc { - // NewExecutableSchema and Config are in the generated.go file - // Resolver is in the resolver.go file + // NewExecutableSchema and Config are in the generated.go file + // Resolver is in the resolver.go file h := handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: &Resolver{}})) return func(c *gin.Context) { @@ -44,12 +47,13 @@ func playgroundHandler() gin.HandlerFunc { } func main() { - // Setting up Gin - r := gin.Default() + // Setting up Gin + r := gin.Default() r.POST("/query", graphqlHandler()) r.GET("/", playgroundHandler()) - r.Run() -} + r.Run() +} + ``` ## Accessing gin.Context @@ -96,7 +100,7 @@ func (r *resolver) Todo(ctx context.Context) (*Todo, error) { if err != nil { return nil, err } - + // ... } ```