Skip to content

Commit

Permalink
Add links to godoc to the README and docsite
Browse files Browse the repository at this point in the history
  • Loading branch information
ddevault committed Apr 13, 2020
1 parent a1a0261 commit 6f78c6a
Show file tree
Hide file tree
Showing 17 changed files with 68 additions and 25 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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?

Expand All @@ -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

Expand Down
10 changes: 5 additions & 5 deletions docs/content/reference/apq.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion docs/content/reference/changesets.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion docs/content/reference/complexity.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion docs/content/reference/dataloaders.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions docs/content/reference/directives.md
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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)
Expand Down Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion docs/content/reference/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/content/reference/field-collection.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion docs/content/reference/file-upload.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. \
Expand Down
18 changes: 18 additions & 0 deletions docs/content/reference/godoc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
title: "godoc"
description:
linkTitle: |
godoc
<span class="icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path d="M576 24v127.984c0 21.461-25.96 31.98-40.971 16.971l-35.707-35.709-243.523 243.523c-9.373 9.373-24.568 9.373-33.941 0l-22.627-22.627c-9.373-9.373-9.373-24.569 0-33.941L442.756 76.676l-35.703-35.705C391.982 25.9 402.656 0 424.024 0H552c13.255 0 24 10.745 24 24zM407.029 270.794l-16 16A23.999 23.999 0 0 0 384 303.765V448H64V128h264a24.003 24.003 0 0 0 16.97-7.029l16-16C376.089 89.851 365.381 64 344 64H48C21.49 64 0 85.49 0 112v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V287.764c0-21.382-25.852-32.09-40.971-16.97z"/></svg>
<!--
Font Awesome Free 5.3.1 by @fontawesome - https://fontawesome.com
License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
-->
</span>
menu:
main:
parent: 'reference'
weight: 0
url: https://godoc.org/github.com/99designs/gqlgen
---
2 changes: 1 addition & 1 deletion docs/content/reference/introspection.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion docs/content/reference/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions docs/content/reference/resolvers.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -179,7 +179,7 @@ type Truck {

type Car struct {
Make string
ShortState string
ShortState string
LongState string
Model string
Color string
Expand Down
2 changes: 1 addition & 1 deletion docs/content/reference/scalars.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions docs/layouts/partials/sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@
{{ end }}
{{- if .HasChildren }}
<ul class="submenu">
{{- range .Children }}
{{- range .Children.ByWeight }}
<li class="{{ if $currentPage.IsMenuCurrent "main" . }}active{{ end }}">
{{ if .URL }}
<a class="menu-item" href="{{ .URL }}">{{ .Name }}</a>
<a class="menu-item" href="{{ .URL }}">
{{ .Name | safeHTML }}
</a>
{{ else }}
<span class="menu-item">{{ .Name }}</span>
{{ end }}
Expand Down
5 changes: 5 additions & 0 deletions docs/static/external-link-alt.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions docs/static/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -525,3 +525,21 @@ tr td:first-child, th {
.alert-warning a {
color: #ff6;
}

.icon {
display: inline-block;
line-height: .75em;
width: 1em;
}

.icon svg {
display: block;
}

.icon svg path {
fill: currentColor;
}

ul.submenu span.icon {
padding: 0;
}

0 comments on commit 6f78c6a

Please sign in to comment.