diff --git a/src/main/java/org/opentripplanner/index/IndexGraphQLSchema.java b/src/main/java/org/opentripplanner/index/IndexGraphQLSchema.java index 4c4148d18b6..b3c920cbc84 100644 --- a/src/main/java/org/opentripplanner/index/IndexGraphQLSchema.java +++ b/src/main/java/org/opentripplanner/index/IndexGraphQLSchema.java @@ -3355,12 +3355,24 @@ else if (minDate.compareTo(maxDate) == 0) { .description("Only return alerts with these causes") .type(new GraphQLList(new GraphQLNonNull(alertCauseEnum))) .build()) + .argument(GraphQLArgument.newArgument() + .name("route") + .description("Only return alerts affecting these routes") + .type(new GraphQLList(new GraphQLNonNull(Scalars.GraphQLString))) + .build()) + .argument(GraphQLArgument.newArgument() + .name("stop") + .description("Only return alerts affecting these stops") + .type(new GraphQLList(new GraphQLNonNull(Scalars.GraphQLString))) + .build()) .dataFetcher(environment -> { return index.getAlerts().stream() .filter(alert -> environment.getArgument("feeds") == null || ((List)environment.getArgument("feeds")).contains(alert.getFeedId())) .filter(alert -> environment.getArgument("severityLevel") == null || ((List)environment.getArgument("severityLevel")).contains(alert.getAlert().severityLevel)) .filter(alert -> environment.getArgument("effect") == null || ((List)environment.getArgument("effect")).contains(alert.getAlert().effect)) .filter(alert -> environment.getArgument("cause") == null || ((List)environment.getArgument("cause")).contains(alert.getAlert().cause)) + .filter(alert -> environment.getArgument("route") == null || (alert.getRoute() != null && ((List)environment.getArgument("route")).contains(FeedScopedId.convertToString(alert.getRoute())))) + .filter(alert -> environment.getArgument("stop") == null || (alert.getStop() != null && ((List)environment.getArgument("stop")).contains(FeedScopedId.convertToString(alert.getStop())))) .collect(Collectors.toList()); }) .build())