diff --git a/src/main/java/org/opentripplanner/index/IndexGraphQLSchema.java b/src/main/java/org/opentripplanner/index/IndexGraphQLSchema.java index 0911ddbc2f3..a9fd398e2e3 100644 --- a/src/main/java/org/opentripplanner/index/IndexGraphQLSchema.java +++ b/src/main/java/org/opentripplanner/index/IndexGraphQLSchema.java @@ -2963,6 +2963,11 @@ private Object getObject(String idString) { .description("Only return stations that match one of the ids in this list") .type(new GraphQLList(Scalars.GraphQLString)) .build()) + .argument(GraphQLArgument.newArgument() + .name("feeds") + .description("List of feeds from which stations are returned. Defaults to all feeds") + .type(GraphQLList.list(GraphQLNonNull.nonNull(Scalars.GraphQLString))) + .build()) .argument(GraphQLArgument.newArgument() .name("name") .description("Query stations by name") @@ -2973,11 +2978,6 @@ private Object getObject(String idString) { .description("Number of results to return when using `name` argument. Defaults to 10") .type(Scalars.GraphQLInt) .build()) - .argument(GraphQLArgument.newArgument() - .name("feeds") - .description("List of feeds from which stations are returned when using `name` argument. Defaults to all feeds") - .type(GraphQLList.list(GraphQLNonNull.nonNull(Scalars.GraphQLString))) - .build()) .dataFetcher(environment -> { if ((environment.getArgument("ids") instanceof List)) { if (environment.getArguments().entrySet() @@ -2995,7 +2995,12 @@ private Object getObject(String idString) { Stream stream; if (environment.getArgument("name") == null) { - stream = index.stationForId.values().stream(); + if (environment.getArgument("feeds") == null) { + stream = index.stationForId.values().stream(); + } else { + List feedIds = environment.getArgument("feeds"); + stream = index.stationForId.values().stream().filter(station -> feedIds.contains(station.getId().getAgencyId())); + } } else { int maxResults = environment.getArgument("maxResults") != null ? environment.getArgument("maxResults") : 10; List feeds = environment.getArgument("feeds");