This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const mapConfig = { | |
| style: "mapbox://styles/mapbox/outdoors-v10", | |
| containerStyle: { | |
| height: "100vh", | |
| width: "100vw" | |
| }, | |
| center: { lat: 30.266666, lng: -97.73333 }, | |
| flyToOptions: { | |
| speed: 0.8 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from "react"; | |
| import { Layer, Feature } from "react-mapbox-gl"; | |
| import { gql } from "apollo-boost"; | |
| import { useQuery } from "@apollo/react-hooks"; | |
| function UserFeatures({ bbox }) { | |
| const { loading, error, data } = useQuery(USER_FEATURES, { | |
| variables: { bbox } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const USER_FEATURES = gql` | |
| query($bbox: BBox) { | |
| geoSearch(bbox: $bbox) { | |
| users { | |
| hits { | |
| name | |
| location { | |
| lat | |
| lon | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| query ($bbox: BBox) { | |
| geoSearch(bbox: $bbox) { | |
| users(name: "M") { | |
| hits { | |
| id | |
| name | |
| location { | |
| lat | |
| lon | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val route: Route = | |
| (post & path("graphql")) { | |
| entity(as[JsValue]) { requestJson => | |
| GraphQLServer.endpoint(requestJson) | |
| } | |
| } ~ { | |
| getFromResource("graphiql.html") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package models.responses | |
| import spray.json.DefaultJsonProtocol | |
| import models.common._ | |
| // CoffeeShop.scala | |
| case class CoffeeShop(id: Int, name: String, location: Location) extends GeoSearchable | |
| object CoffeeShop extends DefaultJsonProtocol { | |
| implicit val format = jsonFormat3(CoffeeShop.apply) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package models.responses | |
| import models.common._ | |
| // SearchResponse.scala | |
| trait SearchResponse[T <: GeoSearchable] { | |
| val hits: Seq[T] | |
| val total: Long | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| case class Location(lat: String, lon: String) | |
| object Location extends DefaultJsonProtocol { | |
| implicit val format = jsonFormat2(Location.apply) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def buildQuery(queryFilter: Filter): BoolQuery = { | |
| var qMusts = mutable.ListBuffer[Query]() | |
| var qFilters = mutable.ListBuffer[Query]() | |
| if (queryFilter.name.isDefined) { | |
| val name = queryFilter.name.get.toLowerCase() | |
| qMusts += prefixQuery("name", name); | |
| } else { | |
| qMusts += matchAllQuery() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| query ($bbox: BBox) { | |
| geoSearch(bbox: $bbox) { | |
| users(name: "M") { | |
| hits { | |
| id | |
| name | |
| location { | |
| lat | |
| lon | |
| } |