https://github.com/blukai/gqlgenc-omitempty-example
https://github.com/blukai/gqlgenc-omitempty-example
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/blukai/gqlgenc-omitempty-example
- Owner: blukai
- Created: 2021-06-03T22:28:58.000Z (about 5 years ago)
- Default Branch: with-omitempty
- Last Pushed: 2021-06-03T23:07:57.000Z (about 5 years ago)
- Last Synced: 2025-10-04T12:07:13.044Z (9 months ago)
- Language: Go
- Size: 10.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# gqlgenc-omitempty-example
run [dgraph](https://dgraph.io) in [docker](https://docs.docker.com/engine/install/)
```
$ docker-compose up -d
```
set the schema with [dgraph-admin](https://github.com/blukai/dgraph-admin)
```
$ dgraph-admin update-schema schema.graphql
```
generate modelds and client with [gqlgenc](https://github.com/Yamashou/gqlgenc)
```
$ gqlgenc
```
run the example
```
$ go run main.go
```
and the response is fine
```
[]*gen.PlanetFragment{
&gen.PlanetFragment{
ID: "0x2e",
Name: "Jupiter",
Moons: []*struct { ID string "json:\"id\" graphql:\"id\""; Name string "json:\"name\" graphql:\"name\"" }{},
},
&gen.PlanetFragment{
ID: "0x2f",
Name: "Earth",
Moons: []*struct { ID string "json:\"id\" graphql:\"id\""; Name string "json:\"name\" graphql:\"name\"" }{
&struct { ID string "json:\"id\" graphql:\"id\""; Name string "json:\"name\" graphql:\"name\"" }{
ID: "0x30",
Name: "Moon",
},
},
},
}
```