# SPDX-FileCopyrightText: 2020 Volker Krause <vkrause@kde.org>
# SPDX-License-Identifier: CC0-1.0

query stopsByCoordinate(
    $lat: Float!
    $lon: Float!
    $radius: Float!
    $maxResults: Int!
    $placeType: [FilterPlaceType]!
) {
  stopsByRadius: nearest(
    latitude: $lat
    longitude: $lon
    maximumDistance: $radius
    maximumResults: $maxResults
    filterByPlaceTypes: $placeType
  ) {
    edges {
      node {
        stop: place { ...on StopPlace {
          id
          name
          lat: latitude
          lon: longitude
          parentStation: parent {
            id
            name
            lat: latitude
            lon: longitude
          }
          transportMode
        }}
        bikeRentalStation: place { ...bikeRentalStationFragment }
        rentalVehicle: place { ...rentalVehicleFragment }
      }
    }
  }
}

#include <bikerentalfragment.graphql>

fragment rentalVehicleFragment on RentalVehicle {
    id
    vehicleType { ...rentalVehicleTypeFragment }
    network
    lon: longitude
    lat: latitude
    # TODO currently produces a server-side GraphQL serialization error due to a type mismatch
    #currentRangeMeters
}

fragment rentalVehicleTypeFragment on RentalVehicleType {
    vehicleTypeId
    name
    formFactor
    propulsionType
    maxRangeMeters
}
