This project uses graph-gophers/graphql-go, graph-gophers/dataloader to write a sample graphql server in golang.
POST: /graphql
{
findPosts(ids: [1,11,21,31,41]){
id
body
user{
id
name
}
}
}
{
listPosts(limit: 2){
id
body
user{
name
address
}
}
}
curl --location 'http://localhost:9000/graphql' \
--header 'Content-Type: application/json' \
--data '{"query":"{\n listPosts(limit: 2){\n id\n body\n user{\n name\n address\n }\n }\n}"}'
├── adapter // data source
├── repository // data source
├── config
├── graphql
│ ├── resolver
│ │ ├── post.go // model resolver
│ │ ├── root.go // root resolver
│ └── schema
│ ├── schema.go
│ ├── schema.graphql
│ └── type
│ ├── post.graphql // model type
│ ├── root.graphql // root type
├── handler.go
├── loader
│ ├── loader.go // dataloader
│ └── user.go // dataloader implementation
├── model // models
├── pkg // librabries
└── server.go