From 6f78c6ac5c071700b80507c4ad72283a7911acaf Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Mon, 13 Apr 2020 12:12:02 -0400 Subject: [PATCH] Add links to godoc to the README and docsite --- README.md | 4 ++-- docs/content/reference/apq.md | 10 +++++----- docs/content/reference/changesets.md | 2 +- docs/content/reference/complexity.md | 2 +- docs/content/reference/dataloaders.md | 2 +- docs/content/reference/directives.md | 8 ++++---- docs/content/reference/errors.md | 2 +- docs/content/reference/field-collection.md | 2 +- docs/content/reference/file-upload.md | 2 +- docs/content/reference/godoc.md | 18 ++++++++++++++++++ docs/content/reference/introspection.md | 2 +- docs/content/reference/plugins.md | 2 +- docs/content/reference/resolvers.md | 6 +++--- docs/content/reference/scalars.md | 2 +- docs/layouts/partials/sidebar.html | 6 ++++-- docs/static/external-link-alt.svg | 5 +++++ docs/static/main.css | 18 ++++++++++++++++++ 17 files changed, 68 insertions(+), 25 deletions(-) create mode 100644 docs/content/reference/godoc.md create mode 100644 docs/static/external-link-alt.svg diff --git a/README.md b/README.md index 688df8cba12..ac474f19475 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# gqlgen [![Continuous Integration](https://github.com/99designs/gqlgen/workflows/Continuous%20Integration/badge.svg)](https://github.com/99designs/gqlgen/actions) [![Read the Docs](https://badgen.net/badge/docs/available/green)](http://gqlgen.com/) +# gqlgen [![Continuous Integration](https://github.com/99designs/gqlgen/workflows/Continuous%20Integration/badge.svg)](https://github.com/99designs/gqlgen/actions) [![Read the Docs](https://badgen.net/badge/docs/available/green)](http://gqlgen.com/) [![GoDoc](https://godoc.org/github.com/99designs/gqlgen?status.svg)](https://godoc.org/github.com/99designs/gqlgen) ## What is gqlgen? @@ -14,7 +14,7 @@ First work your way through the [Getting Started](https://gqlgen.com/getting-started/) tutorial. -If you can't find what your looking for, look at our [examples](https://github.com/99designs/gqlgen/tree/master/example) for example usage of gqlgen. +If you can't find what your looking for, look at our [examples](https://github.com/99designs/gqlgen/tree/master/example) for example usage of gqlgen, or visit [godoc](https://godoc.org/github.com/99designs/gqlgen). ## Reporting Issues diff --git a/docs/content/reference/apq.md b/docs/content/reference/apq.md index 79c98b55eb9..d570e44ec45 100644 --- a/docs/content/reference/apq.md +++ b/docs/content/reference/apq.md @@ -1,8 +1,8 @@ --- title: "Automatic persisted queries" -description: +description: linkTitle: "APQ" -menu: { main: { parent: 'reference' } } +menu: { main: { parent: 'reference', weight: 10 } } --- When you work with GraphQL by default your queries are transferred with every request. That can waste significant @@ -13,10 +13,10 @@ to register query hash with original query on a server. ## Usage -In order to enable Automatic Persisted Queries you need to change your client. For more information see +In order to enable Automatic Persisted Queries you need to change your client. For more information see [Automatic Persisted Queries Link](https://github.com/apollographql/apollo-link-persisted-queries) documentation. -For the server you need to implement `PersistedQueryCache` interface and pass instance to +For the server you need to implement `PersistedQueryCache` interface and pass instance to `handler.EnablePersistedQueryCache` option. See example using [go-redis](https://github.com/go-redis/redis) package below: @@ -66,7 +66,7 @@ func main() { if err != nil { log.Fatalf("cannot create APQ redis cache: %v", err) } - + c := Config{ Resolvers: &resolvers{} } gqlHandler := handler.GraphQL( blog.NewExecutableSchema(c), diff --git a/docs/content/reference/changesets.md b/docs/content/reference/changesets.md index 1c7e9b0d9e0..243ab30eb6a 100644 --- a/docs/content/reference/changesets.md +++ b/docs/content/reference/changesets.md @@ -2,7 +2,7 @@ linkTitle: Changesets title: Using maps as changesets description: Falling back to map[string]interface{} to allow for presence checks. -menu: { main: { parent: 'reference' } } +menu: { main: { parent: 'reference', weight: 10 } } --- Occasionally you need to distinguish presence from nil (undefined vs null). In gqlgen we do this using maps: diff --git a/docs/content/reference/complexity.md b/docs/content/reference/complexity.md index 4debe4198b2..81367c1cccd 100644 --- a/docs/content/reference/complexity.md +++ b/docs/content/reference/complexity.md @@ -2,7 +2,7 @@ title: "Preventing overly complex queries" description: Avoid denial of service attacks by calculating query costs and limiting complexity. linkTitle: Query Complexity -menu: { main: { parent: "reference" } } +menu: { main: { parent: "reference", weight: 10 } } --- GraphQL provides a powerful way to query your data, but putting great power in the hands of your API clients also exposes you to a risk of denial of service attacks. You can mitigate that risk with gqlgen by limiting the complexity of the queries you allow. diff --git a/docs/content/reference/dataloaders.md b/docs/content/reference/dataloaders.md index d1b3d7a7e14..a5f4f12ecef 100644 --- a/docs/content/reference/dataloaders.md +++ b/docs/content/reference/dataloaders.md @@ -2,7 +2,7 @@ title: "Optimizing N+1 database queries using Dataloaders" description: Speeding up your GraphQL requests by reducing the number of round trips to the database. linkTitle: Dataloaders -menu: { main: { parent: 'reference' } } +menu: { main: { parent: 'reference', weight: 10 } } --- Have you noticed some GraphQL queries end can make hundreds of database diff --git a/docs/content/reference/directives.md b/docs/content/reference/directives.md index 869bb799209..44a485f1880 100644 --- a/docs/content/reference/directives.md +++ b/docs/content/reference/directives.md @@ -1,8 +1,8 @@ --- title: Using schema directives to implement permission checks -description: Implementing graphql schema directives in golang for permission checks. +description: Implementing graphql schema directives in golang for permission checks. linkTitle: Schema Directives -menu: { main: { parent: 'reference' } } +menu: { main: { parent: 'reference', weight: 10 } } --- Directives are a bit like annotations in any other language. They give you a way to specify some behaviour without directly binding to the implementation. This can be really useful for cross cutting concerns like permission checks. @@ -22,7 +22,7 @@ enum Role { } ``` -When we next run go generate, gqlgen will add this directive to the DirectiveRoot +When we next run go generate, gqlgen will add this directive to the DirectiveRoot ```go type DirectiveRoot struct { HasRole func(ctx context.Context, obj interface{}, next graphql.Resolver, role Role) (res interface{}, err error) @@ -61,7 +61,7 @@ func main() { // block calling the next resolver return nil, fmt.Errorf("Access denied") } - + // or let it pass through return next(ctx) } diff --git a/docs/content/reference/errors.md b/docs/content/reference/errors.md index 361813b259b..22822089d4d 100644 --- a/docs/content/reference/errors.md +++ b/docs/content/reference/errors.md @@ -2,7 +2,7 @@ linkTitle: Handling Errors title: Sending custom error data in the graphql response description: Customising graphql error types to send custom error data back to the client using gqlgen. -menu: { main: { parent: 'reference' } } +menu: { main: { parent: 'reference', weight: 10 } } --- ## Returning errors diff --git a/docs/content/reference/field-collection.md b/docs/content/reference/field-collection.md index 8541ae0b059..0a065256a22 100644 --- a/docs/content/reference/field-collection.md +++ b/docs/content/reference/field-collection.md @@ -2,7 +2,7 @@ title: 'Determining which fields were requested by a query' description: How to determine which fields a query requested in a resolver. linkTitle: Field Collection -menu: { main: { parent: 'reference' } } +menu: { main: { parent: 'reference', weight: 10 } } --- Often it is useful to know which fields were queried for in a resolver. Having this information can allow a resolver to only fetch the set of fields required from a data source, rather than over-fetching everything and allowing gqlgen to do the rest. diff --git a/docs/content/reference/file-upload.md b/docs/content/reference/file-upload.md index e72b1d6c95e..3d4d4ea1067 100644 --- a/docs/content/reference/file-upload.md +++ b/docs/content/reference/file-upload.md @@ -2,7 +2,7 @@ title: "File Upload" description: How to upload files. linkTitle: File Upload -menu: { main: { parent: "reference" } } +menu: { main: { parent: "reference", weight: 10 } } --- Graphql server has an already built-in Upload scalar to upload files using a multipart request. \ diff --git a/docs/content/reference/godoc.md b/docs/content/reference/godoc.md new file mode 100644 index 00000000000..d6c864e85fa --- /dev/null +++ b/docs/content/reference/godoc.md @@ -0,0 +1,18 @@ +--- +title: "godoc" +description: +linkTitle: | + godoc + + + + +menu: + main: + parent: 'reference' + weight: 0 + url: https://godoc.org/github.com/99designs/gqlgen +--- diff --git a/docs/content/reference/introspection.md b/docs/content/reference/introspection.md index f9c8cc9d2b8..c3e042f4257 100644 --- a/docs/content/reference/introspection.md +++ b/docs/content/reference/introspection.md @@ -2,7 +2,7 @@ title: 'Disabling introspection' description: Prevent users from introspecting schemas in production. linkTitle: Introspection -menu: { main: { parent: 'reference' } } +menu: { main: { parent: 'reference', weight: 10 } } --- One of the best features of GraphQL is it's powerful discoverability, but sometimes you don't want to allow others to explore your endpoint. diff --git a/docs/content/reference/plugins.md b/docs/content/reference/plugins.md index 047da75c884..68a21debb02 100644 --- a/docs/content/reference/plugins.md +++ b/docs/content/reference/plugins.md @@ -2,7 +2,7 @@ linkTitle: Plugins title: How to write plugins for gqlgen description: Use plugins to customize code generation and integrate with other libraries -menu: { main: { parent: "reference" } } +menu: { main: { parent: "reference", weight: 10 } } --- Plugins provide a way to hook into the gqlgen code generation lifecycle. In order to use anything other than the diff --git a/docs/content/reference/resolvers.md b/docs/content/reference/resolvers.md index c89ee6d56c2..4418c68e9dd 100644 --- a/docs/content/reference/resolvers.md +++ b/docs/content/reference/resolvers.md @@ -2,7 +2,7 @@ linkTitle: Resolvers title: Resolving graphQL requests description: Different ways of binding graphQL requests to resolvers -menu: { main: { parent: 'reference' } } +menu: { main: { parent: 'reference', weight: 10 } } --- There are multiple ways that a graphQL type can be bound to a Go struct that allows for many usecases. @@ -102,7 +102,7 @@ The first way is you can bind resolvers to a struct based off of struct tags lik ```go type Car struct { Make string - ShortState string + ShortState string LongState string `gqlgen:"state"` Model string Color string @@ -179,7 +179,7 @@ type Truck { type Car struct { Make string - ShortState string + ShortState string LongState string Model string Color string diff --git a/docs/content/reference/scalars.md b/docs/content/reference/scalars.md index d3858c80aa1..1dbd679482f 100644 --- a/docs/content/reference/scalars.md +++ b/docs/content/reference/scalars.md @@ -2,7 +2,7 @@ linkTitle: Scalars title: Mapping GraphQL scalar types to Go types description: Mapping GraphQL scalar types to Go types -menu: { main: { parent: "reference" } } +menu: { main: { parent: "reference", weight: 10 } } --- ## Built-in helpers diff --git a/docs/layouts/partials/sidebar.html b/docs/layouts/partials/sidebar.html index c14938b5826..e9826e238a1 100644 --- a/docs/layouts/partials/sidebar.html +++ b/docs/layouts/partials/sidebar.html @@ -25,10 +25,12 @@ {{ end }} {{- if .HasChildren }}