Skip to content

Commit

Permalink
Fix VSCode Weirdness, validate formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
cfilby committed Oct 16, 2019
1 parent a20c96d commit 0968e0c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 19 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,29 @@ 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:
User:
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
Expand Down
22 changes: 11 additions & 11 deletions docs/content/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}
```
2 changes: 1 addition & 1 deletion docs/content/reference/dataloaders.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
6 changes: 3 additions & 3 deletions docs/content/reference/file-upload.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ curl localhost:4000/graphql \
That invokes the following operation:
```graphql
```javascript
{
query: `
mutation($file: Upload!) {
Expand Down Expand Up @@ -115,7 +115,7 @@ curl localhost:4000/query \

That invokes the following operation:

```graphql
```javascript
{
query: `
mutation($req: [UploadFile!]!)
Expand All @@ -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.

0 comments on commit 0968e0c

Please sign in to comment.