Skip to content

Commit

Permalink
Add docs for config directives
Browse files Browse the repository at this point in the history
  • Loading branch information
vektah committed Jun 26, 2019
1 parent 64aca61 commit e7e8b55
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 4 deletions.
30 changes: 30 additions & 0 deletions docs/content/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,33 @@ models:
Everything has defaults, so add things as you need.
## Inline config with directives
gqlgen ships with some builtin directives that make it a little easier to manage wiring.
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
```
> Here be dragons
>
> gqlgen doesnt currently support user-configurable directives for SCALAR, ENUM, INTERFACE or UNION. This only works
> for internal directives. You can track the progress [here](https://github.com/99designs/gqlgen/issues/760)
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(resolver: true)
}
```
43 changes: 39 additions & 4 deletions example/config/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e7e8b55

Please sign in to comment.