Add vehicleRentalsByBbox query to GTFS GraphQL API#6186
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev-2.x #6186 +/- ##
=============================================
- Coverage 69.90% 69.72% -0.18%
+ Complexity 17722 17714 -8
=============================================
Files 1998 2010 +12
Lines 75443 75898 +455
Branches 7718 7766 +48
=============================================
+ Hits 52739 52921 +182
- Misses 20025 20265 +240
- Partials 2679 2712 +33 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
optionsome
left a comment
There was a problem hiding this comment.
You could try adding tests for this query. You can mimic what is done in for example https://github.com/opentripplanner/OpenTripPlanner/blob/dev-2.x/application/src/test/resources/org/opentripplanner/apis/gtfs/queries/vehicle-rental-station.graphql https://github.com/opentripplanner/OpenTripPlanner/blob/dev-2.x/application/src/test/resources/org/opentripplanner/apis/gtfs/expectations/vehicle-rental-station.json. The tests are run in https://github.com/opentripplanner/OpenTripPlanner/blob/dev-2.x/application/src/test/java/org/opentripplanner/apis/gtfs/GraphQLIntegrationTest.java
|
What is your use case for this btw? Are you only interested in the stations, not floating vehicles? Would it make more sense to use a vector map layer to achieve something similar to this? |
|
If possible I prefer to keep it a graphql query because we have a backend that calls OTP and add some custom data to the returned object. |
There are two options. Either separate queries or one query that returns a new interface/union type which we could call |
|
I think the easiest way to do this is to have two different queries for stations and free floating but I also like the idea of having one single query that does both. type VehicleRentalPlace implements Node PlaceInterface {
"""
If true, vehicles can be returned to this station if the station has spaces available
or allows overloading.
"""
allowDropoff: Boolean
"If true, vehicles can be currently returned to this station."
allowDropoffNow: Boolean
"If true, vehicles can be returned even if spacesAvailable is zero or vehicles > capacity."
allowOverloading: Boolean
"If true, vehicles can be picked up from this station if the station has vehicles available."
allowPickup: Boolean
"If true, vehicles can be currently picked up from this station."
allowPickupNow: Boolean
"Nominal capacity (number of racks) of the rental station. One if free floating vehicle."
capacity: Int
"Number of vehicles currently available on the rental station, grouped by vehicle type."
availableVehicles: RentalVehicleEntityCounts
"Global object ID provided by Relay. This value can be used to refetch this object using **node** query."
id: ID!
"Latitude of the vehicle (WGS 84)"
lat: Float
"Longitude of the vehicle (WGS 84)"
lon: Float
"Name of the vehicle"
name: String!
"If true, station is on and in service."
operative: Boolean
"The vehicle rental network information. This is referred as system in the GBFS terminology."
rentalNetwork: VehicleRentalNetwork!
"Platform-specific URLs to begin the vehicle."
rentalUris: VehicleRentalUris
"ID of the vehicle in the format of network:id"
stationId: String
"Vehicle current fuel percentage. Highest battery percent among vehicles if it is a station."
currentFuelPercent: Float
}I added also the currentFuelPercent property, it is related to an issue I opened a week ago. Of course I will not implement it here. |
If you create a new interface, you don't have to specify all the fields from both types there, instead you can only specify the common types. So something like Then you can change the existing types to implement this interface (which they sort of do already) Then you can from In practice, it means you can either use named or inlined fragments to use these types in query (this example is with inlined fragments) |
|
Hi, thanks for the input. I implemented the VehicleRental interface with the relative query. |
vehicleRentalsByBbox query to GTFS GraphQL API
Co-authored-by: Joel Lappalainen <lappalj8@gmail.com>
Summary
Add vehicleRentalStationsByBbox query to gtfs graphql schema
Unit tests
pass the continuous integration service
? Yes
Documentation
I added the proper comments in the schema.graphqls file