https://github.com/gbaptista/requested-fields-demo
Sample GraphQL server to show the use of the requested-fields lib.
https://github.com/gbaptista/requested-fields-demo
chi go golang graphql graphql-go requested-fields
Last synced: about 1 month ago
JSON representation
Sample GraphQL server to show the use of the requested-fields lib.
- Host: GitHub
- URL: https://github.com/gbaptista/requested-fields-demo
- Owner: gbaptista
- Created: 2019-02-10T20:08:33.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-02-10T22:00:47.000Z (over 7 years ago)
- Last Synced: 2025-04-08T17:51:21.470Z (about 1 year ago)
- Topics: chi, go, golang, graphql, graphql-go, requested-fields
- Language: Go
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# requested-fields-demo [](https://codeclimate.com/github/gbaptista/requested-fields-demo/maintainability)
Sample GraphQL server to show the use of the [requested-fields](https://github.com/gbaptista/requested-fields) lib. Created with [graphql-go](https://github.com/graph-gophers/graphql-go) and [chi](https://github.com/go-chi/chi).
- [Setup](#setup)
- [Schema](#schema)
- [Query](#query)
- [Request](#request)
- [Result](#result)
- [Logs](#logs)
## Setup
```shell
dep init
dep ensure
go build
./requested-fields-demo
```
## Schema
```graphql
schema {
query: Query
}
type Query {
user: User
}
type User {
name: String
address: Address
}
type Address {
city: String
street: String
}
```
## Query
- *http://localhost:3000/graphql*
### Request:
```graphql
query {
user {
name
address {
street
city
}
}
}
```
### Result:
```json
{
"data": {
"user": {
"name": "Harry Potter",
"address": {
"street": "4 Privet Drive",
"city": "Little Whinging"
}
}
}
}
```
### Logs:
```shell
2019/02/10 19:52:16 Query.User Fields: [name address]
2019/02/10 19:52:16 User.Address Fields: [street city]
2019/02/10 19:52:16 "POST http://localhost:3000/graphql HTTP/1.1"
```