forked from opentripplanner/OpenTripPlanner
-
Notifications
You must be signed in to change notification settings - Fork 30
/
GraphQLRequestContext.java
46 lines (43 loc) · 1.7 KB
/
GraphQLRequestContext.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package org.opentripplanner.ext.gtfsgraphqlapi;
import javax.annotation.Nonnull;
import org.opentripplanner.routing.api.RoutingService;
import org.opentripplanner.routing.api.request.RouteRequest;
import org.opentripplanner.routing.fares.FareService;
import org.opentripplanner.routing.graphfinder.GraphFinder;
import org.opentripplanner.routing.vehicle_parking.VehicleParkingService;
import org.opentripplanner.service.realtimevehicles.RealtimeVehicleService;
import org.opentripplanner.service.vehiclerental.VehicleRentalService;
import org.opentripplanner.standalone.api.OtpServerRequestContext;
import org.opentripplanner.transit.service.TransitService;
public record GraphQLRequestContext(
RoutingService routingService,
TransitService transitService,
FareService fareService,
VehicleParkingService vehicleParkingService,
VehicleRentalService vehicleRentalService,
RealtimeVehicleService realtimeVehicleService,
GraphFinder graphFinder,
RouteRequest defaultRouteRequest
) {
public static GraphQLRequestContext ofServerContext(OtpServerRequestContext context) {
return new GraphQLRequestContext(
context.routingService(),
context.transitService(),
context.graph().getFareService(),
context.graph().getVehicleParkingService(),
context.vehicleRentalService(),
context.realtimeVehicleService(),
context.graphFinder(),
context.defaultRouteRequest()
);
}
/**
* Returns a clone of the default route request. The clone is necessary because one HTTP
* request can lead to several GraphQL queries, for example through batch or alias queries.
*/
@Nonnull
@Override
public RouteRequest defaultRouteRequest() {
return defaultRouteRequest.clone();
}
}