Query cities w/enrichment sort

Now lets take spice to another dimension. Let's capture the Parcl Labs Price Feed however this time we want to order cities based on the number of Millenial WFH Population in descending order.

Key Notes

  • order by average census_aggregate on Millenial_WFH_Population in desc order
query MyQuery {
  MSA(where: {MSA_NAME: {_eq: "New York-Newark-Jersey City, NY-NJ-PA"}}) {
    MSA_NAME
    parcl_price_feed_aggregate(limit: 14, order_by: {DATE: desc}) {
      aggregate {
        avg {
          PARCL_PRICE_FEED
        }
      }
    }
    cities(limit: 10, order_by: {census_aggregate: {avg: {Millennial_WFH_Population: desc}}}) {
      CITY_NAME
      parcl_price_feed(limit: 3, order_by: {DATE: desc}) {
        PARCL_PRICE_FEED
        DATE
      }
      census(limit: 5, order_by: {YEAR: desc}) {
        Millennial_WFH_Population
        YEAR
      }
    }
  }
}

Results

{
  "data": {
    "MSA": [
      {
        "MSA_NAME": "New York-Newark-Jersey City, NY-NJ-PA",
        "parcl_price_feed_aggregate": {
          "aggregate": {
            "avg": {
              "PARCL_PRICE_FEED": 323.92405795264
            }
          }
        },
        "cities": [
          {
            "CITY_NAME": "New York",
            "parcl_price_feed": [
              {
                "PARCL_PRICE_FEED": 505.2091693260863,
                "DATE": "2022-10-24"
              },
              {
                "PARCL_PRICE_FEED": 507.89352761956457,
                "DATE": "2022-10-22"
              },
              {
                "PARCL_PRICE_FEED": 507.12428124999934,
                "DATE": "2022-10-21"
              }
            ],
            "census": [
              {
                "Millennial_WFH_Population": 158765,
                "YEAR": 2020
              },
              {
                "Millennial_WFH_Population": 81706,
                "YEAR": 2019
              },
              {
                "Millennial_WFH_Population": 77398,
                "YEAR": 2018
              },
              {
                "Millennial_WFH_Population": 73961,
                "YEAR": 2016
              },
              {
                "Millennial_WFH_Population": 70993,
                "YEAR": 2015
              }
            ]
          },
          ...
          }
          }