Skip to content

Add a null-check to the ids argument in the stopPlaces Transmodel API endpoint. #6556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: dev-2.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ private GraphQLSchema create() {
.field(
GraphQLFieldDefinition.newFieldDefinition()
.name("stopPlaces")
.description("Get all stopPlaces")
.description("Get stopPlaces by ids. The ids argument must be set to a non-null value.")
.withDirective(TransmodelDirectives.TIMING_DATA)
.type(new GraphQLNonNull(new GraphQLList(stopPlaceType)))
.argument(
Expand All @@ -457,20 +457,13 @@ private GraphQLSchema create() {
.build()
)
.dataFetcher(env -> {
if (env.getArgument("ids") != null) {
var ids = mapIDsToDomainNullSafe(env.getArgument("ids"));
return ids
.stream()
.map(id -> StopPlaceType.fetchStopPlaceById(id, env))
.collect(Collectors.toList());
if (env.getArgument("ids") == null) {
throw new IllegalArgumentException("ids argument must be set to a non-null value.");
}
TransitService transitService = GqlUtil.getTransitService(env);
return transitService
.listStations()
var ids = mapIDsToDomainNullSafe(env.getArgument("ids"));
return ids
.stream()
.map(station ->
new MonoOrMultiModalStation(station, transitService.findMultiModalStation(station))
)
.map(id -> StopPlaceType.fetchStopPlaceById(id, env))
.collect(Collectors.toList());
})
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ type QueryType {
): [PtSituationElement!]! @timingData
"Get a single stopPlace based on its id)"
stopPlace(id: String!): StopPlace @timingData
"Get all stopPlaces"
"Get stopPlaces by ids. The ids argument must be set to a non-null value."
stopPlaces(ids: [String]): [StopPlace]! @timingData
"Get all stop places within the specified bounding box"
stopPlacesByBbox(
Expand Down
Loading