From c2ff4198e5fcba7976a103da1f9c569c6a7356bf Mon Sep 17 00:00:00 2001 From: Jack Williams Date: Thu, 31 Mar 2022 15:27:45 +0100 Subject: [PATCH] Add instructions for enabling autobinding --- docs/content/getting-started.md | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/docs/content/getting-started.md b/docs/content/getting-started.md index 35506265476..d09b5f36a52 100644 --- a/docs/content/getting-started.md +++ b/docs/content/getting-started.md @@ -193,7 +193,17 @@ This example is great, but in the real world fetching most objects is expensive. todo unless the user actually asked for it. So lets replace the generated `Todo` model with something slightly more realistic. -Create a new file called `graph/model/todo.go` +First let's enable `autobind`, allowing gqlgen to use your custom models if it can find them rather than generating them. We do this by uncommenting the `autobind` config line in `gqlgen.yml`: + +```yml +# gqlgen will search for any type names in the schema in these go packages +# if they match it will use them, otherwise it will generate them. +autobind: + - "github.com/[username]/gqlgen-todos/graph/model" +``` + +Next, create a new file called `graph/model/todo.go` + ```go package model @@ -205,10 +215,6 @@ type Todo struct { } ``` -> Note -> -> By default gqlgen will use any models in the model directory that match on name, this can be configured in `gqlgen.yml`. - And run `go run github.com/99designs/gqlgen generate`. >