From b995f7f1fa2e18b4016d167739213ec5de95a053 Mon Sep 17 00:00:00 2001 From: Michael Compton Date: Mon, 15 Mar 2021 17:09:56 +1100 Subject: [PATCH] Make spacing consistent (#1488) --- docs/content/reference/complexity.md | 46 ++++++++++++++-------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/docs/content/reference/complexity.md b/docs/content/reference/complexity.md index 81367c1cccd..e99ac130587 100644 --- a/docs/content/reference/complexity.md +++ b/docs/content/reference/complexity.md @@ -13,13 +13,13 @@ Consider a schema that allows listing blog posts. Each blog post is also related ```graphql type Query { - posts(count: Int = 10): [Post!]! + posts(count: Int = 10): [Post!]! } type Post { - title: String! - text: String! - related(count: Int = 10): [Post!]! + title: String! + text: String! + related(count: Int = 10): [Post!]! } ``` @@ -27,15 +27,15 @@ It's not too hard to craft a query that will cause a very large response: ```graphql { - posts(count: 100) { - related(count: 100) { - related(count: 100) { - related(count: 100) { - title - } - } - } - } + posts(count: 100) { + related(count: 100) { + related(count: 100) { + related(count: 100) { + title + } + } + } + } } ``` @@ -47,12 +47,12 @@ Limiting query complexity is as simple as specifying it with the provided extens ```go func main() { - c := Config{ Resolvers: &resolvers{} } + c := Config{ Resolvers: &resolvers{} } srv := handler.NewDefaultServer(blog.NewExecutableSchema(c)) srv.Use(extension.FixedComplexityLimit(5)) // This line is key - r.Handle("/query", srv) + r.Handle("/query", srv) } ``` @@ -66,17 +66,17 @@ To apply higher costs to certain fields, we can use custom complexity functions. ```go func main() { - c := Config{ Resolvers: &resolvers{} } + c := Config{ Resolvers: &resolvers{} } - countComplexity := func(childComplexity, count int) int { - return count * childComplexity - } - c.Complexity.Query.Posts = countComplexity - c.Complexity.Post.Related = countComplexity + countComplexity := func(childComplexity, count int) int { + return count * childComplexity + } + c.Complexity.Query.Posts = countComplexity + c.Complexity.Post.Related = countComplexity - srv := handler.NewDefaultServer(blog.NewExecutableSchema(c)) + srv := handler.NewDefaultServer(blog.NewExecutableSchema(c)) srv.Use(extension.FixedComplexityLimit(5)) - http.Handle("/query", gqlHandler) + http.Handle("/query", gqlHandler) } ```