Sample GraphQL server to show the use of the requested-fields lib. Created with graphql-go and chi.
dep init
dep ensure
go build
./requested-fields-demo
schema {
query: Query
}
type Query {
user: User
}
type User {
name: String
address: Address
}
type Address {
city: String
street: String
}
query {
user {
name
address {
street
city
}
}
}
{
"data": {
"user": {
"name": "Harry Potter",
"address": {
"street": "4 Privet Drive",
"city": "Little Whinging"
}
}
}
}
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"