Skip to content

Commit

Permalink
add previousLegs into GTFS GraphQL API
Browse files Browse the repository at this point in the history
  • Loading branch information
miklcct committed Oct 10, 2024
1 parent 155d19b commit 5d67bf1
Show file tree
Hide file tree
Showing 4 changed files with 1,542 additions and 4,164 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,17 @@ private Leg getSource(DataFetchingEnvironment environment) {
return environment.getSource();
}

@Override
public DataFetcher<Iterable<Leg>> previousLegs() {
return nextOrPreviousLegs(true);
}

@Override
public DataFetcher<Iterable<Leg>> nextLegs() {
return nextOrPreviousLegs(false);
}

private DataFetcher<Iterable<Leg>> nextOrPreviousLegs(boolean includeDepartBefore) {
return environment -> {
if (environment.getSource() instanceof ScheduledTransitLeg originalLeg) {
var args = new GraphQLTypes.GraphQLLegNextLegsArgs(environment.getArguments());
Expand Down Expand Up @@ -307,7 +316,7 @@ public DataFetcher<Iterable<Leg>> nextLegs() {
environment.getSource(),
numberOfLegs,
environment.<GraphQLRequestContext>getContext().transitService(),
false,
includeDepartBefore,
AlternativeLegsFilter.NO_FILTER,
limitToExactOriginStop,
limitToExactDestinationStop
Expand Down
Loading

0 comments on commit 5d67bf1

Please sign in to comment.