diff --git a/README.md b/README.md index 5f8fa6d78f..20d12c3fc7 100644 --- a/README.md +++ b/README.md @@ -40,15 +40,19 @@ type User { You need to tell gqlgen that we should only fetch friends if the user requested it. There are two ways to do this. -1. Write the model yourself and leave off friends. +#### Custom Models + +Write a custom model that omits the Friends model: ```go type User struct { - ID int - Name string + ID int + Name string } ``` +And reference the model in `gqlgen.yml`: + ```yaml # gqlgen.yml models: @@ -56,7 +60,9 @@ models: model: github.com/you/pkg/model.User # go import path to the User struct above ``` -2. Keep using the generated model, and mark the field as requiring a resolver explicitly +#### Explicit Resolvers + +If you want to Keep using the generated model: mark the field as requiring a resolver explicitly in `gqlgen.yml`: ```yaml # gqlgen.yml diff --git a/docs/content/config.md b/docs/content/config.md index 2152e81e1e..00902352da 100644 --- a/docs/content/config.md +++ b/docs/content/config.md @@ -82,15 +82,15 @@ gqlgen ships with some builtin directives that make it a little easier to manage To start using them you first need to define them: ```graphql -directive @goModel( - model: String - models: [String!] -) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION - -directive @goField( - forceResolver: Boolean - name: String -) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION +directive @goModel(model: String, models: [String!]) on OBJECT + | INPUT_OBJECT + | SCALAR + | ENUM + | INTERFACE + | UNION + +directive @goField(forceResolver: Boolean, name: String) on INPUT_FIELD_DEFINITION + | FIELD_DEFINITION ``` > Here be dragons @@ -102,7 +102,7 @@ Now you can use these directives when defining types in your schema: ```graphql type User @goModel(model: "github.com/my/app/models.User") { - id: ID! @goField(name: "todoId") - name: String! @goField(forceResolver: true) + id: ID! @goField(name: "todoId") + name: String! @goField(forceResolver: true) } ``` diff --git a/docs/content/reference/dataloaders.md b/docs/content/reference/dataloaders.md index c478947bc9..f1423511b2 100644 --- a/docs/content/reference/dataloaders.md +++ b/docs/content/reference/dataloaders.md @@ -155,4 +155,4 @@ The generated UserLoader has a few other useful methods on it: - `LoadAll(keys)`: If you know up front you want a bunch users - `Prime(key, user)`: Used to sync state between similar loaders (usersById, usersByNote) -You can see the full working example [here](https://github.com/vektah/gqlgen-tutorials/tree/master/dataloader) +You can see the full working example [here](https://github.com/vektah/gqlgen-tutorials/tree/master/dataloader). diff --git a/docs/content/reference/file-upload.md b/docs/content/reference/file-upload.md index 0680d62fef..4bf5042220 100644 --- a/docs/content/reference/file-upload.md +++ b/docs/content/reference/file-upload.md @@ -55,7 +55,7 @@ curl localhost:4000/graphql \ That invokes the following operation: -```graphql +```javascript { query: ` mutation($file: Upload!) { @@ -115,7 +115,7 @@ curl localhost:4000/query \ That invokes the following operation: -```graphql +```javascript { query: ` mutation($req: [UploadFile!]!) @@ -141,4 +141,4 @@ That invokes the following operation: } ``` -see the [example/fileupload](https://github.com/99designs/gqlgen/tree/master/example/fileupload) package for more examples. +See the [example/fileupload](https://github.com/99designs/gqlgen/tree/master/example/fileupload) package for more examples.