Skip to content

Commit

Permalink
Update getting-started.md
Browse files Browse the repository at this point in the history
Fix getting-started missing fields resolver config
  • Loading branch information
a70537952 committed May 11, 2022
1 parent b8ec51d commit 839a842
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions docs/content/getting-started.md
Expand Up @@ -202,6 +202,31 @@ autobind:
- "github.com/[username]/gqlgen-todos/graph/model"
```

And add `Todo` fields resolver config in `gqlgen.yml` to generate resolver for `user` field
```yml
# This section declares type mapping between the GraphQL and go type systems
#
# The first line in each type will be used as defaults for resolver arguments and
# modelgen, the others will be allowed when binding to fields. Configure them to
# your liking
models:
ID:
model:
- github.com/99designs/gqlgen/graphql.ID
- github.com/99designs/gqlgen/graphql.Int
- github.com/99designs/gqlgen/graphql.Int64
- github.com/99designs/gqlgen/graphql.Int32
Int:
model:
- github.com/99designs/gqlgen/graphql.Int
- github.com/99designs/gqlgen/graphql.Int64
- github.com/99designs/gqlgen/graphql.Int32
Todo:
fields:
user:
resolver: true
```

Next, create a new file called `graph/model/todo.go`

```go
Expand All @@ -211,6 +236,7 @@ type Todo struct {
ID string `json:"id"`
Text string `json:"text"`
Done bool `json:"done"`
UserID string `json:"userId"`
User *User `json:"user"`
}
```
Expand Down

0 comments on commit 839a842

Please sign in to comment.