thepont / graphql-aggregate-sample

GraphQL Aggregate Sample
2 stars 1 forks source link

to run the run script run the follow command at the command line

npm run run

this should start a webserver on port 3121, connecting to this port should give you a GraphiQL interface allowing accesss to the people collection via the graphql-aggregation methods

Example Query:

The following query proves that people with blue eyes and an age less then 40 and also and an age less the 29 on average are younger then their green and brown eyed counterparts.

The searching for the elixer of youth we can therefor turn the to blue eyed population.

{
  people {
    count
    average {
      age
      index
    }
    filter {
      age(lt: 40) {
        average {
          age
        }
        filter {
          age(lt: 29) {
            average {
              age
            }
            count
            groupedBy {
              eyeColor {
                keys
                values {
                  count
                  average {
                    age
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

data.js is generated by (JSON-Generator)[http://beta.json-generator.com/4J77vWKgG]