/requested-fields-demo

Sample GraphQL server to show the use of the requested-fields lib.

Primary LanguageGo

requested-fields-demo Maintainability

Sample GraphQL server to show the use of the requested-fields lib. Created with graphql-go and chi.

Setup

dep init
dep ensure
go build
./requested-fields-demo

Schema

schema {
  query: Query
}

type Query {
  user: User
}

type User {
  name: String
  address: Address
}

type Address {
  city: String
  street: String
}

Query

Request:

query {
  user {
    name
    address {
      street
      city
    }
  }
}

Result:

{
  "data": {
    "user": {
      "name": "Harry Potter",
      "address": {
        "street": "4 Privet Drive",
        "city": "Little Whinging"
      }
    }
  }
}

Logs:

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"